diff --git a/src/app/api/tasks/[id]/route.ts b/src/app/api/tasks/[id]/route.ts index fb01c95..200aa8d 100644 --- a/src/app/api/tasks/[id]/route.ts +++ b/src/app/api/tasks/[id]/route.ts @@ -77,15 +77,9 @@ export async function PUT( nextOccurrence: nextOccurrence ? new Date(nextOccurrence) : undefined, reminders: { deleteMany: {}, - create: (reminders || []).map((r: string) => { - // Parse local datetime string and construct Date to preserve local time - const [datePart, timePart] = r.split('T'); - const [year, month, day] = datePart.split('-').map(Number); - const [hours, minutes] = timePart.split(':').map(Number); - return { - reminder: new Date(Date.UTC(year, month - 1, day, hours, minutes)), - }; - }), + create: (reminders || []).map((r: string) => ({ + reminder: new Date(r), + })), }, }, include: { diff --git a/src/app/api/tasks/route.ts b/src/app/api/tasks/route.ts index 398ceaf..e954d86 100644 --- a/src/app/api/tasks/route.ts +++ b/src/app/api/tasks/route.ts @@ -93,15 +93,9 @@ export async function POST(request: NextRequest) { parentTaskId: parentTaskId || undefined, sortOrder: (maxSort._max.sortOrder ?? 0) + 1, reminders: { - create: (reminders || []).map((r: string) => { - // Parse local datetime string and construct Date to preserve local time - const [datePart, timePart] = r.split('T'); - const [year, month, day] = datePart.split('-').map(Number); - const [hours, minutes] = timePart.split(':').map(Number); - return { - reminder: new Date(Date.UTC(year, month - 1, day, hours, minutes)), - }; - }), + create: (reminders || []).map((r: string) => ({ + reminder: new Date(r), + })), }, }, include: { diff --git a/src/components/EditTaskModal.tsx b/src/components/EditTaskModal.tsx index dedbb17..8cafec7 100644 --- a/src/components/EditTaskModal.tsx +++ b/src/components/EditTaskModal.tsx @@ -44,7 +44,11 @@ export default function EditTaskModal() { .then(data => { setSubtasks(data.subtasks || []); if (data.reminders && data.reminders.length > 0) { - setReminders(data.reminders.map((r: any) => r.reminder)); + // API returns UTC times — convert to local for datetime-local input + setReminders(data.reminders.map((r: any) => { + const d = new Date(r.reminder + 'Z'); + return format(d, "yyyy-MM-dd'T'HH:mm"); + })); } }) .catch(console.error); @@ -81,7 +85,9 @@ export default function EditTaskModal() { status, recurrenceRule, recurrenceInterval, - reminders: reminders.filter((r) => r !== ''), + reminders: reminders + .filter((r) => r !== '') + .map((r) => new Date(r).toISOString()), }), }); diff --git a/src/components/NewTaskModal.tsx b/src/components/NewTaskModal.tsx index 71cca36..5a88c01 100644 --- a/src/components/NewTaskModal.tsx +++ b/src/components/NewTaskModal.tsx @@ -66,7 +66,9 @@ export default function NewTaskModal() { status, recurrenceRule, recurrenceInterval, - reminders: reminders.filter((r) => r !== ''), + reminders: reminders + .filter((r) => r !== '') + .map((r) => new Date(r).toISOString()), }), });