From a6724a0f22788da367f73aebfd5f334b3f0671ea Mon Sep 17 00:00:00 2001 From: rasmusq Date: Wed, 26 Nov 2025 00:50:05 +0100 Subject: [PATCH] update: hide claimed wishlists when no wishlists are claimed --- src/lib/i18n/translations/da.ts | 2 ++ src/lib/i18n/translations/en.ts | 2 ++ src/routes/dashboard/+page.server.ts | 23 +++++++++++++++++++++++ src/routes/dashboard/+page.svelte | 15 ++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/lib/i18n/translations/da.ts b/src/lib/i18n/translations/da.ts index ac93420..94b08f0 100644 --- a/src/lib/i18n/translations/da.ts +++ b/src/lib/i18n/translations/da.ts @@ -20,6 +20,8 @@ export const da: Translation = { copyLink: 'Kopiér Link', viewWishlist: 'Se Ønskeliste', unsave: 'Fjern', + unclaim: 'Fjern Ejerskab', + delete: 'Slet', emptyWishlists: 'Du har ikke oprettet nogen ønskelister endnu.', emptyWishlistsAction: 'Opret Din Første Ønskeliste', emptyClaimedWishlists: 'Du har ikke taget ejerskab af nogen ønskelister endnu.', diff --git a/src/lib/i18n/translations/en.ts b/src/lib/i18n/translations/en.ts index 6a6c9a7..b6c64fb 100644 --- a/src/lib/i18n/translations/en.ts +++ b/src/lib/i18n/translations/en.ts @@ -17,6 +17,8 @@ export const en = { copyLink: 'Copy Link', viewWishlist: 'View Wishlist', unsave: 'Unsave', + unclaim: 'Unclaim', + delete: 'Delete', emptyWishlists: "You haven't created any wishlists yet.", emptyWishlistsAction: 'Create Your First Wishlist', emptyClaimedWishlists: "You haven't claimed any wishlists yet.", diff --git a/src/routes/dashboard/+page.server.ts b/src/routes/dashboard/+page.server.ts index cb730ce..20d03b9 100644 --- a/src/routes/dashboard/+page.server.ts +++ b/src/routes/dashboard/+page.server.ts @@ -119,6 +119,29 @@ export const actions: Actions = { eq(savedWishlists.userId, session.user.id) )); + return { success: true }; + }, + + deleteWishlist: async ({ request, locals }) => { + const session = await locals.auth(); + if (!session?.user?.id) { + throw redirect(303, '/signin'); + } + + const formData = await request.formData(); + const wishlistId = formData.get('wishlistId') as string; + + if (!wishlistId) { + return { success: false, error: 'Wishlist ID is required' }; + } + + // Verify the user owns this wishlist + await db.delete(wishlists) + .where(and( + eq(wishlists.id, wishlistId), + eq(wishlists.userId, session.user.id) + )); + return { success: true }; } }; diff --git a/src/routes/dashboard/+page.svelte b/src/routes/dashboard/+page.svelte index 3e58f62..a570b69 100644 --- a/src/routes/dashboard/+page.svelte +++ b/src/routes/dashboard/+page.svelte @@ -216,6 +216,19 @@ > {t.dashboard.copyLink} + {#if myWishlistsUnlocked} + +
{ + return async ({ update }) => { + await update({ reset: false }); + }; + }}> + + +
+ {/if} {/snippet} @@ -287,7 +300,7 @@ }}> {/if}