fix: use authenticated user ID for habit service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<script lang="ts">
|
||||
import type { HabitWithCompletions } from '$lib/context/habits.svelte';
|
||||
import type { User } from 'better-auth';
|
||||
import HabitGrid from './HabitGrid.svelte';
|
||||
import HabitCreationForm from './HabitCreationForm.svelte';
|
||||
import { setHabitService } from '$lib/context/habits.svelte';
|
||||
|
||||
|
||||
// shadcn-svelte components
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
@@ -12,7 +13,7 @@
|
||||
import * as Popover from '$lib/components/ui/popover';
|
||||
import * as Dialog from '$lib/components/ui/dialog';
|
||||
import { Alert, AlertDescription } from '$lib/components/ui/alert';
|
||||
|
||||
|
||||
// Icons
|
||||
import Plus from '@lucide/svelte/icons/plus';
|
||||
import CalendarIcon from '@lucide/svelte/icons/calendar';
|
||||
@@ -21,21 +22,24 @@
|
||||
import AlertTriangle from '@lucide/svelte/icons/alert-triangle';
|
||||
import Eye from '@lucide/svelte/icons/eye';
|
||||
import EyeOff from '@lucide/svelte/icons/eye-off';
|
||||
|
||||
|
||||
import { today, getLocalTimeZone } from '@internationalized/date';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let { data }: { data: { user: User } } = $props();
|
||||
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
|
||||
// Date selection state
|
||||
let selectedDate = $state(today(getLocalTimeZone()));
|
||||
let showCalendar = $state(false);
|
||||
|
||||
|
||||
// Habit visibility toggle
|
||||
let showInactiveHabits = $state(false);
|
||||
|
||||
// Create habit service instance - subscriptions will handle all data loading
|
||||
const habitService = setHabitService('default-user');
|
||||
|
||||
// Create habit service instance with authenticated user
|
||||
// svelte-ignore state_referenced_locally
|
||||
const habitService = setHabitService(data.user!.id);
|
||||
|
||||
// Simple loading state - just show skeleton briefly while subscriptions initialize
|
||||
let loading = $state(true);
|
||||
|
||||
Reference in New Issue
Block a user