fix: return project as object with id and name in task response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gabriel Santana de Menezes 2026-05-09 17:16:29 -04:00
parent 1bf60c3ac6
commit 397e84ae17
9 changed files with 20 additions and 13 deletions

View file

@ -10,9 +10,11 @@ public record CreateTaskResponse(
String title, String title,
String description, String description,
TaskStatus status, TaskStatus status,
String projectName, ProjectResponse project,
LocalDateTime finishedAt, LocalDateTime finishedAt,
List<TaskHistoryItemResponse> history) { List<TaskHistoryItemResponse> history) {
public record ProjectResponse(Long id, String name) {}
} }
record TaskHistoryItemResponse( record TaskHistoryItemResponse(

View file

@ -26,7 +26,7 @@ public class TaskControllerMapper {
output.title(), output.title(),
output.description(), output.description(),
output.status(), output.status(),
output.projectName(), Objects.nonNull(output.project()) ? new CreateTaskResponse.ProjectResponse(output.project().id(), output.project().name()) : null,
output.finishedAt(), output.finishedAt(),
output.history().stream().map(taskHistoryItemOutput -> new TaskHistoryItemResponse(taskHistoryItemOutput.id(), taskHistoryItemOutput.startAt(), taskHistoryItemOutput.endAt())).toList() output.history().stream().map(taskHistoryItemOutput -> new TaskHistoryItemResponse(taskHistoryItemOutput.id(), taskHistoryItemOutput.startAt(), taskHistoryItemOutput.endAt())).toList()
); );

View file

@ -11,7 +11,7 @@ public class CreateTaskMapper {
task.getTitle(), task.getTitle(),
task.getDescription(), task.getDescription(),
task.getStatus(), task.getStatus(),
Objects.nonNull(task.getProject()) ? task.getProject().getName() : null, Objects.nonNull(task.getProject()) ? new CreateTaskOutput.ProjectOutput(task.getProject().getId(), task.getProject().getName()) : null,
task.getFinishedAt(), task.getFinishedAt(),
task.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList()); task.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList());
} }

View file

@ -9,8 +9,9 @@ public record CreateTaskOutput(
String title, String title,
String description, String description,
TaskStatus status, TaskStatus status,
String projectName, ProjectOutput project,
LocalDateTime finishedAt, LocalDateTime finishedAt,
List<TaskHistoryItemOutput> history) { List<TaskHistoryItemOutput> history) {
public record ProjectOutput(Long id, String name) {}
} }

View file

@ -55,7 +55,7 @@ export function CreateTaskPage() {
title: data.title, title: data.title,
description: data.description || "", description: data.description || "",
status: data.status, status: data.status,
projectId: data.projectId?.toString() || "", projectId: data.project?.id?.toString() || "",
history: data.history || [], history: data.history || [],
}); });
} catch (error) { } catch (error) {
@ -156,7 +156,7 @@ export function CreateTaskPage() {
{TASK_STATUS_LABELS[createdTask.status]} {TASK_STATUS_LABELS[createdTask.status]}
</span> </span>
<span className="text-[10px] font-bold text-text-muted"> <span className="text-[10px] font-bold text-text-muted">
{createdTask.project || "Geral"} {createdTask.project?.name || "Geral"}
</span> </span>
</div> </div>
</div> </div>

View file

@ -296,7 +296,7 @@ export const DashboardPage: React.FC = () => {
{task.title} {task.title}
</div> </div>
<div className="text-[10px] font-black uppercase text-brand tracking-widest"> <div className="text-[10px] font-black uppercase text-brand tracking-widest">
{task.projectName} {task.project?.name}
</div> </div>
</div> </div>
</div> </div>
@ -360,7 +360,7 @@ export const DashboardPage: React.FC = () => {
</td> </td>
<td className="py-4 text-sm font-medium text-text-muted"> <td className="py-4 text-sm font-medium text-text-muted">
<span className="px-2 py-1 bg-surface-muted rounded-lg border border-border-soft"> <span className="px-2 py-1 bg-surface-muted rounded-lg border border-border-soft">
{task.projectName} {task.project?.name}
</span> </span>
</td> </td>
<td className="py-4 text-sm font-bold text-text-main"> <td className="py-4 text-sm font-bold text-text-main">

View file

@ -192,7 +192,7 @@ export function TaskBoardPage() {
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-1 text-[10px] font-bold text-text-muted"> <div className="flex items-center gap-1 text-[10px] font-bold text-text-muted">
<Tag size={12} className="text-brand" /> <Tag size={12} className="text-brand" />
{task.projectName || 'Geral'} {task.project?.name || 'Geral'}
</div> </div>
<span className="font-mono text-[10px] font-bold text-text-muted/50"> <span className="font-mono text-[10px] font-bold text-text-muted/50">
#{task.id} #{task.id}

View file

@ -85,7 +85,7 @@ export function TaskListPage() {
const matchesSearch = const matchesSearch =
task.title.toLowerCase().includes(searchQuery.toLowerCase()) || task.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
task.description?.toLowerCase().includes(searchQuery.toLowerCase()) || task.description?.toLowerCase().includes(searchQuery.toLowerCase()) ||
task.projectName?.toLowerCase().includes(searchQuery.toLowerCase()) task.project?.name?.toLowerCase().includes(searchQuery.toLowerCase())
const matchesStatus = statusFilter === 'ALL' || task.status === statusFilter const matchesStatus = statusFilter === 'ALL' || task.status === statusFilter
@ -210,7 +210,7 @@ export function TaskListPage() {
<div className="flex flex-wrap items-center gap-3 border-t border-border-soft/50 pt-4"> <div className="flex flex-wrap items-center gap-3 border-t border-border-soft/50 pt-4">
<div className="flex items-center gap-1.5 text-xs font-bold text-text-muted"> <div className="flex items-center gap-1.5 text-xs font-bold text-text-muted">
<Tag size={14} className="text-brand" /> <Tag size={14} className="text-brand" />
{task.projectName || 'Geral'} {task.project?.name || 'Geral'}
</div> </div>
<div className="h-4 w-px bg-border-soft" /> <div className="h-4 w-px bg-border-soft" />
<div className="flex items-center gap-1.5 text-xs font-bold text-text-muted"> <div className="flex items-center gap-1.5 text-xs font-bold text-text-muted">

View file

@ -27,13 +27,17 @@ export type TaskHistoryItem = {
endAt: string | null endAt: string | null
} }
export type TaskProject = {
id: number
name: string
}
export type TaskResponse = { export type TaskResponse = {
id: number id: number
title: string title: string
description: string description: string
status: TaskStatus status: TaskStatus
projectName: string project: TaskProject | null
projectId?: number
finishedAt?: string finishedAt?: string
history?: TaskHistoryItem[] history?: TaskHistoryItem[]
} }