diff --git a/README.md b/README.md index 4a02fdc..c121700 100644 --- a/README.md +++ b/README.md @@ -1,164 +1,82 @@ # Hezarfen Frontend -A modern, high-performance **SolidJS + TypeScript** web application for the Hezarfen Campus & Learning Management System. Built with Vite, TanStack Router, Tailwind CSS, and a rich, accessible dark mode design system. +Hezarfen's school dashboard and learning portal, built with SolidJS, TypeScript, TanStack Router, Tailwind CSS, and shadcn-solid components. The dashboard is a read-only status board; other pages provide role-scoped learning and school-management workflows. The interface supports Turkish and English. ---- +## Local development -## 🚀 Key Highlights & UI/UX Experience - -- **Çelebi AI Assistant**: Top-bar instant AI study and campus guide accessible from every page (`IconSparkles`). -- **Smart Notebook & Import Assistant**: Upload PDF, TXT, or MD files and automatically extract clean Markdown notes (OCR warning, split line joining, header stripping). -- **Freehand Drawing Canvas (`.hzdraw`)**: Unbounded pannable/zoomable drawing canvas with stroke smoothing, dark mode grid paper, and PNG scene JSON metadata embedding. -- **Question Bank & Verified Solutions**: Question repository (`/questions`) supporting written/multiple-choice answers, teacher verification badges, and subject taxonomy. -- **Live Exam Room & Real-Time Monitor**: Server-clock-synchronized countdown timer (`GET /time`), WebSocket + REST autosave, teacher SSE live monitoring, and answer sheet grading. -- **Unified Sky-Blue Container (`data-shell`)**: Cohesive, elegant dark mode surfaces (`border-sky-500/15 bg-sky-500/[0.025]`) across Courses, Exams, Events, Calendar, and Guide pages. -- **Redesigned Tab System**: Stationary tab dimensions (zero layout shifts), glowing dark mode halo rings (`dark:shadow-[0_0_16px_rgba(255,255,255,0.08)]`), dynamic alternating accent lines, and perfectly aligned icon + text triggers. -- **Çelebi Primary Button Styling**: Hairline borders, translucent fill (`bg-primary/15`), subtle rings, and clean hover micro-interactions. - ---- - -## 🛠️ Stack & Architecture - -- **Core**: SolidJS 1.8+ & TypeScript 5+ (scaffolded with Vite 6) -- **Routing**: TanStack Router (`@tanstack/solid-router`, code-based route tree, route-level code splitting via `lazy()`) -- **UI Primitives**: Custom **shadcn-solid** wrappers under `src/components/ui/` styled with Tailwind CSS (using `clsx` + `tailwind-merge` + `cva`) -- **API Layer**: Domain-driven `src/api//` functions using `fetch` inside SolidJS `createResource` boundaries. Pages never call `fetch` directly. -- **Testing**: Vitest with 100% endpoint test coverage (`src/api/__tests__/`) and custom `mockFetch` utilities. -- **Runtime Targets**: Under ~70KB gzipped bundle size for lightning-fast loads. - ---- - -## 📦 Prerequisites & Setup - -- **Node.js** 20+ or **bun** (recommended) -- A Hezarfen backend to talk to — the deployed frontend proxies `/api/*` to it, so `https://hezarfen.dizey.sh` is enough in a browser; for a direct backend (dev) door use `https://hezarfen-backend.dizey.sh`, or `BACKEND_ORIGIN=http://127.0.0.1:7656` against a backend on the same machine - -### Installation & Development +Install [Bun](https://bun.sh/) and run: ```bash -# Install dependencies bun install - -# Start Vite development server bun run dev - -# Run unit tests -bun run test - -# Typecheck and build production bundle -bun run build ``` -Open [http://localhost:5173](http://localhost:5173) in your browser. - -> **Proxy Note**: Vite proxies `/api/*` and WebSocket connections to `BACKEND_ORIGIN`, preserving HttpOnly session cookies across same-origin calls. Local development defaults to `https://hezarfen-backend.dizey.sh`, so `bun run dev` works without a backend process on the laptop; use `BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` to target one locally. The production Bun server gets its co-located loopback default from the image and can be overridden through `hezarfen_frontend.env` (see "Run in a container" below). - -> **Dev auto sign-in**: for local testing, put `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD` (optionally `VITE_DEV_AUTOLOGIN_SCHOOL`, a school uuid) in `.env.local`, which git ignores. `bun run dev` then signs in on the first `401`; logging out turns it off for that tab. It lives in `src/lib/dev-auto-login.ts` behind `import.meta.env.DEV`, so `vite build` drops it and the credentials never reach `dist/`. - -> **Demo sign-in**: set `VITE_DEMO_LOGIN_USERNAME` and `VITE_DEMO_LOGIN_PASSWORD` at build time and the login page opens filled with them, plus a one-click "Demo hesabıyla gir" button (`src/lib/demo-login.ts`). Unlike the dev auto sign-in these values are bundled into `dist/`, so set them only for a demo school's build. - ---- - -## 🐳 Run in a container (podman) +Open . Vite proxies `/api/*` and WebSocket traffic to `https://hezarfen-backend.dizey.sh` by default. To use a local backend: ```bash -podman compose up -d --build # build + start, http://127.0.0.1:5173 -podman compose logs -f frontend -podman compose down # stop +BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev ``` -The `Containerfile` is a two-stage build: `bun install --frozen-lockfile` plus `bun run build` produce `dist/`, and `oven/bun:1-slim` serves it with `server.ts` — which also reverse-proxies `/api/*` (plain HTTP and the exam-room WebSocket) to `BACKEND_ORIGIN`. No nginx, no node_modules at runtime, no state: one container and no volumes. It runs with `network_mode: host`, so it shares the host's loopback and reaches a backend published on `127.0.0.1:7656` exactly as a host process would (a bridge network would resolve `127.0.0.1` to the container itself). Host networking means no port mapping: the app binds the host's interface directly, so set `HOST=127.0.0.1` and let the reverse proxy on the same loopback be the only door. - -**Knobs live in two places and are never mixed.** The defaults are written once, in the image's `ENV` block (`Containerfile`) — `BACKEND_ORIGIN`, `HOST`, `PORT` — and nothing else in the repo repeats them: `server.ts` reads all three and refuses to boot without them, the compose healthcheck asks the container for `PORT`, and the deploy reads the port back out of the running container. A laptop needs no extra files. On a server the operator copies `deploy/hezarfen_frontend.env.example` to `$HOME/hezarfen_frontend/hezarfen_frontend.env`, `chmod 0600` it and edits it — nothing automated creates, overwrites or uploads that file. The service declares it as `env_file:`, so **every key it carries overrides the image default with no extra flag**; nothing is interpolated from it, and the only compose-level variable is `HEZARFEN_TAG`, which the deploy owns in `stack.env`. +The proxy keeps browser requests and session cookies on the frontend origin. A backend account is needed for authenticated pages. For local testing, `.env.local` can hold `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD`, plus optional `VITE_DEV_AUTOLOGIN_SCHOOL`. Dev auto sign-in runs only in Vite development mode. `VITE_DEMO_LOGIN_USERNAME` and `VITE_DEMO_LOGIN_PASSWORD` instead prefill the demo login at build time; those values **are included in the built bundle**, so use only demo credentials. -Environment values are read when the container **starts**: after editing the file, recreate (`podman compose up -d`, or `systemctl --user restart hezarfen_frontend_compose`). `podman restart` keeps the old environment. - -`deploy/hezarfen_frontend_compose.service` is a systemd **user** unit that brings the stack up at boot: +### Checks ```bash -podman compose --env-file ~/hezarfen_frontend/hezarfen_frontend.env \ - --env-file ~/hezarfen_frontend/stack.env up -d --no-build +bun run check # TypeScript +bun run test # Vitest unit tests +bun run build # TypeScript + production bundle +bun run test:e2e # Playwright; starts Vite and requires a live backend +bun run test:contract # Live API contract tests; requires CONTRACT_BASE_URL ``` -`--env-file` feeds both compose's interpolation and — through `env_file:` — the container; the second file is compose-owned and carries `HEZARFEN_TAG` (a later `--env-file` wins for duplicate keys). Because the unit passes `--no-build`, the image must already exist on the host (`podman compose build`, or `podman load` of a tarball shipped from elsewhere). After an env change: `systemctl --user restart hezarfen_frontend_compose`. - -Deploying is GitHub Actions' job, not the server's. `.github/workflows/main.yml` typechecks (`tsc --noEmit`, its own runner, parallel with the rest), runs the vitest suite, builds the SPA, builds the repo `Containerfile`'s image (the same one a laptop builds — its `ENV` block is the single source of the deployment defaults), and ships the image tarball together with `compose.yaml`, the `hezarfen_frontend_compose.service` unit and a `tag` file as the run's artifact. The deploy job loads that image on the server and starts the stack with `podman compose up -d --no-build`; the tag travels in a deploy-owned `stack.env`, so a release never rewrites the operator's knobs file. A health gate protects the swap: the new container must serve the SPA shell and must be *this* build's image, otherwise the deploy rolls back to `previous_tag` (and on a first deploy stops the stack instead). The operator's only manual step is writing the env file once (above). - -It needs three repository secrets — `SSH_PRIVATE_KEY`, `SSH_HOST`, `SSH_USER`, the same three names the backend deploy uses — plus `loginctl enable-linger` for the deploy user. `workflow_dispatch` (Actions → Run workflow, or `gh workflow run main.yml --ref main`) redeploys the newest green build without re-running the suite, which is the door to use when only the server side changed. +The Playwright and live contract suites are local, on-demand checks. The push workflow runs typechecking, unit tests, and the production build. ---- +## Application map -## 👥 Role Scope Matrix +| Area | Routes | Purpose | +| --- | --- | --- | +| Home and account | `/`, `/profile/me`, `/guide` | Status dashboard, profile, and in-app guide. | +| Learning | `/courses`, `/courses/$id`, `/instances/$id`, `/homework`, `/exams`, `/notes`, `/whiteboards` | Catalog courses, class-specific course instances, assignments, exams, notes, and boards. | +| Questions and AI | `/questions`, `/question-bank`, `/ai/studio`, `/ai/study`, `/ai/insights` | Community questions, staff question bank, AI note studio, study assistant, and insights. | +| School life | `/calendar`, `/events`, `/appointments`, `/meals`, `/messages` | Calendar, events, appointments, meal menus, and messages. | +| Personal progress | `/marks`, `/pomodoro`, `/payments` | Student marks and focus sessions; parent payment statements. | +| School management | `/management/classes`, `/management/students`, `/management/teachers`, `/management/student-attendance`, `/management/student-marks`, `/management/pomodoros` | Classes, rosters, and student progress. | +| Administration | `/management/academic-years`, `/management/terms`, `/management/holidays`, `/management/staff-work`, `/management/settings`, `/management/payments`, `/admin/users` | Academic calendar, staff work, settings, payments, and users. | -`student < teacher < manager < admin` — Higher roles inherit lower capabilities. Public registration creates a `student`. +There are separate `parent`, `student`, `teacher`, `manager`, and `admin` experiences, plus a platform builder session under `/builder`. Pages and data are scoped by role and enabled school modules. See [the sitemap](docs/frontend/sitemap.md) for the complete route and access map. -| Role | Access & Capabilities | -|---|---| -| **Student (`student`)** | Personal notebook, PDF import, drawing canvas, enrolled courses, live exam room, question bank, pomodoro focus log, personal report card & attendance history. | -| **Teacher (`teacher`)** | Course/study creation, student enrollment, lesson session roll call, exam question authoring, live exam monitoring, answer sheet grading, and solution verification. | -| **Manager (`manager`)** | Academic settings, term definitions, attendance reports, global course/exam oversight, and staff work logs. | -| **Admin (`admin`)** | Global management scope across all users, role assignments, system policies, settings, and terms. | +A course at `/courses/$id` is a catalog record. An instance at `/instances/$id` attaches that course to a class and owns its enrollment, sessions, homework, exams, and roll call. Keep that distinction when extending API calls or UI. ---- +## Code layout -## 🗺️ Page Routes & System Navigation +| Path | Contents | +| --- | --- | +| `src/api/` | Domain-based API functions and endpoint tests. Pages use this layer rather than calling `fetch` directly. | +| `src/components/` | Shared UI, layout, and domain components, including side panels. | +| `src/pages/` | Page components, loaded lazily by the router. | +| `src/routes/router.tsx` | Route definitions and redirects. | +| `src/i18n/` | Turkish and English messages. | +| `src/stores/` | Shared SolidJS contexts. | +| `docs/` | Product, UI, auth, frontend, and backend notes. | -| Path | Access Scope | Description | -|---|---|---| -| `/login`, `/register` | Guests | Authentication with same-origin cookie management. | -| `/` | Authenticated | Read-only observation dashboard with role-scoped portal cards, attention items, and upcoming events. | -| `/guide` | Authenticated | Redesigned product guide featuring role scope matrix, 6 core feature cards, and pro tips. | -| `/profile` | Authenticated | User profile management (display name, email, phone, birth date). | -| `/notes` | Student+ | Personal notebook with paper-style cards, Note Import Assistant (PDF/TXT), reader drawer, file attachments, and `.hzdraw` live canvas. | -| `/ai` | Authenticated | AI hub: the note studio (course-note AI outputs plus narrated podcast audio with live job progress, cancellation and playback), the ZEKA analysis board, and the Çelebi entry point. `/sound-studio` redirects to its note-studio tab. | -| `/questions`, `/questions/:id` | Student+ | Community Question Bank with solution authoring and teacher verification. | -| `/courses`, `/courses/:id` | Student+ | Course catalog, student enrollment, curriculum subjects, homework assignments, and lesson session roll call. | -| `/exams`, `/exams/:id` | Student+ | Exam list and details, subject-tagged questions, draft/publish controls, and grading statistics. | -| `/exam-room/:id` | Student+ | WebSocket real-time exam room with autosave, server timer (`/time`), and automatic turn-in on expiry. | -| `/exams/:id/live` | Teacher+ | Live exam monitor over SSE/polling with answer sheets, auto-score suggestions, and inline grading. | -| `/events`, `/events/:id` | Student+ | Campus event list and detail views with search filters and attendance roster. | -| `/calendar` | Student+ | Full calendar view with sky-blue container, event & exam markers, and day detail inspection. | -| `/marks` | Student+ | Report card with weighted exam average calculations and course breakdown. | -| `/messages` | Student+ | Messaging portal with folder navigation, unread badges, and micro-animations. | -| `/pomodoro` | Student | Student focus log with server-stamped session tracking. | -| `/admin/users` | Admin | User account administration and role assignment. | +SolidJS components execute once. Use signals and memos for reactive state; do not assume React-style rerenders. Repository conventions and area-specific skills are listed in [AGENTS.md](AGENTS.md). ---- +## Container and deployment -## 🎨 UI/UX Design System Tokens +Use Podman: -- **Data Shell Surface**: Subtle sky-blue background container (`border-sky-500/15 bg-sky-500/[0.025]`) used across data-heavy views for visual cohesion. -- **Domain Accent Colors**: Centralized single source of truth (`src/lib/domain-colors.ts`) mapping domain colors exclusively to hairline borders and ring highlights (amber for Notes, violet for Messages, rose for Exams, emerald for Events, sky for Courses, cyan for Questions, teal for Marks). -- **Tab Indicators**: Recessed list tracks, stationary pill triggers, halo ring glow outlines, and alternating accent lines. -- **Button Styling**: Çelebi-themed translucent fill (`bg-primary/15`), hairline borders, and subtle rings (`ring-1 ring-primary/25`). -- **Invisible Scrollbars**: Functional scrolling without visible scrollbar clutter across all browsers (`scrollbar-width: none`). - ---- - -## 📁 Project Directory Structure - -``` -src/ -├── api/ # Endpoint functions organized by domain (notes, exams, courses, etc.) -│ └── __tests__/ # Vitest endpoint tests (100% API coverage) -├── components/ # Domain & UI components -│ ├── exams/ # Exam cards, forms, live monitor, WS room -│ ├── layout/ # AppShell, PageHeader, Sidebar, RouteGuard -│ ├── notes/ # Note cards, reader panel, file attachment manager -│ ├── ui/ # Design system (Button, Badge, DataTable, SidePanel, Tabs, etc.) -│ └── users/ # User search, profile form, admin user table -├── i18n/ # Localization dictionaries (TR / EN) and MessageKey types -├── lib/ # Shared utilities (domain-colors, note-importer, stroke-smoothing, etc.) -├── pages/ # Lazy-loaded page components for TanStack Router -├── routes/ # TanStack Router route tree definition -└── stores/ # Cross-cutting contexts (AuthContext, PreferencesContext) +```bash +podman compose up -d --build +podman compose logs -f frontend +podman compose down ``` ---- +The `Containerfile` builds the app with Bun, then `server.ts` serves `dist/` and proxies `/api/*`, including the exam-room WebSocket. `compose.yaml` uses host networking. The image defines defaults for `BACKEND_ORIGIN`, `HOST`, and `PORT`; production overrides them with an operator-owned `~/hezarfen_frontend/hezarfen_frontend.env` created from `deploy/hezarfen_frontend.env.example`. Set `HOST=127.0.0.1` when a reverse proxy on the same server is the public entry point. Keep the env file private with mode `0600`. + +The systemd user unit at `deploy/hezarfen_frontend_compose.service` starts the stack. After changing its env file, recreate the container with `systemctl --user restart hezarfen_frontend_compose` so it reads the new values. A plain `podman restart` retains the old environment. -## 📜 Commit & Quality Workflow +On pushes to `main`, `.github/workflows/main.yml` checks, tests, builds, and deploys an image over SSH, then verifies the new container. It requires repository secrets `SSH_PRIVATE_KEY`, `SSH_HOST`, and `SSH_USER`, plus Podman and a compose provider on the server. The operator creates the production env file once; the workflow does not overwrite it. `workflow_dispatch` redeploys the latest successful build artifact. -All contributions adhere to the strict repository rulebook (`AGENTS.md`): +## Contributing -1. **Pre-commit Check**: `bun run test` (35 test files, 238 tests) and `bun run build` (`tsc --noEmit && vite build`) must pass green before committing. -2. **Conventional Commits**: Format `type: emoji short summary` with technical bullet details written in English. +Keep changes reviewable and use Bun for JavaScript and TypeScript tooling. Before a commit, run `bun run build`; run relevant tests for behavior changes. Commit messages use the repository's `type: emoji short summary` format with English details. See [AGENTS.md](AGENTS.md) and the `commit-workflow` skill for the full rules. diff --git a/docs/backend/live-list-filter-drift-2026-09-25.md b/docs/backend/live-list-filter-drift-2026-09-25.md new file mode 100644 index 0000000..9e3299f --- /dev/null +++ b/docs/backend/live-list-filter-drift-2026-09-25.md @@ -0,0 +1,16 @@ +# Live list filter drift — 2026-09-25 + +This note records behavior observed against the authenticated live backend on +2026-09-25. It describes that deployment, not a permanent API guarantee. + +| List | Request / observation | Contract impact | +|---|---|---| +| `GET /courses` | `?limit=5&offset=0&q=zzzx-no-such-course` returned HTTP 200, `total=10`, and five ordinary courses. | `q` was ignored in this check; frontend search and pagination cannot be trusted to reflect the query. | +| `GET /courses` | A `taught=false` request still returned taught courses. | The taught filter was ignored in this check. | +| `GET /homework` | A `due_before` request used by the Past tab still returned future deadlines. | The Past tab did not filter as requested. | + +The live OpenAPI document currently lists `limit` and `offset` for these list +routes, but does not list the filters above. Frontend API helpers send them; +their presence in frontend code does not establish backend support. Verify the +deployed response and OpenAPI document again after a backend update. Do not +infer the status of other filters from these observations. diff --git a/docs/frontend/frontend-next-steps.md b/docs/frontend/frontend-next-steps.md index 87cb801..89004ae 100644 --- a/docs/frontend/frontend-next-steps.md +++ b/docs/frontend/frontend-next-steps.md @@ -66,8 +66,13 @@ Active backend/class/meals alignment is tracked in: - Main lists use real server paging (`limit`/`offset` + `total`) when no client-only filter is active: - exams and events (hybrid: full fetch only while client-only filters need it) - notes, terms, work log, admin users (server page; admin metrics still load full list once) -- Courses temporarily load the visible list once and filter/paginate locally because - backend course filters remain a documented prerequisite. +- Courses now request server pages with `kind`, `q`, and `taught`; the current + deployment does not honor at least `q` and `taught=false`, so the list can + show unfiltered rows or misleading page counts until the backend is fixed. +- Homework requests `due_after`, `due_before`, and `class_course` for its tabs + and section picker. The current deployment ignores at least `due_before`, + so the Past tab can include future deadlines. See + `docs/backend/live-list-filter-drift-2026-09-25.md` for observed requests. - Nested/deferred lists unwrap full `.items` (sessions, enrollments, attendance, exam results/questions). - `/exams/:id/live`: client-paginated roster over snapshot/SSE (not the list envelope). - Progress Report card and Attendance tabs: not paged; aggregate report shapes. @@ -111,6 +116,14 @@ Active backend/class/meals alignment is tracked in: linked and included in deadlines for every role. - Terms page: SidePanel create/edit + dense table row actions; header create buttons use shared min-width/radius. - Settings: dirty-state save gate and auto-clearing success message. +- Settings: comma-separated branch and excuse-kind fields round-trip as lists; + a fixed save bar appears while there are unsaved changes, with a leave guard. +- Staff work: the staff card grid has a separated pagination row and record + range; opening a card keeps the selected person's work log in a side panel. +- Meals: week and slot controls lead into a seven-day picker. Selecting a day + shows its menus or an explicit empty-day state; publish remains a side panel. +- Homework: the section picker tolerates asynchronous option loading without + crashing while the list or panel mounts. - Nested breadcrumbs on exam room and live monitor. ### UX batch (2026-07, observation UI + feedback) diff --git a/src/components/appointments/publish-slots-form.tsx b/src/components/appointments/publish-slots-form.tsx index 01c68d0..b427ece 100644 --- a/src/components/appointments/publish-slots-form.tsx +++ b/src/components/appointments/publish-slots-form.tsx @@ -93,7 +93,7 @@ export function PublishSlotsForm(props: { placeholder="09:00" pattern="[0-2][0-9]:[0-5][0-9]" value={startsTime()} - aria-label={t("appointments.starts")} + aria-label={t("appointments.startTime")} onInput={(e) => setStartsTime(e.currentTarget.value)} /> @@ -109,7 +109,7 @@ export function PublishSlotsForm(props: { placeholder="10:00" pattern="[0-2][0-9]:[0-5][0-9]" value={endsTime()} - aria-label={t("appointments.ends")} + aria-label={t("appointments.endTime")} onInput={(e) => setEndsTime(e.currentTarget.value)} /> diff --git a/src/components/appointments/reschedule-form.tsx b/src/components/appointments/reschedule-form.tsx index afeb748..6238b96 100644 --- a/src/components/appointments/reschedule-form.tsx +++ b/src/components/appointments/reschedule-form.tsx @@ -61,7 +61,7 @@ export function RescheduleForm(props: { placeholder="09:00" pattern="[0-2][0-9]:[0-5][0-9]" value={startsTime()} - aria-label={t("appointments.starts")} + aria-label={t("appointments.startTime")} onInput={(e) => setStartsTime(e.currentTarget.value)} /> @@ -77,7 +77,7 @@ export function RescheduleForm(props: { placeholder="10:00" pattern="[0-2][0-9]:[0-5][0-9]" value={endsTime()} - aria-label={t("appointments.ends")} + aria-label={t("appointments.endTime")} onInput={(e) => setEndsTime(e.currentTarget.value)} /> diff --git a/src/components/meals/meal-day-group.tsx b/src/components/meals/meal-day-group.tsx index 6e6aad4..d79d8b4 100644 --- a/src/components/meals/meal-day-group.tsx +++ b/src/components/meals/meal-day-group.tsx @@ -1,6 +1,7 @@ import { For, Show } from "solid-js"; import type { MealMenu } from "@/api/client"; import { Badge } from "@/components/ui/badge"; +import { EmptyInline } from "@/components/ui/empty-inline"; import { MealMenuRow } from "@/components/meals/meal-menu-row"; import { formatMealDay } from "@/lib/meals"; import { useT } from "@/stores/preferences-context"; @@ -19,11 +20,16 @@ export function MealDayGroup(props: { {formatMealDay(props.date, props.locale)} {t("meals.today")} -
- - {(menu) => } - -
+ 0} + fallback={} + > +
+ + {(menu) => } + +
+
); } diff --git a/src/components/meals/meal-day-picker.tsx b/src/components/meals/meal-day-picker.tsx new file mode 100644 index 0000000..bf361de --- /dev/null +++ b/src/components/meals/meal-day-picker.tsx @@ -0,0 +1,46 @@ +import { For } from "solid-js"; +import type { MealMenu } from "@/api/client"; +import { cn } from "@/lib/cn"; +import { addDaysIso, formatMealDay } from "@/lib/meals"; +import { useT } from "@/stores/preferences-context"; + +/** All seven days stay visible, including days with no published menu. */ +export function MealDayPicker(props: { + weekStart: string; + selectedDate: string; + locale: string; + days: { date: string; menus: MealMenu[] }[]; + onSelect: (date: string) => void; +}) { + const t = useT(); + const dates = () => Array.from({ length: 7 }, (_, index) => addDaysIso(props.weekStart, index)); + const count = (date: string) => props.days.find((day) => day.date === date)?.menus.length ?? 0; + const weekday = (date: string) => new Intl.DateTimeFormat(props.locale, { weekday: "short", timeZone: "UTC" }).format(new Date(`${date}T00:00:00Z`)); + + return ( + + ); +} diff --git a/src/components/meals/meal-menu-row.tsx b/src/components/meals/meal-menu-row.tsx index 76c834c..e62b723 100644 --- a/src/components/meals/meal-menu-row.tsx +++ b/src/components/meals/meal-menu-row.tsx @@ -20,22 +20,23 @@ export function MealMenuRow(props: { menu: MealMenu; locale: string }) { - {mealSlotLabel(props.menu.slot, t)} - + {mealSlotLabel(props.menu.slot, t)} + + {dishes() || t("meals.noDishes")} 0}> - dietaryTagLabel(tag, t)).join(", ")}`}> - + + + {t("meals.conflict")}: {conflicts().map((tag) => dietaryTagLabel(tag, t)).join(", ")} - {dishes() || t("meals.noDishes")} -