add: local wishlists stored in local storage for anonymous users
This commit is contained in:
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import PageContainer from '$lib/components/layout/PageContainer.svelte';
|
||||
import DashboardHeader from '$lib/components/layout/DashboardHeader.svelte';
|
||||
import WishlistSection from '$lib/components/dashboard/WishlistSection.svelte';
|
||||
import LocalWishlistsSection from '$lib/components/dashboard/LocalWishlistsSection.svelte';
|
||||
import { enhance } from '$app/forms';
|
||||
import { Star } from 'lucide-svelte';
|
||||
import { languageStore } from '$lib/stores/language.svelte';
|
||||
@@ -36,8 +37,12 @@
|
||||
<PageContainer>
|
||||
<DashboardHeader userName={data.user?.name} userEmail={data.user?.email} />
|
||||
|
||||
<!-- My Wishlists Section -->
|
||||
<WishlistSection
|
||||
<!-- Local Wishlists Section (for anonymous and authenticated users) -->
|
||||
<LocalWishlistsSection isAuthenticated={data.isAuthenticated} />
|
||||
|
||||
{#if data.isAuthenticated}
|
||||
<!-- My Wishlists Section -->
|
||||
<WishlistSection
|
||||
title={t.dashboard.myWishlists}
|
||||
description={t.dashboard.myWishlistsDescription}
|
||||
items={myWishlists()}
|
||||
@@ -189,4 +194,5 @@
|
||||
</div>
|
||||
{/snippet}
|
||||
</WishlistSection>
|
||||
{/if}
|
||||
</PageContainer>
|
||||
|
||||
Reference in New Issue
Block a user