Initial project scaffold: FastAPI backend + Svelte 5 frontend
Backend (uv): FastAPI app with routers (foods, log, targets, OFF proxy), SQLAlchemy models, Pydantic schemas, migration runner + 0001 initial schema, example pytest suite (7 tests). Frontend (npm): Vite 7 + Svelte 5 runes, lib/ (api, stores, scanner, format) per spec §7, placeholder components, example vitest suite (4 tests). SPEC.md §1: registered uvicorn and Vitest (rule §8.3.3).
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<script>
|
||||
// Dashboard — Daily view: progress bar + log entries grouped by meal_slot (spec §4.6)
|
||||
import { api } from '../lib/api.js'
|
||||
import { formatDate } from '../lib/format.js'
|
||||
|
||||
let { date } = $props()
|
||||
|
||||
let entries = $state(null) // null = loading
|
||||
let error = $state(null)
|
||||
|
||||
$effect(() => {
|
||||
entries = null
|
||||
error = null
|
||||
api.getLog(date)
|
||||
.then((data) => (entries = data))
|
||||
.catch((e) => (error = e.message))
|
||||
})
|
||||
</script>
|
||||
|
||||
<h2>{formatDate(date)}</h2>
|
||||
|
||||
{#if error}
|
||||
<p role="alert">Failed to load log: {error}</p>
|
||||
{:else if entries === null}
|
||||
<p>Loading…</p>
|
||||
{:else if entries.length === 0}
|
||||
<p>Nothing logged yet today.</p>
|
||||
{:else}
|
||||
<ul>
|
||||
{#each entries as entry (entry.id)}
|
||||
<li>Food #{entry.food_id} × {entry.quantity}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user