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/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} - + - + {/if} @@ -169,6 +169,8 @@ currentPosition={items.findIndex(item => item.id === editingItem.id) + 1} totalItems={items.length} onPositionChange={handlePositionChange} + wishlistColor={currentColor} + wishlistTheme={currentTheme} /> {/if}