|
6 | 6 | import AIInsightsCard from '../ui/AIInsightsCard.svelte';
|
7 | 7 | import EmptyState from '../ui/EmptyState.svelte';
|
8 | 8 | import Skeleton from '../ui/Skeleton.svelte';
|
| 9 | + import { rightPanelView, uiHelpers } from '$lib/stores/ui'; |
9 | 10 | import type { PetPanelData } from '$lib/types/Pet';
|
10 | 11 | import type { JournalEntry } from '$lib/types/JournalEntry';
|
11 | 12 |
|
12 | 13 | let selectedPet: PetPanelData | null = null;
|
13 | 14 | let selectedPetId: string | null = null;
|
14 | 15 | let pets: PetPanelData[] = [];
|
15 |
| - let currentView = 'dashboard'; // dashboard, journal, history |
| 16 | + let currentView: 'dashboard' | 'journal' | 'history' | 'memorial' | 'confirmArchive' = 'dashboard'; |
16 | 17 | let journalInput = '';
|
17 | 18 | let selectedMood = '';
|
18 | 19 | let selectedActivity = '';
|
|
57 | 58 | selectedPet = petId ? pets.find((p) => p.id === petId) || null : null;
|
58 | 59 | });
|
59 | 60 |
|
| 61 | + // Drive view from shared UI store |
| 62 | + rightPanelView.subscribe((v) => (currentView = v)); |
| 63 | +
|
60 | 64 | // Load from storage (will trigger subscriptions above)
|
61 | 65 | petHelpers.load();
|
62 | 66 | selectedPetHelpers.load();
|
|
95 | 99 | journalInput = '';
|
96 | 100 | selectedMood = '';
|
97 | 101 | selectedActivity = '';
|
98 |
| - currentView = 'dashboard'; |
| 102 | + uiHelpers.setView('dashboard'); |
99 | 103 |
|
100 | 104 | // Refresh selected pet data
|
101 | 105 | selectedPet = petHelpers.getPet(selectedPet.id);
|
|
127 | 131 | }}
|
128 | 132 | />
|
129 | 133 | {:else}
|
130 |
| - <div class="pet-viewport h-full flex flex-col"> |
| 134 | + <div class="pet-viewport h-full flex flex-col"> |
131 | 135 | <!-- Header with pet info and navigation -->
|
132 | 136 | <div class="viewport-header p-4 border-b" style="border-color: var(--petalytics-border); background: var(--petalytics-overlay);">
|
133 | 137 | <div class="flex items-center justify-between">
|
|
145 | 149 |
|
146 | 150 | <div class="flex space-x-2">
|
147 | 151 | <button
|
148 |
| - on:click={() => (currentView = 'dashboard')} |
| 152 | + on:click={() => uiHelpers.setView('dashboard')} |
149 | 153 | class="nav-button px-3 py-1 rounded-md text-sm"
|
150 | 154 | class:active={currentView === 'dashboard'}
|
151 | 155 | >
|
152 | 156 | Dashboard
|
153 | 157 | </button>
|
154 | 158 | <button
|
155 |
| - on:click={() => (currentView = 'journal')} |
| 159 | + on:click={() => uiHelpers.setView('journal')} |
156 | 160 | class="nav-button px-3 py-1 rounded-md text-sm"
|
157 | 161 | class:active={currentView === 'journal'}
|
158 | 162 | >
|
159 | 163 | New Entry
|
160 | 164 | </button>
|
161 | 165 | <button
|
162 |
| - on:click={() => (currentView = 'history')} |
| 166 | + on:click={() => uiHelpers.setView('history')} |
163 | 167 | class="nav-button px-3 py-1 rounded-md text-sm"
|
164 | 168 | class:active={currentView === 'history'}
|
165 | 169 | >
|
|
171 | 175 |
|
172 | 176 | <!-- Content Area -->
|
173 | 177 | <div class="viewport-content flex-1 p-4 overflow-y-auto">
|
174 |
| - {#if currentView === 'dashboard'} |
| 178 | + {#if currentView === 'confirmArchive'} |
| 179 | + <!-- Confirm Archive View --> |
| 180 | + <div class="space-y-4 font-mono"> |
| 181 | + <h3 class="text-lg font-semibold" style="color: var(--petalytics-text);">Archive Pet</h3> |
| 182 | + <p>Mark {selectedPet?.name} as passed away?</p> |
| 183 | + <div class="flex justify-end gap-2"> |
| 184 | + <button class="button-secondary" on:click={() => uiHelpers.setView('dashboard')}>Cancel</button> |
| 185 | + <button class="button" on:click={() => { |
| 186 | + if (selectedPet) { |
| 187 | + petHelpers.archive(selectedPet.id); |
| 188 | + if (selectedPetId === selectedPet.id) { |
| 189 | + selectedPetHelpers.clear(); |
| 190 | + } |
| 191 | + } |
| 192 | + uiHelpers.setView('dashboard'); |
| 193 | + }}>Confirm</button> |
| 194 | + </div> |
| 195 | + </div> |
| 196 | + {:else if currentView === 'memorial'} |
| 197 | + <!-- Memorial View (inline, no modal) --> |
| 198 | + <div class="space-y-4 font-mono"> |
| 199 | + <div class="rounded p-3" style="background: color-mix(in oklab, var(--petalytics-overlay) 60%, transparent); border: 1px solid var(--petalytics-border);"> |
| 200 | + <div class="flex items-center justify-between"> |
| 201 | + <div> |
| 202 | + <div class="text-sm" style="color: var(--petalytics-subtle);">{petSubtitle(selectedPet!)}</div> |
| 203 | + <div class="text-base font-semibold" style="color: var(--petalytics-text);"> |
| 204 | + In loving memory of {selectedPet?.name} |
| 205 | + </div> |
| 206 | + </div> |
| 207 | + <div class="text-xs px-2 py-1 rounded" style="background: var(--petalytics-surface); color: var(--petalytics-subtle);"> |
| 208 | + {selectedPet?.journalEntries.length || 0} memories |
| 209 | + </div> |
| 210 | + </div> |
| 211 | + </div> |
| 212 | + {#if (selectedPet?.journalEntries.length || 0) === 0} |
| 213 | + <div class="text-sm" style="color: var(--petalytics-subtle);">No journal entries yet.</div> |
| 214 | + {:else} |
| 215 | + <div class="space-y-3"> |
| 216 | + {#each [...(selectedPet?.journalEntries || [])].slice().reverse() as entry} |
| 217 | + <div class="rounded border p-3" style="background: var(--petalytics-surface); border-color: var(--petalytics-border);"> |
| 218 | + <div class="flex items-center justify-between mb-2"> |
| 219 | + <div class="text-xs" style="color: var(--petalytics-subtle);"> |
| 220 | + {new Date(entry.date as any).toLocaleDateString()} |
| 221 | + </div> |
| 222 | + <div class="text-sm" style="color: var(--petalytics-text);">{entry.mood || '🐾'}</div> |
| 223 | + </div> |
| 224 | + <div class="text-sm" style="color: var(--petalytics-text);">{entry.content}</div> |
| 225 | + </div> |
| 226 | + {/each} |
| 227 | + </div> |
| 228 | + {/if} |
| 229 | + </div> |
| 230 | + {:else if currentView === 'dashboard'} |
175 | 231 | <!-- Dashboard View -->
|
176 | 232 | <div class="dashboard-grid space-y-4">
|
177 | 233 | <!-- Stats Cards -->
|
|
0 commit comments