update: hide claimed wishlists when no wishlists are claimed
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user