mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
fix(shared): align todo contracts with the wire format the client sends
The optional metadata fields (category, due_date, description, assigned_user_id — plus priority on update) now accept explicit null: the client clears fields by sending null, which the schemas rejected. checked accepts the legacy 0/1 numeric form alongside boolean (the integration net pins it). Drops the client-side casts that papered over the too-narrow types.
This commit is contained in:
@@ -20,19 +20,6 @@ export interface MTaskSheetProps {
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
/** Payload shape covering both create and update — the update schema allows
|
||||
* clearing a field with `null`, which `TodoUpdateItemRequest` itself (typed
|
||||
* against the create request) doesn't express; the store call below is cast
|
||||
* to it rather than widened to `any`. */
|
||||
interface TodoSavePayload {
|
||||
name: string
|
||||
description: string | null
|
||||
due_date: string | null
|
||||
category: string | null
|
||||
assigned_user_id: number | null
|
||||
priority: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Edit task sheet (spec 03 §4.7 `openTask` / progress-card "New task"):
|
||||
* name, description, list (category), due date, assignee and priority.
|
||||
@@ -99,7 +86,7 @@ export default function MTaskSheet({ planner, open, itemId, categories, members,
|
||||
setSaving(true)
|
||||
try {
|
||||
if (item) {
|
||||
const payload: TodoSavePayload = {
|
||||
const payload: TodoUpdateItemRequest = {
|
||||
name: trimmedName,
|
||||
description: description || null,
|
||||
due_date: dueDate || null,
|
||||
@@ -107,7 +94,7 @@ export default function MTaskSheet({ planner, open, itemId, categories, members,
|
||||
assigned_user_id: assignedUserId,
|
||||
priority,
|
||||
}
|
||||
await tripActions.updateTodoItem(tripId, item.id, payload as unknown as TodoUpdateItemRequest)
|
||||
await tripActions.updateTodoItem(tripId, item.id, payload)
|
||||
} else {
|
||||
const payload: TodoCreateItemRequest = {
|
||||
name: trimmedName,
|
||||
|
||||
Reference in New Issue
Block a user