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",
|
"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",
|
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -79,6 +79,14 @@ export async function GET() {
|
|||||||
parentTaskId: true,
|
parentTaskId: true,
|
||||||
somedaySlotIndex: true,
|
somedaySlotIndex: true,
|
||||||
projectId: 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;
|
recurrenceUnit?: string | null;
|
||||||
recurrenceTime?: string | null;
|
recurrenceTime?: string | null;
|
||||||
recurrenceEndDate?: string | null;
|
recurrenceEndDate?: string | null;
|
||||||
|
recurrenceDays?: string | null;
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
updatedAt?: string;
|
updatedAt?: string;
|
||||||
parentTaskId?: string | null;
|
parentTaskId?: string | null;
|
||||||
somedaySlotIndex?: number | null;
|
somedaySlotIndex?: number | null;
|
||||||
projectId?: string | 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[];
|
subTasks?: ImportTask[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +174,7 @@ export async function POST(request: Request) {
|
|||||||
const created = await prisma.task.create({
|
const created = await prisma.task.create({
|
||||||
data: {
|
data: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
title: task.title,
|
title: task.title || '(untitled)',
|
||||||
description: task.description ?? null,
|
description: task.description ?? null,
|
||||||
markdownContent: task.markdownContent ?? null,
|
markdownContent: task.markdownContent ?? null,
|
||||||
completed: task.completed ?? false,
|
completed: task.completed ?? false,
|
||||||
@ -183,8 +191,16 @@ export async function POST(request: Request) {
|
|||||||
recurrenceUnit: task.recurrenceUnit ?? null,
|
recurrenceUnit: task.recurrenceUnit ?? null,
|
||||||
recurrenceTime: task.recurrenceTime ?? null,
|
recurrenceTime: task.recurrenceTime ?? null,
|
||||||
recurrenceEndDate: task.recurrenceEndDate ? new Date(task.recurrenceEndDate) : null,
|
recurrenceEndDate: task.recurrenceEndDate ? new Date(task.recurrenceEndDate) : null,
|
||||||
|
recurrenceDays: task.recurrenceDays ?? null,
|
||||||
somedaySlotIndex: task.somedaySlotIndex ?? null,
|
somedaySlotIndex: task.somedaySlotIndex ?? null,
|
||||||
projectId: resolvedProjectId ?? 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) {
|
} catch (error) {
|
||||||
console.error('Import data error:', error);
|
console.error('Import data error:', error);
|
||||||
const message = error instanceof SyntaxError
|
let message = 'Import failed. Please check the file format.';
|
||||||
? 'Invalid JSON file'
|
if (error instanceof SyntaxError) {
|
||||||
: 'Import failed. Please check the file format.';
|
message = 'Invalid JSON file';
|
||||||
|
} else if (error instanceof Error) {
|
||||||
|
message = `Import failed: ${error.message}`;
|
||||||
|
}
|
||||||
return NextResponse.json({ error: message }, { status: 500 });
|
return NextResponse.json({ error: message }, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user