update: hide claimed wishlists when no wishlists are claimed
This commit is contained in:
@@ -20,6 +20,8 @@ export const da: Translation = {
|
|||||||
copyLink: 'Kopiér Link',
|
copyLink: 'Kopiér Link',
|
||||||
viewWishlist: 'Se Ønskeliste',
|
viewWishlist: 'Se Ønskeliste',
|
||||||
unsave: 'Fjern',
|
unsave: 'Fjern',
|
||||||
|
unclaim: 'Fjern Ejerskab',
|
||||||
|
delete: 'Slet',
|
||||||
emptyWishlists: 'Du har ikke oprettet nogen ønskelister endnu.',
|
emptyWishlists: 'Du har ikke oprettet nogen ønskelister endnu.',
|
||||||
emptyWishlistsAction: 'Opret Din Første Ønskeliste',
|
emptyWishlistsAction: 'Opret Din Første Ønskeliste',
|
||||||
emptyClaimedWishlists: 'Du har ikke taget ejerskab af nogen ønskelister endnu.',
|
emptyClaimedWishlists: 'Du har ikke taget ejerskab af nogen ønskelister endnu.',
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ export const en = {
|
|||||||
copyLink: 'Copy Link',
|
copyLink: 'Copy Link',
|
||||||
viewWishlist: 'View Wishlist',
|
viewWishlist: 'View Wishlist',
|
||||||
unsave: 'Unsave',
|
unsave: 'Unsave',
|
||||||
|
unclaim: 'Unclaim',
|
||||||
|
delete: 'Delete',
|
||||||
emptyWishlists: "You haven't created any wishlists yet.",
|
emptyWishlists: "You haven't created any wishlists yet.",
|
||||||
emptyWishlistsAction: 'Create Your First Wishlist',
|
emptyWishlistsAction: 'Create Your First Wishlist',
|
||||||
emptyClaimedWishlists: "You haven't claimed any wishlists yet.",
|
emptyClaimedWishlists: "You haven't claimed any wishlists yet.",
|
||||||
|
|||||||
@@ -119,6 +119,29 @@ export const actions: Actions = {
|
|||||||
eq(savedWishlists.userId, session.user.id)
|
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 };
|
return { success: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -216,6 +216,19 @@
|
|||||||
>
|
>
|
||||||
{t.dashboard.copyLink}
|
{t.dashboard.copyLink}
|
||||||
</Button>
|
</Button>
|
||||||
|
{#if myWishlistsUnlocked}
|
||||||
|
<!-- Add delete button for owned wishlists when unlocked -->
|
||||||
|
<form method="POST" action="?/deleteWishlist" use:enhance={() => {
|
||||||
|
return async ({ update }) => {
|
||||||
|
await update({ reset: false });
|
||||||
|
};
|
||||||
|
}}>
|
||||||
|
<input type="hidden" name="wishlistId" value={wishlist.id} />
|
||||||
|
<Button type="submit" size="sm" variant="destructive">
|
||||||
|
{t.dashboard.delete}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</WishlistCard>
|
</WishlistCard>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
@@ -287,7 +300,7 @@
|
|||||||
}}>
|
}}>
|
||||||
<input type="hidden" name="savedWishlistId" value={wishlist.savedId} />
|
<input type="hidden" name="savedWishlistId" value={wishlist.savedId} />
|
||||||
<Button type="submit" size="sm" variant="destructive">
|
<Button type="submit" size="sm" variant="destructive">
|
||||||
{t.dashboard.unsave}
|
{t.dashboard.unclaim}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user