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