fix: improve import — surface real errors, restore all task fields
- Export now includes kanbanStage, url, urgency, importance, priority, delegatedTo, delegationNote, recurrenceDays so backups are complete - Import now handles those same fields (round-trip fidelity) - Error handler returns the actual error message instead of the generic "Import failed. Please check the file format." — makes failures diagnosable - Guard against empty task title with fallback '(untitled)' v1.87.2
This commit is contained in:
parent
a117b60d84
commit
8ffc127671
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "my-weekly-todo-list",
|
||||
"version": "1.87.1",
|
||||
"version": "1.87.2",
|
||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -79,6 +79,14 @@ export async function GET() {
|
||||
parentTaskId: true,
|
||||
somedaySlotIndex: true,
|
||||
projectId: true,
|
||||
kanbanStage: true,
|
||||
url: true,
|
||||
urgency: true,
|
||||
importance: true,
|
||||
priority: true,
|
||||
delegatedTo: true,
|
||||
delegationNote: true,
|
||||
recurrenceDays: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -22,11 +22,19 @@ interface ImportTask {
|
||||
recurrenceUnit?: string | null;
|
||||
recurrenceTime?: string | null;
|
||||
recurrenceEndDate?: string | null;
|
||||
recurrenceDays?: string | null;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
parentTaskId?: string | null;
|
||||
somedaySlotIndex?: number | null;
|
||||
projectId?: string | null;
|
||||
kanbanStage?: string | null;
|
||||
url?: string | null;
|
||||
urgency?: boolean | null;
|
||||
importance?: boolean | null;
|
||||
priority?: string | null;
|
||||
delegatedTo?: string | null;
|
||||
delegationNote?: string | null;
|
||||
subTasks?: ImportTask[];
|
||||
}
|
||||
|
||||
@ -166,7 +174,7 @@ export async function POST(request: Request) {
|
||||
const created = await prisma.task.create({
|
||||
data: {
|
||||
userId: user.id,
|
||||
title: task.title,
|
||||
title: task.title || '(untitled)',
|
||||
description: task.description ?? null,
|
||||
markdownContent: task.markdownContent ?? null,
|
||||
completed: task.completed ?? false,
|
||||
@ -183,8 +191,16 @@ export async function POST(request: Request) {
|
||||
recurrenceUnit: task.recurrenceUnit ?? null,
|
||||
recurrenceTime: task.recurrenceTime ?? null,
|
||||
recurrenceEndDate: task.recurrenceEndDate ? new Date(task.recurrenceEndDate) : null,
|
||||
recurrenceDays: task.recurrenceDays ?? null,
|
||||
somedaySlotIndex: task.somedaySlotIndex ?? null,
|
||||
projectId: resolvedProjectId ?? null,
|
||||
kanbanStage: task.kanbanStage ?? null,
|
||||
url: task.url ?? null,
|
||||
urgency: task.urgency ?? null,
|
||||
importance: task.importance ?? null,
|
||||
priority: task.priority ?? null,
|
||||
delegatedTo: task.delegatedTo ?? null,
|
||||
delegationNote: task.delegationNote ?? null,
|
||||
},
|
||||
});
|
||||
|
||||
@ -242,9 +258,12 @@ export async function POST(request: Request) {
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Import data error:', error);
|
||||
const message = error instanceof SyntaxError
|
||||
? 'Invalid JSON file'
|
||||
: 'Import failed. Please check the file format.';
|
||||
let message = 'Import failed. Please check the file format.';
|
||||
if (error instanceof SyntaxError) {
|
||||
message = 'Invalid JSON file';
|
||||
} else if (error instanceof Error) {
|
||||
message = `Import failed: ${error.message}`;
|
||||
}
|
||||
return NextResponse.json({ error: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user