diff --git a/drizzle/schema.ts b/drizzle/schema.ts index ebf2d4b..c70006b 100644 --- a/drizzle/schema.ts +++ b/drizzle/schema.ts @@ -78,6 +78,9 @@ export const user = pgTable("user", { username: text(), dashboardTheme: text("dashboard_theme").default('none'), dashboardColor: text("dashboard_color"), + lastLogin: timestamp("last_login", { mode: 'string' }), + createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(), + updatedAt: timestamp("updated_at", { mode: 'string' }).defaultNow().notNull(), }, (table) => [ unique("user_email_unique").on(table.email), unique("user_username_unique").on(table.username), diff --git a/src/auth.ts b/src/auth.ts index 4fa6d8f..411ece9 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -103,6 +103,14 @@ const authConfig: SvelteKitAuthConfig = { signIn: '/signin' }, callbacks: { + async signIn({ user }) { + if (user?.id) { + await db.update(users) + .set({ lastLogin: new Date() }) + .where(eq(users.id, user.id)); + } + return true; + }, async jwt({ token, user }) { if (user) { token.id = user.id; diff --git a/src/lib/components/layout/DashboardHeader.svelte b/src/lib/components/layout/DashboardHeader.svelte index 5852c7d..1ac62e0 100644 --- a/src/lib/components/layout/DashboardHeader.svelte +++ b/src/lib/components/layout/DashboardHeader.svelte @@ -79,7 +79,7 @@ {/if}
- + diff --git a/src/lib/components/themes/svgs/BottomPattern.svelte b/src/lib/components/themes/svgs/BottomPattern.svelte index 3459dd3..2a8c5aa 100644 --- a/src/lib/components/themes/svgs/BottomPattern.svelte +++ b/src/lib/components/themes/svgs/BottomPattern.svelte @@ -16,17 +16,15 @@ {#if pattern !== 'none'}
{/if} diff --git a/src/lib/components/themes/svgs/CardPattern.svelte b/src/lib/components/themes/svgs/CardPattern.svelte index 52dc17c..f378160 100644 --- a/src/lib/components/themes/svgs/CardPattern.svelte +++ b/src/lib/components/themes/svgs/CardPattern.svelte @@ -16,18 +16,15 @@ {#if pattern !== 'none'}
{/if} diff --git a/src/lib/components/themes/svgs/TopPattern.svelte b/src/lib/components/themes/svgs/TopPattern.svelte index 87524a2..b42c9f6 100644 --- a/src/lib/components/themes/svgs/TopPattern.svelte +++ b/src/lib/components/themes/svgs/TopPattern.svelte @@ -16,17 +16,16 @@ {#if pattern !== 'none'}
{/if} diff --git a/src/lib/components/ui/ColorPicker.svelte b/src/lib/components/ui/ColorPicker.svelte index b8bddcc..9341b70 100644 --- a/src/lib/components/ui/ColorPicker.svelte +++ b/src/lib/components/ui/ColorPicker.svelte @@ -18,7 +18,7 @@ }; const iconSizeClasses = { - sm: 'w-3 h-3', + sm: 'w-4 h-4', md: 'w-4 h-4', lg: 'w-5 h-5' }; diff --git a/src/lib/components/wishlist/AddItemForm.svelte b/src/lib/components/wishlist/AddItemForm.svelte index 31e1332..a5a1a20 100644 --- a/src/lib/components/wishlist/AddItemForm.svelte +++ b/src/lib/components/wishlist/AddItemForm.svelte @@ -8,12 +8,18 @@ import ColorPicker from '$lib/components/ui/ColorPicker.svelte'; import { enhance } from '$app/forms'; import { languageStore } from '$lib/stores/language.svelte'; + import ThemeCard from '$lib/components/themes/ThemeCard.svelte'; + import { getCardStyle } from '$lib/utils/colors'; interface Props { onSuccess?: () => void; + wishlistColor?: string | null; + wishlistTheme?: string | null; } - let { onSuccess }: Props = $props(); + let { onSuccess, wishlistColor = null, wishlistTheme = null }: Props = $props(); + + const cardStyle = $derived(getCardStyle(wishlistColor, null)); const t = $derived(languageStore.t); @@ -53,11 +59,12 @@ } - - + + + {t.form.addNewWish} - +
void; + wishlistColor?: string | null; + wishlistTheme?: string | null; } - let { item, onSuccess, onCancel, onColorChange, currentPosition = 1, totalItems = 1, onPositionChange }: Props = $props(); + let { item, onSuccess, onCancel, onColorChange, currentPosition = 1, totalItems = 1, onPositionChange, wishlistColor = null, wishlistTheme = null }: Props = $props(); + + const cardStyle = $derived(getCardStyle(wishlistColor, null)); const t = $derived(languageStore.t); @@ -60,11 +66,12 @@ } - - + + + {t.wishlist.editWish} - + onColorUpdate(wishlistColor)} + size="sm" />
diff --git a/src/lib/server/schema.ts b/src/lib/server/schema.ts index d5a796c..de56cd0 100644 --- a/src/lib/server/schema.ts +++ b/src/lib/server/schema.ts @@ -14,7 +14,10 @@ export const users = pgTable('user', { password: text('password'), username: text('username').unique(), dashboardTheme: text('dashboard_theme').default('none'), - dashboardColor: text('dashboard_color') + dashboardColor: text('dashboard_color'), + lastLogin: timestamp('last_login', { mode: 'date' }), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at').defaultNow().notNull() }); export const accounts = pgTable( diff --git a/src/lib/utils/themes.ts b/src/lib/utils/themes.ts index f938f41..5cbe2c5 100644 --- a/src/lib/utils/themes.ts +++ b/src/lib/utils/themes.ts @@ -1,6 +1,6 @@ import { themeStore } from '$lib/stores/theme.svelte'; -export type ThemePattern = 'waves' | 'geometric' | 'dots' | 'none'; +export type ThemePattern = 'snow' | 'none'; export interface Theme { name: string; @@ -13,16 +13,8 @@ export const AVAILABLE_THEMES: Record = { pattern: 'none' }, waves: { - name: 'Waves', - pattern: 'waves' - }, - geometric: { - name: 'Geometric', - pattern: 'geometric' - }, - dots: { - name: 'Dots', - pattern: 'dots' + name: 'Snow', + pattern: 'snow' } }; diff --git a/src/routes/dashboard/+page.server.ts b/src/routes/dashboard/+page.server.ts index cc81900..75b9b83 100644 --- a/src/routes/dashboard/+page.server.ts +++ b/src/routes/dashboard/+page.server.ts @@ -85,7 +85,7 @@ export const actions: Actions = { } await db.update(wishlists) - .set({ isFavorite: !isFavorite }) + .set({ isFavorite: !isFavorite, updatedAt: new Date() }) .where(eq(wishlists.id, wishlistId)); return { success: true }; @@ -171,7 +171,7 @@ export const actions: Actions = { } await db.update(users) - .set({ dashboardTheme: theme }) + .set({ dashboardTheme: theme, updatedAt: new Date() }) .where(eq(users.id, session.user.id)); return { success: true }; @@ -187,7 +187,7 @@ export const actions: Actions = { const color = formData.get('color') as string | null; await db.update(users) - .set({ dashboardColor: color }) + .set({ dashboardColor: color, updatedAt: new Date() }) .where(eq(users.id, session.user.id)); return { success: true }; diff --git a/src/routes/wishlist/[token]/edit/+page.svelte b/src/routes/wishlist/[token]/edit/+page.svelte index 4473b8b..f1bd8af 100644 --- a/src/routes/wishlist/[token]/edit/+page.svelte +++ b/src/routes/wishlist/[token]/edit/+page.svelte @@ -155,7 +155,7 @@ {#if showAddForm}
- +
{/if} @@ -169,6 +169,8 @@ currentPosition={items.findIndex(item => item.id === editingItem.id) + 1} totalItems={items.length} onPositionChange={handlePositionChange} + wishlistColor={currentColor} + wishlistTheme={currentTheme} />
{/if} diff --git a/static/themes/dots/bgbottom.svg b/static/themes/dots/bgbottom.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/dots/bgbottom.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/dots/bgtop.svg b/static/themes/dots/bgtop.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/dots/bgtop.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/dots/item.svg b/static/themes/dots/item.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/dots/item.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/geometric/bgbottom.svg b/static/themes/geometric/bgbottom.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/geometric/bgbottom.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/geometric/bgtop.svg b/static/themes/geometric/bgtop.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/geometric/bgtop.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/geometric/item.svg b/static/themes/geometric/item.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/geometric/item.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/snow/bgbottom.svg b/static/themes/snow/bgbottom.svg new file mode 100644 index 0000000..6fe2abd --- /dev/null +++ b/static/themes/snow/bgbottom.svg @@ -0,0 +1,2782 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/snow/bgtop.svg b/static/themes/snow/bgtop.svg new file mode 100644 index 0000000..450970b --- /dev/null +++ b/static/themes/snow/bgtop.svg @@ -0,0 +1,2783 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/snow/item.svg b/static/themes/snow/item.svg new file mode 100644 index 0000000..41bbeaf --- /dev/null +++ b/static/themes/snow/item.svg @@ -0,0 +1,1695 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/themes/waves/bgbottom.svg b/static/themes/waves/bgbottom.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/waves/bgbottom.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/waves/bgtop.svg b/static/themes/waves/bgtop.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/waves/bgtop.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/themes/waves/item.svg b/static/themes/waves/item.svg deleted file mode 100644 index 455daf8..0000000 --- a/static/themes/waves/item.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file