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:
parent
1bf60c3ac6
commit
397e84ae17
9 changed files with 20 additions and 13 deletions
|
|
@ -10,9 +10,11 @@ public record CreateTaskResponse(
|
|||
String title,
|
||||
String description,
|
||||
TaskStatus status,
|
||||
String projectName,
|
||||
ProjectResponse project,
|
||||
LocalDateTime finishedAt,
|
||||
List<TaskHistoryItemResponse> history) {
|
||||
|
||||
public record ProjectResponse(Long id, String name) {}
|
||||
}
|
||||
|
||||
record TaskHistoryItemResponse(
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class TaskControllerMapper {
|
|||
output.title(),
|
||||
output.description(),
|
||||
output.status(),
|
||||
output.projectName(),
|
||||
Objects.nonNull(output.project()) ? new CreateTaskResponse.ProjectResponse(output.project().id(), output.project().name()) : null,
|
||||
output.finishedAt(),
|
||||
output.history().stream().map(taskHistoryItemOutput -> new TaskHistoryItemResponse(taskHistoryItemOutput.id(), taskHistoryItemOutput.startAt(), taskHistoryItemOutput.endAt())).toList()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class CreateTaskMapper {
|
|||
task.getTitle(),
|
||||
task.getDescription(),
|
||||
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.getHistory().stream().map(CreateTaskMapper::toTaskHistoryItemOutput).toList());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ public record CreateTaskOutput(
|
|||
String title,
|
||||
String description,
|
||||
TaskStatus status,
|
||||
String projectName,
|
||||
ProjectOutput project,
|
||||
LocalDateTime finishedAt,
|
||||
List<TaskHistoryItemOutput> history) {
|
||||
|
||||
public record ProjectOutput(Long id, String name) {}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ export function CreateTaskPage() {
|
|||
title: data.title,
|
||||
description: data.description || "",
|
||||
status: data.status,
|
||||
projectId: data.projectId?.toString() || "",
|
||||
projectId: data.project?.id?.toString() || "",
|
||||
history: data.history || [],
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
@ -156,7 +156,7 @@ export function CreateTaskPage() {
|
|||
{TASK_STATUS_LABELS[createdTask.status]}
|
||||
</span>
|
||||
<span className="text-[10px] font-bold text-text-muted">
|
||||
{createdTask.project || "Geral"}
|
||||
{createdTask.project?.name || "Geral"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ export const DashboardPage: React.FC = () => {
|
|||
{task.title}
|
||||
</div>
|
||||
<div className="text-[10px] font-black uppercase text-brand tracking-widest">
|
||||
{task.projectName}
|
||||
{task.project?.name}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -360,7 +360,7 @@ export const DashboardPage: React.FC = () => {
|
|||
</td>
|
||||
<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">
|
||||
{task.projectName}
|
||||
{task.project?.name}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-4 text-sm font-bold text-text-main">
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ export function TaskBoardPage() {
|
|||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-1 text-[10px] font-bold text-text-muted">
|
||||
<Tag size={12} className="text-brand" />
|
||||
{task.projectName || 'Geral'}
|
||||
{task.project?.name || 'Geral'}
|
||||
</div>
|
||||
<span className="font-mono text-[10px] font-bold text-text-muted/50">
|
||||
#{task.id}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export function TaskListPage() {
|
|||
const matchesSearch =
|
||||
task.title.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
|
||||
|
||||
|
|
@ -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 items-center gap-1.5 text-xs font-bold text-text-muted">
|
||||
<Tag size={14} className="text-brand" />
|
||||
{task.projectName || 'Geral'}
|
||||
{task.project?.name || 'Geral'}
|
||||
</div>
|
||||
<div className="h-4 w-px bg-border-soft" />
|
||||
<div className="flex items-center gap-1.5 text-xs font-bold text-text-muted">
|
||||
|
|
|
|||
|
|
@ -27,13 +27,17 @@ export type TaskHistoryItem = {
|
|||
endAt: string | null
|
||||
}
|
||||
|
||||
export type TaskProject = {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export type TaskResponse = {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
status: TaskStatus
|
||||
projectName: string
|
||||
projectId?: number
|
||||
project: TaskProject | null
|
||||
finishedAt?: string
|
||||
history?: TaskHistoryItem[]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue