diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 8942480..c9d28e5 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -220,6 +220,45 @@ export const actions: Actions = { // Delete from database imageRepository.delete(imageId); + return { success: true }; + }, + + togglePin: async ({ request }) => { + const formData = await request.formData(); + const id = formData.get('id')?.toString(); + + if (!id) { + return fail(400, { error: 'Entry ID is required' }); + } + + const existing = entryRepository.getById(id); + if (!existing) { + return fail(404, { error: 'Entry not found' }); + } + + // Toggle pinned state + entryRepository.update(id, { pinned: !existing.pinned }); + + return { success: true }; + }, + + updateDueDate: async ({ request }) => { + const formData = await request.formData(); + const id = formData.get('id')?.toString(); + const dueDate = formData.get('dueDate')?.toString() || null; + + if (!id) { + return fail(400, { error: 'Entry ID is required' }); + } + + const existing = entryRepository.getById(id); + if (!existing) { + return fail(404, { error: 'Entry not found' }); + } + + // Update due date (empty string becomes null) + entryRepository.update(id, { dueDate: dueDate || null }); + return { success: true }; } };