diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-07 19:17:14 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-07 19:17:14 +0200 |
| commit | 66939bab93cdcb9b7732c45d7bc3b99b6951fe15 (patch) | |
| tree | ec6bc1631464410f8735da49e02e99abff0f3863 /src/lib/server/services/grocery-actions.ts | |
| parent | 6e5dcdb53cea4c3f082d01c937fe5fc1d580c45b (diff) | |
feat: promote a reference as the primary shown in lists
Add an is_primary flag to references; the promoted ref sorts first on the item page and is the one shown under the item in the list and catalog. Item page gets a star toggle per reference.
Diffstat (limited to 'src/lib/server/services/grocery-actions.ts')
| -rw-r--r-- | src/lib/server/services/grocery-actions.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/server/services/grocery-actions.ts b/src/lib/server/services/grocery-actions.ts index 2138f2d..1cfb05d 100644 --- a/src/lib/server/services/grocery-actions.ts +++ b/src/lib/server/services/grocery-actions.ts @@ -14,18 +14,18 @@ export async function toggleGroceryAction(request: Request) { return { success: true }; } -export type DeleteRowResult = - ActionFailure<{ error: string }> | { success: boolean; type?: 'delete' }; +export type RowActionResult = + ActionFailure<{ error: string }> | { success: boolean; type?: string }; -/** Shared 'delete by id form field' action for category and reference lists. */ -export async function deleteByIdAction( +/** Shared 'run fn with the id form field' action for row-based lists. */ +export async function idAction( request: Request, - deleteFn: (id: number) => Promise<unknown>, - extra?: { type: 'delete' }, -): Promise<DeleteRowResult> { + fn: (id: number) => Promise<unknown>, + extra?: { type: string }, +): Promise<RowActionResult> { const data = await request.formData(); try { - await deleteFn(numericId(data.get('id'))); + await fn(numericId(data.get('id'))); } catch { return fail(400, { error: 'ID invalide' }); } |
