add: local wishlists stored in local storage for anonymous users

This commit is contained in:
rasmusq
2025-11-27 21:35:28 +01:00
parent 8dcf26b1d3
commit 85f8671c72
9 changed files with 264 additions and 13 deletions

View File

@@ -7,8 +7,14 @@ import { eq, and } from 'drizzle-orm';
export const load: PageServerLoad = async (event) => {
const session = await event.locals.auth();
// Allow anonymous users to access dashboard for local wishlists
if (!session?.user?.id) {
throw redirect(303, '/signin');
return {
user: null,
wishlists: [],
savedWishlists: [],
isAuthenticated: false
};
}
const userWishlists = await db.query.wishlists.findMany({
@@ -53,7 +59,8 @@ export const load: PageServerLoad = async (event) => {
return {
user: session.user,
wishlists: userWishlists,
savedWishlists: savedWithAccess
savedWishlists: savedWithAccess,
isAuthenticated: true
};
};