Compare commits
No commits in common. "main" and "slots-no-overlap" have entirely different histories.
main
...
slots-no-o
57 changed files with 379 additions and 2181 deletions
17
AGENTS.md
17
AGENTS.md
|
|
@ -3,7 +3,7 @@
|
||||||
## Stack
|
## Stack
|
||||||
|
|
||||||
- **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc.
|
- **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc.
|
||||||
- **PocketBase** — server pinned to **0.40.6** (`docker-compose.yml`, image `elestio/pocketbase`, digest-pinned; runs as non-root uid 100 on port 8090), REST API via the `pocketbase` SDK (v0.28). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations).
|
- **PocketBase** — server pinned to **0.23.12** (`docker-compose.yml`), REST API via the `pocketbase` SDK (v0.26). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations).
|
||||||
- **Tailwind CSS v4** + **DaisyUI 5** — utility-first CSS with DaisyUI components for admin; custom theme for the public site.
|
- **Tailwind CSS v4** + **DaisyUI 5** — utility-first CSS with DaisyUI components for admin; custom theme for the public site.
|
||||||
- **Docker Compose** — four services: `app-admin`, `app-public`, `pocketbase`, and `caddy` (reverse proxy).
|
- **Docker Compose** — four services: `app-admin`, `app-public`, `pocketbase`, and `caddy` (reverse proxy).
|
||||||
|
|
||||||
|
|
@ -25,7 +25,6 @@ app-admin/ # SvelteKit admin app (serves admin.<domain>)
|
||||||
│ │ └── server/ # Re-exports from $shared/server + admin helpers (actions.ts, pages.ts, slots.ts)
|
│ │ └── server/ # Re-exports from $shared/server + admin helpers (actions.ts, pages.ts, slots.ts)
|
||||||
│ ├── routes/
|
│ ├── routes/
|
||||||
│ │ ├── +layout.svelte # Root layout (admin shell: grouped sidebar; bare on /login and /preview)
|
│ │ ├── +layout.svelte # Root layout (admin shell: grouped sidebar; bare on /login and /preview)
|
||||||
│ │ ├── +page.svelte # Dashboard (income + chart, hours, utilisation, customers, codes owed, what sells, needs attention); figures from $lib/server/dashboard.ts. Login lands here
|
|
||||||
│ │ ├── login/ # Admin login
|
│ │ ├── login/ # Admin login
|
||||||
│ │ ├── pages/ # Page CRUD + block editor
|
│ │ ├── pages/ # Page CRUD + block editor
|
||||||
│ │ ├── calendar/ # Event CRUD (menu label: Events)
|
│ │ ├── calendar/ # Event CRUD (menu label: Events)
|
||||||
|
|
@ -35,7 +34,7 @@ app-admin/ # SvelteKit admin app (serves admin.<domain>)
|
||||||
│ │ ├── orders/ # Order list + booking-email status/resend
|
│ │ ├── orders/ # Order list + booking-email status/resend
|
||||||
│ │ ├── customers/ # Customer personal data (GDPR): search, export, correct, erase, retention settings
|
│ │ ├── customers/ # Customer personal data (GDPR): search, export, correct, erase, retention settings
|
||||||
│ │ ├── emails/ # Block-based booking email editor (live preview, test send)
|
│ │ ├── emails/ # Block-based booking email editor (live preview, test send)
|
||||||
│ │ ├── globals/ # Header/footer/colors/style editor (menu label: Site design)
|
│ │ ├── globals/ # Header/footer/colors editor (menu label: Site design)
|
||||||
│ │ ├── backup/ # Export/import UI (calls api/export, api/import)
|
│ │ ├── backup/ # Export/import UI (calls api/export, api/import)
|
||||||
│ │ ├── preview/ # Draft preview via sessionStorage (same-origin)
|
│ │ ├── preview/ # Draft preview via sessionStorage (same-origin)
|
||||||
│ │ └── api/ # upload, export, import, slots (Shop block times in /preview) endpoints
|
│ │ └── api/ # upload, export, import, slots (Shop block times in /preview) endpoints
|
||||||
|
|
@ -82,7 +81,7 @@ Caddyfile # Subdomain-based routing
|
||||||
Caddy routes by `Host` header — no path stripping:
|
Caddy routes by `Host` header — no path stripping:
|
||||||
|
|
||||||
- `admin.{$DOMAIN}:8080` → `app-admin:3001` (admin app)
|
- `admin.{$DOMAIN}:8080` → `app-admin:3001` (admin app)
|
||||||
- `db.{$DOMAIN}:8080` → `pocketbase:8090` (redirects `/` to `/_/`)
|
- `db.{$DOMAIN}:8080` → `pocketbase:80` (redirects `/` to `/_/`)
|
||||||
- `www.{$DOMAIN}:8080`, `*.{$DOMAIN}:8080` → `app-public:3000` (public app)
|
- `www.{$DOMAIN}:8080`, `*.{$DOMAIN}:8080` → `app-public:3000` (public app)
|
||||||
|
|
||||||
For local dev, `DOMAIN` defaults to `localhost`, so Caddy serves `admin.localhost:8080`, `db.localhost:8080`, `www.localhost:8080`. Caddy's `.localhost` handling works without DNS or hosts-file changes.
|
For local dev, `DOMAIN` defaults to `localhost`, so Caddy serves `admin.localhost:8080`, `db.localhost:8080`, `www.localhost:8080`. Caddy's `.localhost` handling works without DNS or hosts-file changes.
|
||||||
|
|
@ -134,7 +133,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
||||||
- Collections: `pages` (slug, title, blocks[], published), `globals` (key, data), `media` (file, alt), `email_templates` (key, subject, blocks[], recipients, enabled); commerce: `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`, `passes` (bundle/voucher codes)
|
- Collections: `pages` (slug, title, blocks[], published), `globals` (key, data), `media` (file, alt), `email_templates` (key, subject, blocks[], recipients, enabled); commerce: `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`, `passes` (bundle/voucher codes)
|
||||||
- Server load functions use `locals.pb.collection('pages').getFirstListItem()`
|
- Server load functions use `locals.pb.collection('pages').getFirstListItem()`
|
||||||
- **Always build filters with `pb.filter('slug = {:slug}', { slug })`** — never interpolate values into filter strings (quotes break them).
|
- **Always build filters with `pb.filter('slug = {:slug}', { slug })`** — never interpolate values into filter strings (quotes break them).
|
||||||
- **Schema changes**: add a migration to `pocketbase/pb_migrations/` (runs once, on the next PocketBase start) **and** mirror it in `pb_schema.json` (fresh installs import that after the migrations have already run). Field settings go at the field's top level (`"maxSize": 2000000`), never under `options`: PocketBase has ignored `options` since 0.23. Migrations must skip missing collections and must not throw for data problems — a failing migration stops PocketBase from starting.
|
- **Schema changes**: add a migration to `pocketbase/pb_migrations/` (runs once, on the next PocketBase start) **and** mirror it in `pb_schema.json` (fresh installs import that after the migrations have already run). Migrations must skip missing collections and must not throw for data problems — a failing migration stops PocketBase from starting.
|
||||||
- **API rules**: CMS collections require `@request.auth.id != ''`, so `users` must never allow public sign-up (its createRule is superuser-only). Commerce writes (orders, order_lines, baskets, basket_lines) are superuser-only; they happen in the PocketBase shop hooks (`pocketbase/pb_hooks/shop/lib.js`), which bypass rules.
|
- **API rules**: CMS collections require `@request.auth.id != ''`, so `users` must never allow public sign-up (its createRule is superuser-only). Commerce writes (orders, order_lines, baskets, basket_lines) are superuser-only; they happen in the PocketBase shop hooks (`pocketbase/pb_hooks/shop/lib.js`), which bypass rules.
|
||||||
- **Slot availability** (window start times, group-session places, blocking by overlapping bookings incl. get-ready time) is computed only by `availability()`/`windowStartTimes()`/`checkBooking()` in the shop hooks — the public listing, basket holds and the admin `/slots` page all go through it (`GET /api/shop/slots?item=&minutes=&from=&to=`, `?detail=1` for the admin). Slots are `window`s (services bookable at any of their lengths) or group `session`s; bookings carry their own `start`/`minutes` on basket/order lines. Never store booking state on a slot or re-implement the rule elsewhere; see the README's *Slot availability*.
|
- **Slot availability** (window start times, group-session places, blocking by overlapping bookings incl. get-ready time) is computed only by `availability()`/`windowStartTimes()`/`checkBooking()` in the shop hooks — the public listing, basket holds and the admin `/slots` page all go through it (`GET /api/shop/slots?item=&minutes=&from=&to=`, `?detail=1` for the admin). Slots are `window`s (services bookable at any of their lengths) or group `session`s; bookings carry their own `start`/`minutes` on basket/order lines. Never store booking state on a slot or re-implement the rule elsewhere; see the README's *Slot availability*.
|
||||||
- **Customer personal data (GDPR)** lives in `orders.customerDetails`/`email`, `passes.email`/`recipientName`/`message` and (during checkout) `baskets` / `basket_lines.giftTo`/`giftMessage`. Admin access, correction, erasure (= anonymise the order, never delete it — the accounts need it) and the retention cron are in `pocketbase/pb_hooks/privacy/`; the admin `/customers` page only calls `/api/privacy/*`. A new place that stores customer details (e.g. a Google Calendar sync) must be covered by export, erase and retention too, and listed in the privacy draft (`app-admin/src/lib/admin/privacyTemplate.ts`). Don't load third-party resources on public pages (fonts are bundled; Stripe.js loads only at Pay) — each one sends visitors' IPs elsewhere and may need consent. See the README's *Personal data (GDPR)*.
|
- **Customer personal data (GDPR)** lives in `orders.customerDetails`/`email`, `passes.email`/`recipientName`/`message` and (during checkout) `baskets` / `basket_lines.giftTo`/`giftMessage`. Admin access, correction, erasure (= anonymise the order, never delete it — the accounts need it) and the retention cron are in `pocketbase/pb_hooks/privacy/`; the admin `/customers` page only calls `/api/privacy/*`. A new place that stores customer details (e.g. a Google Calendar sync) must be covered by export, erase and retention too, and listed in the privacy draft (`app-admin/src/lib/admin/privacyTemplate.ts`). Don't load third-party resources on public pages (fonts are bundled; Stripe.js loads only at Pay) — each one sends visitors' IPs elsewhere and may need consent. See the README's *Personal data (GDPR)*.
|
||||||
|
|
@ -142,10 +141,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
||||||
- **Shop / payments**: all basket, slot-hold, Stripe and order logic lives in the PocketBase hooks (JSVM: synchronous, each handler `require()`s the lib; see the header comment). The public app must stay unprivileged — no superuser login, no Stripe secret key; its routes only proxy to `/api/shop/*` and manage the `basket_id` cookie (`app-public/src/lib/server/shop.ts`). Booking emails are rendered and sent by the public app from data the webhook hook returns (`OrderEmailData`, `sendOrderEmailsFromData`); keep `orderEmailData()` in the hook and `loadOrderEmailData()` in `packages/shared/src/server/email` returning the same shape. Local testing uses `stripe-mock` (`STRIPE_API_BASE`, local compose only).
|
- **Shop / payments**: all basket, slot-hold, Stripe and order logic lives in the PocketBase hooks (JSVM: synchronous, each handler `require()`s the lib; see the header comment). The public app must stay unprivileged — no superuser login, no Stripe secret key; its routes only proxy to `/api/shop/*` and manage the `basket_id` cookie (`app-public/src/lib/server/shop.ts`). Booking emails are rendered and sent by the public app from data the webhook hook returns (`OrderEmailData`, `sendOrderEmailsFromData`); keep `orderEmailData()` in the hook and `loadOrderEmailData()` in `packages/shared/src/server/email` returning the same shape. Local testing uses `stripe-mock` (`STRIPE_API_BASE`, local compose only).
|
||||||
|
|
||||||
### Styling
|
### Styling
|
||||||
- **Public site**: Custom theme via `@theme` in `app.css` — colors: `warm`, `charcoal`, `sage`, `sage-dark`, `terracotta`. Fonts: `font-sans` (body), `font-serif` (headings), chosen in Site design → Style (default DM Sans / Playfair Display).
|
- **Public site**: Custom theme via `@theme` in `app.css` — colors: `warm`, `charcoal`, `sage`, `sage-dark`, `terracotta`. Fonts: `DM Sans` (body), `Playfair Display` (headings).
|
||||||
- **Site design → Style** (`style` global: fonts, corners, text size, shadows, page width) becomes `--site-*` variables (`siteStyleVars` in `$shared/theme`) that the `@theme` tokens in both `app.css` files scale. So in public-site markup use the tokens — `rounded-xl`/`rounded-2xl`/`rounded-card`/`rounded-panel`, `shadow-sm`…`shadow-xl`, `max-w-3xl`/`6xl`/`7xl` — never `rounded-[2rem]` or an arbitrary `shadow-[…]`, which ignore the settings. Buttons, chips and icon buttons are `rounded-button` (a pill when Round, square when Sharp); only dots, avatars and badges stay `rounded-full`.
|
|
||||||
- Keep scrolling smooth: no `backdrop-blur` on public pages (it is redrawn on every scrolled frame; use a nearly solid background), and keep animations short. The `.reveal` / `.animate-fade-in` animations are switched off for people who ask for reduced motion and, by `scrollReveal.ts`, on devices that stutter (`plain-motion` on `<html>`, rules in both `app.css` files).
|
|
||||||
- Fonts are bundled `@fontsource-variable/*` packages, imported in each app's `src/lib/fonts.ts` and listed in `SITE_FONTS`; a new one goes in all three places.
|
|
||||||
- **Admin area**: DaisyUI **5** (no `form-control` / `label-text` / `*-bordered` — those are v4). Colours come from Site design via `$shared/theme`, rendered as a `<style>` in `<head>` (SSR, no flash): the admin gets only DaisyUI primary (= site Primary) and secondary (= site Accent) with auto-contrast text; `/preview` and the public site get all site colour variables. Never use `text-primary`/`text-secondary` for text — a light brand colour is unreadable as text; mark state with a tint/bar instead. Conventions:
|
- **Admin area**: DaisyUI **5** (no `form-control` / `label-text` / `*-bordered` — those are v4). Colours come from Site design via `$shared/theme`, rendered as a `<style>` in `<head>` (SSR, no flash): the admin gets only DaisyUI primary (= site Primary) and secondary (= site Accent) with auto-contrast text; `/preview` and the public site get all site colour variables. Never use `text-primary`/`text-secondary` for text — a light brand colour is unreadable as text; mark state with a tint/bar instead. Conventions:
|
||||||
- Section card: `rounded-box bg-base-100 p-5 shadow` with an `h2.text-2xl.font-bold` title (see Site design / globals).
|
- Section card: `rounded-box bg-base-100 p-5 shadow` with an `h2.text-2xl.font-bold` title (see Site design / globals).
|
||||||
- Form field: `<label class="fieldset"><span class="fieldset-legend">Label</span><input class="input w-full" /></label>`; hints in `<span class="label">`.
|
- Form field: `<label class="fieldset"><span class="fieldset-legend">Label</span><input class="input w-full" /></label>`; hints in `<span class="label">`.
|
||||||
|
|
@ -193,7 +189,7 @@ cd app-public && npm run build
|
||||||
- `DOMAIN` — base domain for subdomain routing. Defaults to `localhost` for local dev. Set in `docker-compose.yml` or `.env`.
|
- `DOMAIN` — base domain for subdomain routing. Defaults to `localhost` for local dev. Set in `docker-compose.yml` or `.env`.
|
||||||
- `URL_SCHEME` (default `http`), `URL_PORT` (default `:8080`; set it empty for no port) — build every browser-facing URL below as `<scheme>://<sub>.<DOMAIN><port>`. They must match the address bar exactly: a mismatched `ORIGIN` makes SvelteKit reject form POSTs (admin login) with "Cross-site POST form submissions are forbidden". Behind a TLS reverse proxy: `URL_SCHEME=https`, `URL_PORT=`. (podman-compose 1.5 can't do nested `${A:-${B}}` defaults, hence two flat variables.)
|
- `URL_SCHEME` (default `http`), `URL_PORT` (default `:8080`; set it empty for no port) — build every browser-facing URL below as `<scheme>://<sub>.<DOMAIN><port>`. They must match the address bar exactly: a mismatched `ORIGIN` makes SvelteKit reject form POSTs (admin login) with "Cross-site POST form submissions are forbidden". Behind a TLS reverse proxy: `URL_SCHEME=https`, `URL_PORT=`. (podman-compose 1.5 can't do nested `${A:-${B}}` defaults, hence two flat variables.)
|
||||||
- `PUBLIC_POCKETBASE_URL` — public-facing PocketBase URL (`<scheme>://db.${DOMAIN}<port>`). Set in `docker-compose.yml`.
|
- `PUBLIC_POCKETBASE_URL` — public-facing PocketBase URL (`<scheme>://db.${DOMAIN}<port>`). Set in `docker-compose.yml`.
|
||||||
- `POCKETBASE_INTERNAL_URL` — internal Docker network URL (`http://pocketbase:8090`). Set in `docker-compose.yml`.
|
- `POCKETBASE_INTERNAL_URL` — internal Docker network URL (`http://pocketbase:80`). Set in `docker-compose.yml`.
|
||||||
- `ORIGIN` — SvelteKit origin for SSR. Differs per app: `<scheme>://admin.${DOMAIN}<port>` (admin), `<scheme>://www.${DOMAIN}<port>` (public).
|
- `ORIGIN` — SvelteKit origin for SSR. Differs per app: `<scheme>://admin.${DOMAIN}<port>` (admin), `<scheme>://www.${DOMAIN}<port>` (public).
|
||||||
- `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`).
|
- `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`).
|
||||||
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `EMAIL_FROM`, `EMAIL_FROM_NAME` — Brevo SMTP relay for booking emails (both apps). Empty `SMTP_HOST` = log emails instead of sending.
|
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `EMAIL_FROM`, `EMAIL_FROM_NAME` — Brevo SMTP relay for booking emails (both apps). Empty `SMTP_HOST` = log emails instead of sending.
|
||||||
|
|
@ -201,5 +197,4 @@ cd app-public && npm run build
|
||||||
- `STRIPE_CURRENCY` — shop currency (ISO 4217, default `eur`; e.g. `nok`). One setting for what Stripe charges and how prices are shown: PocketBase, both apps' layout data (`currency`, read by blocks via `page.data.currency`) and booking emails. Format prices with `formatPrice(amount, currency)` from `$shared/calendar` — never hard-code a currency.
|
- `STRIPE_CURRENCY` — shop currency (ISO 4217, default `eur`; e.g. `nok`). One setting for what Stripe charges and how prices are shown: PocketBase, both apps' layout data (`currency`, read by blocks via `page.data.currency`) and booking emails. Format prices with `formatPrice(amount, currency)` from `$shared/calendar` — never hard-code a currency.
|
||||||
- Secrets (Stripe, `INTERNAL_API_SECRET`, SMTP) are read from a root-level `.env` next to `docker-compose.yml`; see `.env.example`.
|
- Secrets (Stripe, `INTERNAL_API_SECRET`, SMTP) are read from a root-level `.env` next to `docker-compose.yml`; see `.env.example`.
|
||||||
- `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET` → PocketBase only. `INTERNAL_API_SECRET` → PocketBase and app-public (booking-email status). No app gets PocketBase superuser credentials.
|
- `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET` → PocketBase only. `INTERNAL_API_SECRET` → PocketBase and app-public (booking-email status). No app gets PocketBase superuser credentials.
|
||||||
- Shop order: `items.priority` (higher first) is *Recommended*. It's set by dragging the `/items` list (`?/reorder` renumbers n…1), not typed in the item form; `sortItems()` in `packages/shared/src/items.ts` is the one place items are ordered (Shop block `sort` / `showSort`). *Most popular* ranks come from `GET /api/shop/popular` (`popularItems()` in the shop hooks, ids only — never expose sales counts), merged into `ItemRecord.popularRank` by `loadShopData()`.
|
|
||||||
- Shop listings are public data, loaded anonymously by `loadShopData()` in `packages/shared/src/server/shop.ts` (public layout and admin `/preview`). The Shop block fetches bookable times itself, per service and length, from `GET /api/slots` in each app (a proxy to `GET /api/shop/slots`); if it has nothing to show it says "Nothing is available".
|
- Shop listings are public data, loaded anonymously by `loadShopData()` in `packages/shared/src/server/shop.ts` (public layout and admin `/preview`). The Shop block fetches bookable times itself, per service and length, from `GET /api/slots` in each app (a proxy to `GET /api/shop/slots`); if it has nothing to show it says "Nothing is available".
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
{$CADDY_SCHEME}://db.{$DOMAIN}:8080 {
|
{$CADDY_SCHEME}://db.{$DOMAIN}:8080 {
|
||||||
# PocketBase admin UI lives at /_/ — redirect bare root there.
|
# PocketBase admin UI lives at /_/ — redirect bare root there.
|
||||||
redir / /_/{path}
|
redir / /_/{path}
|
||||||
reverse_proxy pocketbase:8090
|
reverse_proxy pocketbase:80
|
||||||
}
|
}
|
||||||
|
|
||||||
{$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 {
|
{$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 {
|
||||||
|
|
|
||||||
48
README.md
48
README.md
|
|
@ -73,41 +73,20 @@ Subsequent builds reuse the npm cache declared in each app's `Dockerfile`.
|
||||||
|
|
||||||
The app containers use two PocketBase URLs:
|
The app containers use two PocketBase URLs:
|
||||||
|
|
||||||
- `POCKETBASE_INTERNAL_URL=http://pocketbase:8090` for server-side SvelteKit calls from the app containers (the `elestio/pocketbase` image listens on 8090).
|
- `POCKETBASE_INTERNAL_URL=http://pocketbase:80` for server-side SvelteKit calls from the app containers when using the included `spectado/pocketbase` image.
|
||||||
- `PUBLIC_POCKETBASE_URL=http://db.${DOMAIN}:8080` for browser-side admin uploads and public file URLs. Points to the Caddy reverse proxy so browsers reach PocketBase via the `db` subdomain.
|
- `PUBLIC_POCKETBASE_URL=http://db.${DOMAIN}:8080` for browser-side admin uploads and public file URLs. Points to the Caddy reverse proxy so browsers reach PocketBase via the `db` subdomain.
|
||||||
|
|
||||||
## PocketBase setup
|
## PocketBase setup
|
||||||
|
|
||||||
A fresh install, once the stack is up (written for the PocketBase 0.40 dashboard):
|
1. Open `http://db.localhost:8080/_/`.
|
||||||
|
2. Create the first PocketBase admin user when prompted.
|
||||||
|
3. Import `pb_schema.json` from the PocketBase admin UI collection settings/import flow. This file uses the newer PocketBase `fields` schema format; if PocketBase still reports `Invalid collections configuration`, create the three collections manually using the fields below.
|
||||||
|
4. Create starter records:
|
||||||
|
- `pages`: slug `home`, title `Home`, `published: true`, and a blocks JSON array.
|
||||||
|
- `globals`: key `header`, data matching the header JSON in the project prompt.
|
||||||
|
- `globals`: key `footer`, data matching the footer JSON in the project prompt.
|
||||||
|
|
||||||
1. **Create the first superuser.** PocketBase prints a one-time install link in its log (`docker compose logs pocketbase`): `http://0.0.0.0:8090/_/#/pbinstall/<token>`. Open it with `http://0.0.0.0:8090` replaced by the address you reach PocketBase at, e.g. `http://db.localhost:8080/_/#/pbinstall/<token>`.
|
If the `globals` records do not exist, the app falls back to safe defaults and the admin globals page will create them.
|
||||||
2. **Import the schema.** In the dashboard: **Settings → Import collections → Load from JSON file**, choose `pb_schema.json`, and **tick "Merge with the existing collections"**. It is off by default, and without it the import deletes every collection that isn't in the file, including `users` (so nobody but superusers could sign in to the admin). Review, then **Confirm and import**. `PUT /api/collections/import` with `"deleteMissing": false` does the same.
|
|
||||||
3. **Add content.** Sign in to the admin app and import a site from `backups/` under **Backup → Import** (see `backups/README.md`), or start from empty: pages are created under **Pages**, and **Site design** creates its own records the first time it is opened.
|
|
||||||
|
|
||||||
The migrations in `pocketbase/pb_migrations/` already ran when PocketBase first started (before the collections existed, so they skipped); the imported `pb_schema.json` is the end state they lead to. On that first start the privacy cron also logs `[privacy] retention at startup failed: … no rows in result set`, because the collections don't exist yet; it is harmless and gone from the next start.
|
|
||||||
|
|
||||||
### Switching PocketBase image (existing installs)
|
|
||||||
|
|
||||||
The PocketBase image changed from `spectado/pocketbase:0.23.12` (removed from Docker Hub) to `elestio/pocketbase:v0.23.12`. It is the same PocketBase version, so the schema, migrations and hooks are unchanged, but the new image runs as a non-root `pocketbase` user (uid 100) and listens on port 8090. Files the old image wrote are owned by root, and PocketBase refuses to start on them (`attempt to write a readonly database`). Fix the ownership once, before the first start on the new image:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
docker compose stop pocketbase
|
|
||||||
# back up first: the volume is <project>_pocketbase (see `docker volume ls`)
|
|
||||||
docker compose run --rm --no-deps --user root --entrypoint chown pocketbase -R pocketbase:pocketbase /pb_data
|
|
||||||
docker compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
Fresh installs need nothing: a new volume is created with the right owner.
|
|
||||||
|
|
||||||
### Upgrading to PocketBase 0.40 (existing installs)
|
|
||||||
|
|
||||||
PocketBase went from 0.23.12 to 0.40.6 (same image, same port and user, so nothing above changes). On its first start 0.40 upgrades `pb_data` in place, and that can't be undone by going back to the old image: **back up `pb_data` first**, and to roll back, restore that backup. Coming from the spectado image, do the `chown` above too.
|
|
||||||
|
|
||||||
What changed for this project:
|
|
||||||
|
|
||||||
- **JSON field limits.** PocketBase's default limit for JSON fields fell to 1MB in 0.29, and six of ours had relied on it (their limits were under `options` in `pb_schema.json`, which PocketBase ignores). Migration `1793400000_json_field_limits.js` sets them explicitly (page and email blocks 2MB, site design 1MB, …). Real pages are far below that.
|
|
||||||
- **New dashboard** at `db.…/_/` (rewritten in 0.37); the setup steps above describe it.
|
|
||||||
- Downloads now send a quoted filename (`filename="photo.jpg"`); nothing here depends on it.
|
|
||||||
|
|
||||||
### Migrations
|
### Migrations
|
||||||
|
|
||||||
|
|
@ -133,7 +112,7 @@ If schema import fails because of a PocketBase version mismatch, create these co
|
||||||
|
|
||||||
Commerce collections (see the Stripe section above for context):
|
Commerce collections (see the Stripe section above for context):
|
||||||
|
|
||||||
- `items` — `name` text, `description` text, `price` number, `image` relation→media, `type` select `item|item_with_time|bundle`, `stock` number + `trackStock` bool (products; PocketBase reads an empty number back as 0, so `trackStock` off = unlimited), `durations` json (services: `[{ minutes, price }]`, the lengths it can be booked for; `price` is then kept at the lowest of them), `bufferMinutes` number (nullable, get-ready minutes after each appointment), `capacity` number (nullable = 1, default places for new group sessions), `bundleParts` json (bundles: `[{ item, minutes, count }]`, minutes null for a product), `validMonths` number (bundles: how long a code can be used; empty = no expiry), `priority` number (−1000…1000, empty = 0: Shop blocks' *Recommended* order, higher first, then by name; set by dragging the `/items` list, never typed), `active` bool
|
- `items` — `name` text, `description` text, `price` number, `image` relation→media, `type` select `item|item_with_time|bundle`, `stock` number + `trackStock` bool (products; PocketBase reads an empty number back as 0, so `trackStock` off = unlimited), `durations` json (services: `[{ minutes, price }]`, the lengths it can be booked for; `price` is then kept at the lowest of them), `bufferMinutes` number (nullable, get-ready minutes after each appointment), `capacity` number (nullable = 1, default places for new group sessions), `bundleParts` json (bundles: `[{ item, minutes, count }]`, minutes null for a product), `validMonths` number (bundles: how long a code can be used; empty = no expiry), `active` bool
|
||||||
- `slots` — `kind` select `window|session`, `items` relation→items (multiple: the services bookable in a window; a session's one service), `start` date, `end` date, `startTimes` select `grid|edges` and `gridMinutes` number (windows), `capacity` number (sessions: places), `notes` text. Nothing about bookings is stored here — see *Slot availability* below
|
- `slots` — `kind` select `window|session`, `items` relation→items (multiple: the services bookable in a window; a session's one service), `start` date, `end` date, `startTimes` select `grid|edges` and `gridMinutes` number (windows), `capacity` number (sessions: places), `notes` text. Nothing about bookings is stored here — see *Slot availability* below
|
||||||
- `baskets` — `status` select `active|completed|abandoned`, `expiresAt` date, `email` text, `customerDetails` json, `stripePaymentIntentId` text, `pass` relation→passes (the code applied at checkout)
|
- `baskets` — `status` select `active|completed|abandoned`, `expiresAt` date, `email` text, `customerDetails` json, `stripePaymentIntentId` text, `pass` relation→passes (the code applied at checkout)
|
||||||
- `basket_lines` — `basket` relation→baskets, `item` relation→items, `slot` relation→slots (nullable), `quantity` number (places, for a slot line), `lineType` select `item|slot`, `start` date and `minutes` number (a slot line's booked time), `heldUntil` date (a slot line's hold), `pass` relation→passes (the code paying for this booking), `giftTo` / `giftMessage` text (who a bundle is for)
|
- `basket_lines` — `basket` relation→baskets, `item` relation→items, `slot` relation→slots (nullable), `quantity` number (places, for a slot line), `lineType` select `item|slot`, `start` date and `minutes` number (a slot line's booked time), `heldUntil` date (a slot line's hold), `pass` relation→passes (the code paying for this booking), `giftTo` / `giftMessage` text (who a bundle is for)
|
||||||
|
|
@ -142,7 +121,7 @@ Commerce collections (see the Stripe section above for context):
|
||||||
- `passes` — bundle/voucher codes: `code` text (unique, 8 characters, shown as `ABCD-2345`), `item` relation→items (the bundle), `order` relation→orders (empty when issued in the admin), `name` text, `parts` json (snapshot: `[{ item, name, minutes, count, value }]`, `value` = the part's share of the price), `email` text (buyer), `recipientName` / `message` text, `expiresAt` date, `status` select `active|void`, `anonymisedAt` date. What's used is never stored — see *Bundles and codes*
|
- `passes` — bundle/voucher codes: `code` text (unique, 8 characters, shown as `ABCD-2345`), `item` relation→items (the bundle), `order` relation→orders (empty when issued in the admin), `name` text, `parts` json (snapshot: `[{ item, name, minutes, count, value }]`, `value` = the part's share of the price), `email` text (buyer), `recipientName` / `message` text, `expiresAt` date, `status` select `active|void`, `anonymisedAt` date. What's used is never stored — see *Bundles and codes*
|
||||||
- `email_templates` — `key` text (unique: `customer_confirmation` | `client_alert`), `subject` text, `blocks` json, `recipients` text, `enabled` bool
|
- `email_templates` — `key` text (unique: `customer_confirmation` | `client_alert`), `subject` text, `blocks` json, `recipients` text, `enabled` bool
|
||||||
|
|
||||||
> **Schema format note:** `pb_schema.json` targets PocketBase 0.23+ using the `fields` array (not the legacy `schema` array). Field config (`collectionId`, `cascadeDelete`, `maxSelect`, `values`, number `min`/`max`/`onlyInt`) belongs at the field top level — 0.23 silently ignores anything nested under `options`, so the older number/text fields that still use `options` get no min/max on a fresh install (the JSON fields' `maxSize` has been moved up; see *Upgrading to PocketBase 0.40*). Importing the whole file via the PocketBase admin UI or `PUT /api/collections/import` creates or updates all collections in one pass; keep *Merge with the existing collections* ticked (`deleteMissing: false`), or `users` is deleted.
|
> **Schema format note:** `pb_schema.json` targets PocketBase 0.23+ using the `fields` array (not the legacy `schema` array). Field config (`collectionId`, `cascadeDelete`, `maxSelect`, `values`, number `min`/`max`/`onlyInt`) belongs at the field top level — 0.23 silently ignores anything nested under `options`, so the older number/text fields that still use `options` get no min/max on a fresh install. Importing the whole file via the PocketBase admin UI or `PUT /api/collections/import` creates or updates all collections in one pass.
|
||||||
|
|
||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
|
|
@ -159,8 +138,7 @@ All routes in `app-admin` except `/login` are guarded in `src/hooks.server.ts`.
|
||||||
- `/pages` — list/create pages
|
- `/pages` — list/create pages
|
||||||
- `/pages/[slug]` — block editor with draft preview. Text is edited visually (headings, bold, italic, strikethrough, links, lists, pull quotes, lines; alignment and a small *footnote* size per block). Layouts have their own blocks: **Cards** (pictures or numbered steps, optionally linked — e.g. *Who I work with*, *Read next*, *How it works*) and **FAQ** (questions that open to show the answer). An **HTML** block takes raw HTML for embeds and one-offs (inline styles only; anything it loads from another site shares visitors' IPs). Every block has an *Anchor*, so a button or link to `#prices` jumps to it.
|
- `/pages/[slug]` — block editor with draft preview. Text is edited visually (headings, bold, italic, strikethrough, links, lists, pull quotes, lines; alignment and a small *footnote* size per block). Layouts have their own blocks: **Cards** (pictures or numbered steps, optionally linked — e.g. *Who I work with*, *Read next*, *How it works*) and **FAQ** (questions that open to show the answer). An **HTML** block takes raw HTML for embeds and one-offs (inline styles only; anything it loads from another site shares visitors' IPs). Every block has an *Anchor*, so a button or link to `#prices` jumps to it.
|
||||||
- `/calendar` — events shown by Upcoming Calendar blocks
|
- `/calendar` — events shown by Upcoming Calendar blocks
|
||||||
- `/items` — services, products and bundles shown in Shop blocks, listed in shop order. Drag a row by its ⠿ handle (or focus the handle and press ↑/↓), then *Save order*: the `?/reorder` action stores it as `items.priority` (n…1, first = highest), writing only what changed. New items go to the end
|
- `/items` — services, products and bundles shown in Shop blocks
|
||||||
- Shop block order: *Recommended* (by priority), *Most popular*, *Price: low to high / high to low*, *Name (A–Z)*, chosen per block (`sort`); *Let visitors sort* (`showSort`) adds a "Sort by" menu that starts at that order. *Most popular* = units in paid orders over the last 90 days, from `GET /api/shop/popular` (public; item ids best-selling first, never the numbers; refunded orders and products handed over inside a bundle don't count, bookings paid with a code do). Items without recent sales follow in Recommended order, and the menu leaves the choice out until something has sold. Chosen items (`itemIds`) follow the block's order too, not the order they were picked in.
|
|
||||||
- `/slots` — when the practitioner can be booked: **windows** (e.g. 09:00–12:00, with the services bookable in it and where bookings may start — in fixed steps (every 10–60 min, default 30), or only at the start/end of the free time) and **group sessions** (one service at one of its lengths, fixed time, places). Month calendar, a day view with free time and bookings, and bulk tools — *Generate slots* (date range × weekdays × hours → windows, or sessions spaced by length + get-ready time), *Copy a week* (repeat into the next 1–12 weeks) and *Clear slots* (slots with nothing booked). No two slots may overlap (windows and group sessions alike); bulk tools preview first and skip past or overlapping slots. A window can't shrink past a booking in it.
|
- `/slots` — when the practitioner can be booked: **windows** (e.g. 09:00–12:00, with the services bookable in it and where bookings may start — in fixed steps (every 10–60 min, default 30), or only at the start/end of the free time) and **group sessions** (one service at one of its lengths, fixed time, places). Month calendar, a day view with free time and bookings, and bulk tools — *Generate slots* (date range × weekdays × hours → windows, or sessions spaced by length + get-ready time), *Copy a week* (repeat into the next 1–12 weeks) and *Clear slots* (slots with nothing booked). No two slots may overlap (windows and group sessions alike); bulk tools preview first and skip past or overlapping slots. A window can't shrink past a booking in it.
|
||||||
- `/items` lists each service's lengths and prices (*Lengths and prices* rows); the Shop block shows a slider between them.
|
- `/items` lists each service's lengths and prices (*Lengths and prices* rows); the Shop block shows a slider between them.
|
||||||
- `/passes` — *Vouchers & codes*: search codes (code, email, recipient, bundle), see what each has used/held/left and each part's share of the price, change the expiry, void/reactivate, and issue a code without a purchase
|
- `/passes` — *Vouchers & codes*: search codes (code, email, recipient, bundle), see what each has used/held/left and each part's share of the price, change the expiry, void/reactivate, and issue a code without a purchase
|
||||||
|
|
@ -239,7 +217,7 @@ What the software does; the studio (the controller) is responsible for the priva
|
||||||
- **Checkout:** a short privacy notice with the link, and a hint under the notes field asking customers not to write health details (special-category data). There is deliberately no "I consent" box: booking data is processed to perform the contract, not on consent. Both texts are editable in the Checkout block.
|
- **Checkout:** a short privacy notice with the link, and a hint under the notes field asking customers not to write health details (special-category data). There is deliberately no "I consent" box: booking data is processed to perform the contract, not on consent. Both texts are editable in the Checkout block.
|
||||||
- **Customers (admin):** look a customer up by name, email, phone or notes (orders and unpaid checkouts, matched by email case-insensitively); *Export data (JSON)* for access/portability requests; correct name/email/phone or remove notes on every record; *Erase* anonymises their orders (amounts, services and dates stay for the accounts) and their codes (the codes keep working), and deletes unpaid checkouts. Stripe and the email provider keep their own copies — handle those in their dashboards.
|
- **Customers (admin):** look a customer up by name, email, phone or notes (orders and unpaid checkouts, matched by email case-insensitively); *Export data (JSON)* for access/portability requests; correct name/email/phone or remove notes on every record; *Erase* anonymises their orders (amounts, services and dates stay for the accounts) and their codes (the codes keep working), and deletes unpaid checkouts. Stripe and the email provider keep their own copies — handle those in their dashboards.
|
||||||
- **Retention:** daily at 03:15 UTC and on PocketBase start (`pocketbase/pb_hooks/privacy.pb.js`): unpaid checkouts are deleted after *N* days (default 30); orders are anonymised after *M* months (default 0 = never — set it once the accountant has said how long records must be kept). Orders with a booking still ahead are skipped; codes are anonymised with the same age once they have expired or are used up. Settings live in the `privacy` global.
|
- **Retention:** daily at 03:15 UTC and on PocketBase start (`pocketbase/pb_hooks/privacy.pb.js`): unpaid checkouts are deleted after *N* days (default 30); orders are anonymised after *M* months (default 0 = never — set it once the accountant has said how long records must be kept). Orders with a booking still ahead are skipped; codes are anonymised with the same age once they have expired or are used up. Settings live in the `privacy` global.
|
||||||
- **No third parties on page load:** fonts are bundled (`@fontsource-variable/*`; *Site design → Style* picks from them), not loaded from Google, and Stripe.js loads only when the customer presses Pay (`@stripe/stripe-js/pure`). The only cookies are the basket cookie and the admin login, so no cookie banner is needed — keep it that way, or add one before adding analytics.
|
- **No third parties on page load:** fonts are bundled (`@fontsource/*`), not loaded from Google, and Stripe.js loads only when the customer presses Pay (`@stripe/stripe-js/pure`). The only cookies are the basket cookie and the admin login, so no cookie banner is needed — keep it that way, or add one before adding analytics.
|
||||||
- All customer-data reads and writes go through `/api/privacy/*` (signed-in admin only; `orders`/`baskets` are superuser-only collections).
|
- All customer-data reads and writes go through `/api/privacy/*` (signed-in admin only; `orders`/`baskets` are superuser-only collections).
|
||||||
|
|
||||||
## Public routes (public app)
|
## Public routes (public app)
|
||||||
|
|
|
||||||
167
app-admin/package-lock.json
generated
167
app-admin/package-lock.json
generated
|
|
@ -20,27 +20,14 @@
|
||||||
"@tiptap/starter-kit": "^3.23.4",
|
"@tiptap/starter-kit": "^3.23.4",
|
||||||
"daisyui": "^5.5.19",
|
"daisyui": "^5.5.19",
|
||||||
"nodemailer": "^10.0.12",
|
"nodemailer": "^10.0.12",
|
||||||
"pocketbase": "^0.28.2",
|
"pocketbase": "^0.26.9",
|
||||||
"svelte-tiptap": "^3.0.1",
|
"svelte-tiptap": "^3.0.1",
|
||||||
"tailwindcss": "^4.3.0",
|
"tailwindcss": "^4.3.0",
|
||||||
"uuid": "^14.0.0"
|
"uuid": "^14.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/cormorant-garamond": "^5.3.0",
|
"@fontsource/dm-sans": "^5.3.0",
|
||||||
"@fontsource-variable/dm-sans": "^5.3.0",
|
"@fontsource/playfair-display": "^5.3.0",
|
||||||
"@fontsource-variable/eb-garamond": "^5.3.0",
|
|
||||||
"@fontsource-variable/fraunces": "^5.3.0",
|
|
||||||
"@fontsource-variable/inter": "^5.3.0",
|
|
||||||
"@fontsource-variable/josefin-sans": "^5.3.0",
|
|
||||||
"@fontsource-variable/libre-baskerville": "^5.3.0",
|
|
||||||
"@fontsource-variable/lora": "^5.3.0",
|
|
||||||
"@fontsource-variable/manrope": "^5.3.0",
|
|
||||||
"@fontsource-variable/montserrat": "^5.3.0",
|
|
||||||
"@fontsource-variable/nunito": "^5.3.0",
|
|
||||||
"@fontsource-variable/outfit": "^5.3.0",
|
|
||||||
"@fontsource-variable/playfair-display": "^5.3.0",
|
|
||||||
"@fontsource-variable/raleway": "^5.3.0",
|
|
||||||
"@fontsource-variable/work-sans": "^5.3.0",
|
|
||||||
"@sveltejs/kit": "^2.57.0",
|
"@sveltejs/kit": "^2.57.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||||
"@types/node": "^25.8.0",
|
"@types/node": "^25.8.0",
|
||||||
|
|
@ -133,150 +120,20 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/@fontsource-variable/cormorant-garamond": {
|
"node_modules/@fontsource/dm-sans": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/cormorant-garamond/-/cormorant-garamond-5.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fontsource/dm-sans/-/dm-sans-5.3.0.tgz",
|
||||||
"integrity": "sha512-rgZJ/5w3hi60swAPnrOXpZf5wEH6NTrvm4H8D9Y4b1QIFUqlX14eM3QTMU/eAznjfh0eXpO1QUqsFhiy58aoMg==",
|
"integrity": "sha512-lYJtMXXO28q1z+yz+z8XKd0s4hXaa9QdkETzkyD760sidCv5heI86weYA0sx0Nc4pAMAQTUuyf4gO44cYKKS9g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "OFL-1.1",
|
"license": "OFL-1.1",
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
"url": "https://github.com/sponsors/ayuhito"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fontsource-variable/dm-sans": {
|
"node_modules/@fontsource/playfair-display": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/dm-sans/-/dm-sans-5.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fontsource/playfair-display/-/playfair-display-5.3.0.tgz",
|
||||||
"integrity": "sha512-BpUG5bqePiDFMBM4ZtLSlPdAIOM990uB1dlXzIf4aw21yQR7BmykedLXXXMqGWsR18aMLOsbWccwJNh3ztTQaA==",
|
"integrity": "sha512-uJSABalvdWc10fEPppQjQocamT21LEyRfzzWfRfqbkPz+sRv+kKpYDKyluBUskvJREkJTos9epj1WjQROGu99Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/eb-garamond": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/eb-garamond/-/eb-garamond-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-656OJsA9Vv24yhqRZFEzXnzS2AYgKdEILLgHJYLzzXndgcWFKfSXFqzbRI5/6Yk1Yt7UfWrUeppE5nRQPQMwlQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/fraunces": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/fraunces/-/fraunces-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-9BYGySn4AHEJdgp9Z28tQ3X+laJMEOITXkQarZXeloWQZDq5oOvXJ3kDA8c7MGIfpogIaZfjrQBqmda8POOCKA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/inter": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/josefin-sans": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/josefin-sans/-/josefin-sans-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-duVgkuzE/co4iuIfJ7jM2qX0ED3b6qdY+SlSjNMs6zfhz7EE7kJxV0qF65hQCv1kN0A20j4FwsGAYJvfpU+iSg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/libre-baskerville": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/libre-baskerville/-/libre-baskerville-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-lIjXwDhcdr0OxSdzlAU4G7Tnny1LhgAiPFdp3/PjwRMqYt2JLU6pQiLwz/M5lRBs/kRtHwxknPUqRt37AnqPFg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/lora": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/lora/-/lora-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-2ph8KiZ8Bn141hWuC3ErtpJ+Ui8p2MJQn8TJNRSRmLmnCIOCtHfiBM9R7WLRPeUG/q6hXyHOxWQ8DvRSX+ixvQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/manrope": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/manrope/-/manrope-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-6D5dgokHsWDDMtmXHznKa0hK229NN+1a4BLPmUCLqcO1Pw5EEhWY5RFt0AcXnVRAljFFPfRtLkJePQj6LSsV6g==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/montserrat": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/montserrat/-/montserrat-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-7PaZoxaxrWLAyrhO46v65An9LhUhfkTExWLhfbywYZCnZEgg/W1rEHnlNmZKjNZ3nJTVYyicqxlJt10z/26yTA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/nunito": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/nunito/-/nunito-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-tw0ch7evIDSwoeUy+0XzocYHfbRWLeCRPJy22KgbrLjDLAbNw/fErBiil10Ssrs3Sjr55zaZrr36a975j8cBkQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/outfit": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/outfit/-/outfit-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-fPb5XnYK0k7SbR++HEmm4+ZqDszmLKQ+sPRUr8oQ/KNC0vy6r6hazJFe8iYozv4cqlHbvJ/JECkJWrfDodUMVQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/playfair-display": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/playfair-display/-/playfair-display-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-IHdzTvE8eGIXHteZql7KXoqdc3Gfm+Zs1u4XlSC3MeplkwviT3sx/P6gI0tLwg/xIYLF4ZJYveZ5V+bl9cnDwA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/raleway": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/raleway/-/raleway-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-aSV2k+V6Zz+od0dHpBOzkVxEzmgEdiXcxDfant39jLOx+T89dielQRrZylukwK3Fp+FY255gPqz67ruOfs1rqA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/work-sans": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/work-sans/-/work-sans-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-le8h/OIIuhm5Z7TdvuMw0yKg2gaCZUiMec8zaumsVVjzeJRBPEF0bQI/MkaZDHCVzZDvZoP/O2LiGOSfDLSbaw==",
|
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "OFL-1.1",
|
"license": "OFL-1.1",
|
||||||
"funding": {
|
"funding": {
|
||||||
|
|
@ -2499,9 +2356,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pocketbase": {
|
"node_modules/pocketbase": {
|
||||||
"version": "0.28.2",
|
"version": "0.26.9",
|
||||||
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.26.9.tgz",
|
||||||
"integrity": "sha512-5lS4g7iDZi90LxLai8kyUK4r5u1GkEAoZ3yuzTEFX97FyDQAoEmXWbTqf+pYA1hz5e/icBQu1MCUjM/9V8mitg==",
|
"integrity": "sha512-Tiv1/hNuUzRdvT0d8hF03dfzuefQ1WdSRp1A1q3wzFC/WYhQcbU/Qlaubl/3ZDo6xvFXBS8JAgBS/L+ms7nkVQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,8 @@
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/cormorant-garamond": "^5.3.0",
|
"@fontsource/dm-sans": "^5.3.0",
|
||||||
"@fontsource-variable/dm-sans": "^5.3.0",
|
"@fontsource/playfair-display": "^5.3.0",
|
||||||
"@fontsource-variable/eb-garamond": "^5.3.0",
|
|
||||||
"@fontsource-variable/fraunces": "^5.3.0",
|
|
||||||
"@fontsource-variable/inter": "^5.3.0",
|
|
||||||
"@fontsource-variable/josefin-sans": "^5.3.0",
|
|
||||||
"@fontsource-variable/libre-baskerville": "^5.3.0",
|
|
||||||
"@fontsource-variable/lora": "^5.3.0",
|
|
||||||
"@fontsource-variable/manrope": "^5.3.0",
|
|
||||||
"@fontsource-variable/montserrat": "^5.3.0",
|
|
||||||
"@fontsource-variable/nunito": "^5.3.0",
|
|
||||||
"@fontsource-variable/outfit": "^5.3.0",
|
|
||||||
"@fontsource-variable/playfair-display": "^5.3.0",
|
|
||||||
"@fontsource-variable/raleway": "^5.3.0",
|
|
||||||
"@fontsource-variable/work-sans": "^5.3.0",
|
|
||||||
"@sveltejs/kit": "^2.57.0",
|
"@sveltejs/kit": "^2.57.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||||
"@types/node": "^25.8.0",
|
"@types/node": "^25.8.0",
|
||||||
|
|
@ -48,7 +35,7 @@
|
||||||
"@tiptap/starter-kit": "^3.23.4",
|
"@tiptap/starter-kit": "^3.23.4",
|
||||||
"daisyui": "^5.5.19",
|
"daisyui": "^5.5.19",
|
||||||
"nodemailer": "^10.0.12",
|
"nodemailer": "^10.0.12",
|
||||||
"pocketbase": "^0.28.2",
|
"pocketbase": "^0.26.9",
|
||||||
"svelte-tiptap": "^3.0.1",
|
"svelte-tiptap": "^3.0.1",
|
||||||
"tailwindcss": "^4.3.0",
|
"tailwindcss": "^4.3.0",
|
||||||
"uuid": "^14.0.0"
|
"uuid": "^14.0.0"
|
||||||
|
|
|
||||||
|
|
@ -13,28 +13,9 @@
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Site design → Style sets the --site-* variables (siteStyleVars in
|
|
||||||
$shared/theme) on the public site and the admin preview; without them
|
|
||||||
(the admin's own pages) every token below is its usual value. Corners,
|
|
||||||
shadows and widths are scaled here, so blocks just use rounded-xl,
|
|
||||||
shadow-sm, max-w-6xl… Buttons and chips use rounded-button (a pill when
|
|
||||||
Round); dots and avatars stay rounded-full. */
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-sans: var(--site-font-body, 'DM Sans Variable', ui-sans-serif, system-ui, sans-serif);
|
--font-sans: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||||
--font-serif: var(--site-font-heading, 'Playfair Display Variable', Georgia, serif);
|
--font-serif: 'Playfair Display', Georgia, serif;
|
||||||
--radius-lg: calc(0.5rem * var(--site-corners, 1));
|
|
||||||
--radius-xl: calc(0.75rem * var(--site-corners, 1));
|
|
||||||
--radius-2xl: calc(1rem * var(--site-corners, 1));
|
|
||||||
--radius-card: calc(1.25rem * var(--site-corners, 1));
|
|
||||||
--radius-panel: calc(2rem * var(--site-corners, 1));
|
|
||||||
--radius-button: var(--site-button-radius, 9999px);
|
|
||||||
--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 1px 2px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 2px 4px -2px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 4px 6px -4px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 8px 10px -6px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--container-3xl: calc(48rem * var(--site-width, 1));
|
|
||||||
--container-6xl: calc(72rem * var(--site-width, 1));
|
|
||||||
--container-7xl: calc(80rem * var(--site-width, 1));
|
|
||||||
--color-warm: var(--color-bg, #faf8f5);
|
--color-warm: var(--color-bg, #faf8f5);
|
||||||
--color-charcoal: var(--color-heading, #2c2c2c);
|
--color-charcoal: var(--color-heading, #2c2c2c);
|
||||||
--color-sage: var(--color-primary, #8a9a7b);
|
--color-sage: var(--color-primary, #8a9a7b);
|
||||||
|
|
@ -73,9 +54,7 @@
|
||||||
--fg-body: var(--color-text, #2c2c2c);
|
--fg-body: var(--color-text, #2c2c2c);
|
||||||
background: var(--color-bg, #faf8f5);
|
background: var(--color-bg, #faf8f5);
|
||||||
color: var(--fg-body);
|
color: var(--fg-body);
|
||||||
font-family: var(--font-sans);
|
font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||||
/* Site design → Style → Text size; rem-sized spacing grows with it. */
|
|
||||||
font-size: var(--site-text-size, 100%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Foreground colour utilities (set per-block via BackgroundWrapper) ── */
|
/* ── Foreground colour utilities (set per-block via BackgroundWrapper) ── */
|
||||||
|
|
@ -105,7 +84,7 @@ h1,
|
||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
h4 {
|
h4 {
|
||||||
font-family: var(--font-serif);
|
font-family: 'Playfair Display', Georgia, serif;
|
||||||
color: var(--fg-heading, #2c2c2c);
|
color: var(--fg-heading, #2c2c2c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +124,7 @@ h4 {
|
||||||
margin: 0.75rem 0;
|
margin: 0.75rem 0;
|
||||||
padding-left: 1.25rem;
|
padding-left: 1.25rem;
|
||||||
border-left: 3px solid var(--color-primary, #8a9a7b);
|
border-left: 3px solid var(--color-primary, #8a9a7b);
|
||||||
font-family: var(--font-serif);
|
font-family: 'Playfair Display', Georgia, serif;
|
||||||
font-size: 1.35rem;
|
font-size: 1.35rem;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
@ -167,13 +146,12 @@ h4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Scroll-reveal animations ── */
|
/* ── Scroll-reveal animations ── */
|
||||||
/* Kept short: blocks fading in while someone scrolls are what slows scrolling down. */
|
|
||||||
.reveal {
|
.reveal {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(16px);
|
transform: translateY(30px);
|
||||||
transition:
|
transition:
|
||||||
opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
|
opacity 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
|
||||||
transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
|
transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal-visible {
|
.reveal-visible {
|
||||||
|
|
@ -184,8 +162,8 @@ h4 {
|
||||||
/* ── Hero fade-in stagger ── */
|
/* ── Hero fade-in stagger ── */
|
||||||
.animate-fade-in {
|
.animate-fade-in {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(12px);
|
transform: translateY(20px);
|
||||||
animation: fadeInUp 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
|
animation: fadeInUp 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeInUp {
|
@keyframes fadeInUp {
|
||||||
|
|
@ -200,30 +178,6 @@ html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No animations on devices that can't keep up (scrollReveal.ts adds .plain-motion
|
|
||||||
to <html>) or for people whose device asks for less motion. */
|
|
||||||
html.plain-motion .reveal,
|
|
||||||
html.plain-motion .animate-fade-in {
|
|
||||||
opacity: 1;
|
|
||||||
transform: none;
|
|
||||||
transition: none;
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.reveal,
|
|
||||||
.animate-fade-in {
|
|
||||||
opacity: 1;
|
|
||||||
transform: none;
|
|
||||||
transition: none;
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
scroll-behavior: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Visual editor (RichTextEditor): roughly how the site shows text, sized for the sidebar. */
|
/* Visual editor (RichTextEditor): roughly how the site shows text, sized for the sidebar. */
|
||||||
.rich-text h2 { font-size: 1.5rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
|
.rich-text h2 { font-size: 1.5rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
|
||||||
.rich-text h3 { font-size: 1.2rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
|
.rich-text h3 { font-size: 1.2rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoginRoute && isAuthed && event.request.method === 'GET') {
|
if (isLoginRoute && isAuthed && event.request.method === 'GET') {
|
||||||
throw redirect(303, '/');
|
throw redirect(303, '/pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await resolve(event);
|
const response = await resolve(event);
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
// Income per month as bars, one series (so no legend: the section title names
|
|
||||||
// it). The month-by-month table below it on the dashboard is its table view.
|
|
||||||
// Drawn at the box's real pixel width so labels stay readable on a phone.
|
|
||||||
|
|
||||||
/** `label` goes under the bar; `name` (e.g. "October 2026") heads the tooltip. */
|
|
||||||
type Month = { month: string; label: string; name: string; income: number; orders: number };
|
|
||||||
let {
|
|
||||||
months,
|
|
||||||
format,
|
|
||||||
tickFormat = format,
|
|
||||||
current = ''
|
|
||||||
}: { months: Month[]; format: (amount: number) => string; tickFormat?: (amount: number) => string; current?: string } = $props();
|
|
||||||
|
|
||||||
let width = $state(600);
|
|
||||||
const height = 220;
|
|
||||||
const pad = { top: 12, right: 8, bottom: 28, left: 64 };
|
|
||||||
let plotWidth = $derived(Math.max(width - pad.left - pad.right, 100));
|
|
||||||
const plotHeight = height - pad.top - pad.bottom;
|
|
||||||
|
|
||||||
// A 1-2-5 step giving about four gridlines.
|
|
||||||
let ticks = $derived.by(() => {
|
|
||||||
const max = Math.max(...months.map((m) => m.income), 0);
|
|
||||||
if (max <= 0) return [0];
|
|
||||||
const rough = max / 4;
|
|
||||||
const magnitude = 10 ** Math.floor(Math.log10(rough));
|
|
||||||
const step = [1, 2, 5, 10].map((n) => n * magnitude).find((n) => n >= rough)!;
|
|
||||||
return Array.from({ length: Math.ceil(max / step) + 1 }, (_, i) => i * step);
|
|
||||||
});
|
|
||||||
let top = $derived(ticks.at(-1) || 1);
|
|
||||||
let slot = $derived(plotWidth / Math.max(months.length, 1));
|
|
||||||
// Thin bars: at most 28px, with the gap between them clearly wider than 2px.
|
|
||||||
let barWidth = $derived(Math.min(28, slot * 0.6));
|
|
||||||
const y = (value: number) => pad.top + plotHeight - (value / top) * plotHeight;
|
|
||||||
|
|
||||||
/** A bar with 4px rounded top corners, square on the baseline. */
|
|
||||||
function barPath(x: number, value: number) {
|
|
||||||
const h = (value / top) * plotHeight;
|
|
||||||
if (h <= 0) return '';
|
|
||||||
const r = Math.min(4, h, barWidth / 2);
|
|
||||||
const yTop = pad.top + plotHeight - h;
|
|
||||||
const base = pad.top + plotHeight;
|
|
||||||
return `M${x},${base}V${yTop + r}Q${x},${yTop} ${x + r},${yTop}H${x + barWidth - r}Q${x + barWidth},${yTop} ${x + barWidth},${yTop + r}V${base}Z`;
|
|
||||||
}
|
|
||||||
|
|
||||||
let hovered = $state<number | null>(null);
|
|
||||||
// Every month labelled when there's room, else every other one (current month always).
|
|
||||||
let labelEvery = $derived(slot < 40 ? 2 : 1);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="relative" bind:clientWidth={width}>
|
|
||||||
<svg {width} {height} role="img" aria-label="Income per month, last {months.length} months. The table below lists the figures.">
|
|
||||||
{#each ticks as tick (tick)}
|
|
||||||
<line x1={pad.left} x2={pad.left + plotWidth} y1={y(tick)} y2={y(tick)} class="stroke-base-content/10" stroke-width="1" />
|
|
||||||
<text x={pad.left - 8} y={y(tick)} dy="0.32em" text-anchor="end" class="fill-base-content/60 text-[11px] tabular-nums">{tickFormat(tick)}</text>
|
|
||||||
{/each}
|
|
||||||
{#each months as m, i (m.month)}
|
|
||||||
{@const x = pad.left + i * slot + (slot - barWidth) / 2}
|
|
||||||
<path d={barPath(x, m.income)} class={hovered === null || hovered === i ? 'fill-primary' : 'fill-primary/40'} />
|
|
||||||
{#if i % labelEvery === (months.length - 1) % labelEvery || m.month === current}
|
|
||||||
<text x={x + barWidth / 2} y={height - 8} text-anchor="middle" class="text-[11px] {m.month === current ? 'fill-base-content font-semibold' : 'fill-base-content/60'}">{m.label}</text>
|
|
||||||
{/if}
|
|
||||||
<!-- Hit target: the whole column, much bigger than the bar. -->
|
|
||||||
<rect
|
|
||||||
x={pad.left + i * slot}
|
|
||||||
y={pad.top}
|
|
||||||
width={slot}
|
|
||||||
height={plotHeight}
|
|
||||||
fill="transparent"
|
|
||||||
role="presentation"
|
|
||||||
onpointerenter={() => (hovered = i)}
|
|
||||||
onpointerleave={() => (hovered = null)}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</svg>
|
|
||||||
{#if hovered !== null}
|
|
||||||
{@const m = months[hovered]}
|
|
||||||
{@const left = Math.min(Math.max(pad.left + hovered * slot + slot / 2, 70), width - 70)}
|
|
||||||
<div class="pointer-events-none absolute -translate-x-1/2 whitespace-nowrap rounded-box bg-base-100 px-3 py-2 text-sm shadow-lg ring-1 ring-base-300" style="left: {left}px; top: {Math.max(y(m.income) - 64, 0)}px">
|
|
||||||
<p class="font-semibold">{m.name}</p>
|
|
||||||
<p class="tabular-nums">{format(m.income)} · {m.orders} {m.orders === 1 ? 'order' : 'orders'}</p>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
@ -73,9 +73,7 @@ export function createBlock(type: BlockType): ContentBlock {
|
||||||
title: 'Our Services',
|
title: 'Our Services',
|
||||||
itemTypeFilter: 'all',
|
itemTypeFilter: 'all',
|
||||||
itemIds: [],
|
itemIds: [],
|
||||||
layout: 'grid',
|
layout: 'grid'
|
||||||
sort: 'recommended',
|
|
||||||
showSort: false
|
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 'checkout':
|
case 'checkout':
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { ContentBlock, ShopBlockData, ShopSort } from '$lib/types';
|
import type { ContentBlock, ShopBlockData } from '$lib/types';
|
||||||
import { SHOP_SORTS } from '$shared/items';
|
|
||||||
import SegmentedControl from './SegmentedControl.svelte';
|
import SegmentedControl from './SegmentedControl.svelte';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
@ -56,28 +55,11 @@
|
||||||
formatLabel={(v) => typeFilterLabels[String(v)] || String(v)}
|
formatLabel={(v) => typeFilterLabels[String(v)] || String(v)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label class="fieldset">
|
|
||||||
<span class="fieldset-legend">Order</span>
|
|
||||||
<select class="select w-full" value={block.data.sort || 'recommended'} onchange={(e) => updateData({ sort: e.currentTarget.value as ShopSort })}>
|
|
||||||
{#each SHOP_SORTS as choice (choice.value)}
|
|
||||||
<option value={choice.value}>{choice.label}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
<span class="label whitespace-normal">
|
|
||||||
Recommended follows each item’s priority (Services & products). Most popular counts what sold in the last 90 days; items without recent sales come after, in Recommended order.
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label class="label cursor-pointer gap-3 whitespace-normal text-base-content">
|
|
||||||
<input class="toggle toggle-primary shrink-0" type="checkbox" checked={!!block.data.showSort} onchange={(e) => updateData({ showSort: e.currentTarget.checked })} />
|
|
||||||
<span>Let visitors sort <span class="text-base-content/60">— a “Sort by” menu above the items, starting at the order chosen above</span></span>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
{#if items.length}
|
{#if items.length}
|
||||||
<div class="rounded-box border border-base-300 p-4">
|
<div class="rounded-box border border-base-300 p-4">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<h3 class="font-semibold">Items</h3>
|
<h3 class="font-semibold">Items</h3>
|
||||||
<p class="text-sm text-base-content/60">Leave empty to show all items of the selected type. Chosen items are shown in the order above, not the order you pick them.</p>
|
<p class="text-sm text-base-content/60">Leave empty to show all items of the selected type.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap gap-2">
|
<div class="flex flex-wrap gap-2">
|
||||||
{#each items as item}
|
{#each items as item}
|
||||||
|
|
|
||||||
|
|
@ -151,14 +151,11 @@
|
||||||
onChange={(v) => (draft.startTimes = v as StartTimesMode)}
|
onChange={(v) => (draft.startTimes = v as StartTimesMode)}
|
||||||
/>
|
/>
|
||||||
{#if draft.startTimes === 'grid'}
|
{#if draft.startTimes === 'grid'}
|
||||||
<!-- Laid out like the Start times row above: label on the left, or above it in a narrow row. -->
|
<label class="mt-2 flex items-center gap-3">
|
||||||
<label class="mt-2 @container block">
|
<span class="w-28 shrink-0 text-sm font-medium">Step</span>
|
||||||
<span class="flex flex-col gap-1 @sm:flex-row @sm:items-center @sm:gap-3">
|
<select class="select select-sm w-40" name="gridMinutes" bind:value={draft.gridMinutes}>
|
||||||
<span class="shrink-0 text-sm font-medium @sm:w-28">Step</span>
|
{#each GRID_STEP_OPTIONS as step (step)}<option value={step}>Every {step} min</option>{/each}
|
||||||
<select class="select select-sm w-full @sm:flex-1" name="gridMinutes" bind:value={draft.gridMinutes}>
|
</select>
|
||||||
{#each GRID_STEP_OPTIONS as step (step)}<option value={step}>Every {step} min</option>{/each}
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
<span class="label whitespace-normal">{startTimesHint(draft.startTimes, draft.gridMinutes)}</span>
|
<span class="label whitespace-normal">{startTimesHint(draft.startTimes, draft.gridMinutes)}</span>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
// The fonts Site design → Style offers (SITE_FONTS in $shared/theme), bundled
|
|
||||||
// and served by this app, not loaded from Google: a Google Fonts request sends
|
|
||||||
// every visitor's IP address to Google (GDPR). Each import only declares the
|
|
||||||
// font; a browser downloads the files of the fonts a page actually uses.
|
|
||||||
import '@fontsource-variable/playfair-display';
|
|
||||||
import '@fontsource-variable/cormorant-garamond';
|
|
||||||
import '@fontsource-variable/eb-garamond';
|
|
||||||
import '@fontsource-variable/libre-baskerville';
|
|
||||||
import '@fontsource-variable/lora';
|
|
||||||
import '@fontsource-variable/fraunces';
|
|
||||||
import '@fontsource-variable/dm-sans';
|
|
||||||
import '@fontsource-variable/inter';
|
|
||||||
import '@fontsource-variable/manrope';
|
|
||||||
import '@fontsource-variable/montserrat';
|
|
||||||
import '@fontsource-variable/nunito';
|
|
||||||
import '@fontsource-variable/outfit';
|
|
||||||
import '@fontsource-variable/raleway';
|
|
||||||
import '@fontsource-variable/work-sans';
|
|
||||||
import '@fontsource-variable/josefin-sans';
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
||||||
// Figures for the admin dashboard (/). Months are calendar months in
|
|
||||||
// SITE_TIMEZONE.
|
|
||||||
//
|
|
||||||
// Income counts an order in the month it was paid, so a voucher sold in March
|
|
||||||
// is March income and the session it later pays for adds hours but no income.
|
|
||||||
// Hours are the time covered by bookings, with overlaps counted once: six
|
|
||||||
// people in one group session are one hour of work, not six. Utilisation is
|
|
||||||
// that booked time against the time opened in Slots.
|
|
||||||
//
|
|
||||||
// Slot places and what codes have left come from the shop hooks (the only
|
|
||||||
// place that counts them); everything else is read from paid orders.
|
|
||||||
|
|
||||||
import { zonedDateKey, zonedInputToIso } from '$lib/calendar';
|
|
||||||
import type { createPocketBase } from '$lib/pb';
|
|
||||||
import { listPasses } from '$lib/server/passes';
|
|
||||||
import { loadSlotDetails, seatsTaken } from '$lib/server/slots';
|
|
||||||
|
|
||||||
type Pb = ReturnType<typeof createPocketBase>;
|
|
||||||
|
|
||||||
/** How many months the month-by-month table and chart show, this one included. */
|
|
||||||
export const DASHBOARD_MONTHS = 12;
|
|
||||||
const UPCOMING_DAYS = 7;
|
|
||||||
/** How far ahead "Needs attention" looks for nearly full sessions and expiring codes. */
|
|
||||||
const ATTENTION_DAYS = 30;
|
|
||||||
/** A group session is "nearly full" with this share of its places taken (or one place left). */
|
|
||||||
const NEARLY_FULL_SHARE = 0.75;
|
|
||||||
const TOP_LIST = 5;
|
|
||||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
||||||
|
|
||||||
export type DashboardMonth = { month: string; income: number; orders: number; minutes: number };
|
|
||||||
export type UpcomingBooking = { start: string; minutes: number; name: string; customer: string; quantity: number };
|
|
||||||
export type SalesRow = { name: string; minutes: number; count: number; income: number };
|
|
||||||
export type Regular = { name: string; orders: number; spent: number };
|
|
||||||
export type Attention =
|
|
||||||
| { kind: 'email'; orderId: string; customer: string; created: string }
|
|
||||||
| { kind: 'session'; start: string; name: string; taken: number; capacity: number }
|
|
||||||
| { kind: 'code'; code: string; name: string; expiresAt: string; left: number };
|
|
||||||
|
|
||||||
type Interval = { start: number; end: number };
|
|
||||||
|
|
||||||
/** `YYYY-MM` for `months` before (negative) or after `monthKey`. */
|
|
||||||
function shiftMonth(monthKey: string, months: number) {
|
|
||||||
const [year, month] = monthKey.split('-').map(Number);
|
|
||||||
const index = year * 12 + (month - 1) + months;
|
|
||||||
return `${Math.floor(index / 12)}-${String((index % 12) + 1).padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Epoch ms of a PocketBase date ('2026-10-27 09:00:00.000Z'), NaN if blank. */
|
|
||||||
const toMs = (value: unknown) => new Date(String(value || '').replace(' ', 'T')).getTime();
|
|
||||||
|
|
||||||
/** Intervals merged where they overlap or touch, sorted by start. */
|
|
||||||
function mergeIntervals(intervals: Interval[]) {
|
|
||||||
const merged: Interval[] = [];
|
|
||||||
for (const interval of [...intervals].sort((a, b) => a.start - b.start)) {
|
|
||||||
const last = merged.at(-1);
|
|
||||||
if (last && interval.start <= last.end) last.end = Math.max(last.end, interval.end);
|
|
||||||
else merged.push({ ...interval });
|
|
||||||
}
|
|
||||||
return merged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Minutes of merged `intervals` that fall inside [from, to). */
|
|
||||||
function minutesBetween(intervals: Interval[], from: number, to: number) {
|
|
||||||
return intervals.reduce((total, { start, end }) => total + Math.max(Math.min(end, to) - Math.max(start, from), 0) / 60_000, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Top rows by income, the rest folded into one "Other" row. */
|
|
||||||
function topWithOther(rows: SalesRow[], other: string) {
|
|
||||||
const sorted = [...rows].sort((a, b) => b.income - a.income || b.count - a.count);
|
|
||||||
if (sorted.length <= TOP_LIST) return sorted;
|
|
||||||
const rest = sorted.slice(TOP_LIST - 1);
|
|
||||||
return [
|
|
||||||
...sorted.slice(0, TOP_LIST - 1),
|
|
||||||
{ name: other, minutes: 0, count: rest.reduce((n, row) => n + row.count, 0), income: rest.reduce((n, row) => n + row.income, 0) }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function loadDashboard(pb: Pb, timeZone: string, now = new Date()) {
|
|
||||||
const nowMs = now.getTime();
|
|
||||||
const thisMonth = zonedDateKey(now.toISOString(), timeZone).slice(0, 7);
|
|
||||||
const months = Array.from({ length: DASHBOARD_MONTHS }, (_, i) => shiftMonth(thisMonth, i - (DASHBOARD_MONTHS - 1)));
|
|
||||||
// The table reaches back at least to January, so it covers "this year" too.
|
|
||||||
const from = zonedInputToIso(`${months[0]}-01T00:00`, timeZone);
|
|
||||||
const monthStart = zonedInputToIso(`${thisMonth}-01T00:00`, timeZone);
|
|
||||||
const monthEnd = zonedInputToIso(`${shiftMonth(thisMonth, 1)}-01T00:00`, timeZone);
|
|
||||||
const attentionUntil = nowMs + ATTENTION_DAYS * DAY_MS;
|
|
||||||
|
|
||||||
const [orders, lines, slotDetails, passes] = await Promise.all([
|
|
||||||
// Every paid order, so "new customer" means first order ever.
|
|
||||||
pb
|
|
||||||
.collection('orders')
|
|
||||||
.getFullList({ filter: "status = 'paid'", fields: 'id,email,total,created,customerDetails,emailError', requestKey: null })
|
|
||||||
.catch(() => []),
|
|
||||||
pb
|
|
||||||
.collection('order_lines')
|
|
||||||
.getFullList({
|
|
||||||
filter: pb.filter("order.status = 'paid' && (order.created >= {:from} || start >= {:from})", { from }),
|
|
||||||
sort: 'start',
|
|
||||||
expand: 'order',
|
|
||||||
fields: 'item,name,price,quantity,lineType,start,minutes,expand.order.created,expand.order.customerDetails',
|
|
||||||
requestKey: null
|
|
||||||
})
|
|
||||||
.catch(() => []),
|
|
||||||
loadSlotDetails(pb, { from: monthStart, to: new Date(Math.max(toMs(monthEnd), attentionUntil)).toISOString() }).catch(() => null),
|
|
||||||
listPasses(pb, '').catch(() => [])
|
|
||||||
]);
|
|
||||||
|
|
||||||
const monthOf = (value: unknown) => zonedDateKey(String(value || ''), timeZone).slice(0, 7);
|
|
||||||
const byMonth = new Map<string, DashboardMonth>(months.map((month) => [month, { month, income: 0, orders: 0, minutes: 0 }]));
|
|
||||||
|
|
||||||
// ── Income and customers ───────────────────────────────────────────
|
|
||||||
// Orders from before `created` existed have no date: they count as
|
|
||||||
// "earlier" (so their customers are returning), never as this month.
|
|
||||||
const firstOrder = new Map<string, number>();
|
|
||||||
const regulars = new Map<string, Regular>();
|
|
||||||
for (const order of [...orders].sort((a, b) => (toMs(a.created) || 0) - (toMs(b.created) || 0))) {
|
|
||||||
const created = toMs(order.created);
|
|
||||||
const month = Number.isNaN(created) ? '' : monthOf(order.created);
|
|
||||||
const row = byMonth.get(month);
|
|
||||||
if (row) {
|
|
||||||
row.income += Number(order.total) || 0;
|
|
||||||
row.orders += 1;
|
|
||||||
}
|
|
||||||
// Anonymised orders have no email: they're nobody's history any more.
|
|
||||||
const email = String(order.email || '').trim().toLowerCase();
|
|
||||||
if (!email) continue;
|
|
||||||
if (!firstOrder.has(email)) firstOrder.set(email, Number.isNaN(created) ? 0 : created);
|
|
||||||
if (row) {
|
|
||||||
const regular = regulars.get(email) ?? { name: '', orders: 0, spent: 0 };
|
|
||||||
regular.name = String(order.customerDetails?.name || '') || regular.name || email;
|
|
||||||
regular.orders += 1;
|
|
||||||
regular.spent += Number(order.total) || 0;
|
|
||||||
regulars.set(email, regular);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let newCustomers = 0;
|
|
||||||
let returningCustomers = 0;
|
|
||||||
const seenThisMonth = new Set<string>();
|
|
||||||
for (const order of orders) {
|
|
||||||
const email = String(order.email || '').trim().toLowerCase();
|
|
||||||
if (!email || seenThisMonth.has(email) || Number.isNaN(toMs(order.created)) || monthOf(order.created) !== thisMonth) continue;
|
|
||||||
seenThisMonth.add(email);
|
|
||||||
if ((firstOrder.get(email) ?? 0) >= toMs(monthStart)) newCustomers++;
|
|
||||||
else returningCustomers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── What sells (orders paid in the 12 months) ─────────────────────────
|
|
||||||
const services = new Map<string, SalesRow>();
|
|
||||||
const lengths = new Map<string, SalesRow>();
|
|
||||||
for (const line of lines) {
|
|
||||||
const created = line.expand?.order?.created;
|
|
||||||
if (!byMonth.has(monthOf(created))) continue;
|
|
||||||
const quantity = Number(line.quantity) || 1;
|
|
||||||
const income = (Number(line.price) || 0) * quantity;
|
|
||||||
const name = String(line.name || '');
|
|
||||||
const service = services.get(line.item) ?? { name, minutes: 0, count: 0, income: 0 };
|
|
||||||
service.count += quantity;
|
|
||||||
service.income += income;
|
|
||||||
services.set(line.item, service);
|
|
||||||
if (line.lineType === 'slot' && line.minutes) {
|
|
||||||
const key = `${line.item}:${line.minutes}`;
|
|
||||||
const length = lengths.get(key) ?? { name, minutes: Number(line.minutes), count: 0, income: 0 };
|
|
||||||
length.count += quantity;
|
|
||||||
length.income += income;
|
|
||||||
lengths.set(key, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Products inside a bundle are lines at price 0: the bundle line has the money.
|
|
||||||
const sales = topWithOther([...services.values()].filter((row) => row.income > 0), 'Everything else');
|
|
||||||
const topLengths = [...lengths.values()].sort((a, b) => b.count - a.count || b.income - a.income).slice(0, TOP_LIST);
|
|
||||||
|
|
||||||
// ── Hours ────────────────────────────────────────────────────────────
|
|
||||||
const bookings = mergeIntervals(
|
|
||||||
lines
|
|
||||||
.filter((line) => line.lineType === 'slot' && Number(line.minutes) > 0 && !Number.isNaN(toMs(line.start)))
|
|
||||||
.map((line) => ({ start: toMs(line.start), end: toMs(line.start) + Number(line.minutes) * 60_000 }))
|
|
||||||
);
|
|
||||||
for (const { start, end } of bookings) {
|
|
||||||
const row = byMonth.get(monthOf(new Date(start).toISOString()));
|
|
||||||
if (row) row.minutes += (end - start) / 60_000;
|
|
||||||
}
|
|
||||||
const minutesDoneThisMonth = minutesBetween(bookings, toMs(monthStart), Math.min(nowMs, toMs(monthEnd)));
|
|
||||||
const minutesAheadThisMonth = minutesBetween(bookings, nowMs, toMs(monthEnd));
|
|
||||||
|
|
||||||
const upcomingUntil = nowMs + UPCOMING_DAYS * DAY_MS;
|
|
||||||
const upcoming: UpcomingBooking[] = lines
|
|
||||||
.filter((line) => {
|
|
||||||
if (line.lineType !== 'slot') return false;
|
|
||||||
const start = toMs(line.start);
|
|
||||||
return start + (Number(line.minutes) || 0) * 60_000 > nowMs && start < upcomingUntil;
|
|
||||||
})
|
|
||||||
.map((line) => ({
|
|
||||||
start: String(line.start),
|
|
||||||
minutes: Number(line.minutes) || 0,
|
|
||||||
name: String(line.name || ''),
|
|
||||||
customer: String(line.expand?.order?.customerDetails?.name || ''),
|
|
||||||
quantity: Number(line.quantity) || 1
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Opened time this month (overlapping slots counted once) vs. booked time in it.
|
|
||||||
const slots = slotDetails?.slots ?? [];
|
|
||||||
const opened = mergeIntervals(slots.map((slot) => ({ start: toMs(slot.start), end: toMs(slot.end) })).filter((i) => !Number.isNaN(i.start)));
|
|
||||||
const openMinutes = minutesBetween(opened, toMs(monthStart), toMs(monthEnd));
|
|
||||||
const bookedInMonth = minutesBetween(bookings, toMs(monthStart), toMs(monthEnd));
|
|
||||||
|
|
||||||
// ── Vouchers and codes ───────────────────────────────────────────────
|
|
||||||
// What's owed: the unbooked share of each usable code's value.
|
|
||||||
let codesOutstanding = 0;
|
|
||||||
let valueOutstanding = 0;
|
|
||||||
const attention: Attention[] = [];
|
|
||||||
for (const pass of passes) {
|
|
||||||
const expires = pass.expiresAt ? toMs(pass.expiresAt) : Infinity;
|
|
||||||
if (pass.status !== 'active' || expires <= nowMs) continue;
|
|
||||||
const open = pass.parts.filter((part) => part.redeemable && part.left > 0);
|
|
||||||
if (!open.length) continue;
|
|
||||||
codesOutstanding++;
|
|
||||||
valueOutstanding += open.reduce((total, part) => total + (part.count ? (part.value * part.left) / part.count : 0), 0);
|
|
||||||
if (expires <= attentionUntil) {
|
|
||||||
attention.push({ kind: 'code', code: pass.code, name: pass.name, expiresAt: pass.expiresAt, left: open.reduce((n, part) => n + part.left, 0) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Needs attention ──────────────────────────────────────────────────
|
|
||||||
for (const order of orders) {
|
|
||||||
if (order.emailError) {
|
|
||||||
attention.push({ kind: 'email', orderId: order.id, customer: String(order.customerDetails?.name || order.email || 'A customer'), created: String(order.created || '') });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const slot of slots) {
|
|
||||||
if (slot.kind !== 'session' || !slot.capacity || toMs(slot.start) <= nowMs || toMs(slot.start) > attentionUntil) continue;
|
|
||||||
const taken = seatsTaken(slot);
|
|
||||||
if (taken < slot.capacity && (taken >= slot.capacity * NEARLY_FULL_SHARE || slot.capacity - taken === 1)) {
|
|
||||||
attention.push({ kind: 'session', start: slot.start, name: slot.itemNames.join(', '), taken, capacity: slot.capacity });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const year = thisMonth.slice(0, 4);
|
|
||||||
const monthRows = months.map((month) => byMonth.get(month)!);
|
|
||||||
return {
|
|
||||||
thisMonth: byMonth.get(thisMonth)!,
|
|
||||||
lastMonth: byMonth.get(shiftMonth(thisMonth, -1))!,
|
|
||||||
incomeThisYear: monthRows.filter((row) => row.month.startsWith(year)).reduce((total, row) => total + row.income, 0),
|
|
||||||
minutesDoneThisMonth: Math.round(minutesDoneThisMonth),
|
|
||||||
minutesAheadThisMonth: Math.round(minutesAheadThisMonth),
|
|
||||||
// null when nothing is opened (or slots couldn't be read): no percentage to show.
|
|
||||||
utilisation: openMinutes > 0 && slotDetails ? { booked: Math.round(bookedInMonth), open: Math.round(openMinutes) } : null,
|
|
||||||
upcomingDays: UPCOMING_DAYS,
|
|
||||||
upcoming,
|
|
||||||
upcomingMinutes: Math.round(minutesBetween(bookings, nowMs, upcomingUntil)),
|
|
||||||
newCustomers,
|
|
||||||
returningCustomers,
|
|
||||||
regulars: [...regulars.values()]
|
|
||||||
.filter((regular) => regular.orders > 1)
|
|
||||||
.sort((a, b) => b.orders - a.orders || b.spent - a.spent)
|
|
||||||
.slice(0, TOP_LIST),
|
|
||||||
sales,
|
|
||||||
lengths: topLengths,
|
|
||||||
codesOutstanding,
|
|
||||||
valueOutstanding,
|
|
||||||
attentionDays: ATTENTION_DAYS,
|
|
||||||
attention,
|
|
||||||
// Oldest first: the chart reads left to right.
|
|
||||||
months: monthRows
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { env } from '$env/dynamic/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { defaultColors, defaultStyle } from '$lib/types';
|
import { defaultColors } from '$lib/types';
|
||||||
import { shopCurrency } from '$shared/calendar';
|
import { shopCurrency } from '$shared/calendar';
|
||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
|
|
||||||
|
|
@ -13,16 +13,13 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const load: LayoutServerLoad = async ({ locals }) => {
|
export const load: LayoutServerLoad = async ({ locals }) => {
|
||||||
const [colors, header, style] = await Promise.all([
|
const [colors, header] = await Promise.all([
|
||||||
getGlobal(locals.pb, 'colors', defaultColors),
|
getGlobal(locals.pb, 'colors', defaultColors),
|
||||||
getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }>,
|
getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }>
|
||||||
// Only /preview uses it: the admin's own pages keep their look.
|
|
||||||
getGlobal(locals.pb, 'style', defaultStyle)
|
|
||||||
]);
|
]);
|
||||||
return {
|
return {
|
||||||
user: locals.user,
|
user: locals.user,
|
||||||
colors,
|
colors,
|
||||||
style,
|
|
||||||
// The site's logo is the admin's tab icon too (same as the public site).
|
// The site's logo is the admin's tab icon too (same as the public site).
|
||||||
logoUrl: header?.logo?.url || '',
|
logoUrl: header?.logo?.url || '',
|
||||||
// Admin dates/times are entered and shown in the site's timezone, and
|
// Admin dates/times are entered and shown in the site's timezone, and
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
import '$lib/fonts';
|
// Fonts are bundled and served by this app, not loaded from Google: a
|
||||||
|
// Google Fonts request sends every visitor's IP address to Google (GDPR).
|
||||||
|
import '@fontsource/dm-sans/400.css';
|
||||||
|
import '@fontsource/dm-sans/500.css';
|
||||||
|
import '@fontsource/dm-sans/600.css';
|
||||||
|
import '@fontsource/dm-sans/700.css';
|
||||||
|
import '@fontsource/playfair-display/600.css';
|
||||||
|
import '@fontsource/playfair-display/700.css';
|
||||||
import favicon from '$lib/assets/favicon.svg';
|
import favicon from '$lib/assets/favicon.svg';
|
||||||
import { afterNavigate } from '$app/navigation';
|
import { afterNavigate } from '$app/navigation';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
|
|
@ -22,10 +29,6 @@
|
||||||
// Sidebar navigation, grouped by what the studio is doing. Labels are
|
// Sidebar navigation, grouped by what the studio is doing. Labels are
|
||||||
// user-facing names; hrefs keep the original route names.
|
// user-facing names; hrefs keep the original route names.
|
||||||
const navGroups = [
|
const navGroups = [
|
||||||
{
|
|
||||||
title: 'Studio',
|
|
||||||
links: [{ href: '/', label: 'Dashboard' }]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Website',
|
title: 'Website',
|
||||||
links: [
|
links: [
|
||||||
|
|
@ -84,7 +87,7 @@
|
||||||
<label for="admin-nav" class="btn btn-square btn-ghost" aria-label="Open menu">
|
<label for="admin-nav" class="btn btn-square btn-ghost" aria-label="Open menu">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="size-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" /></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" class="size-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" /></svg>
|
||||||
</label>
|
</label>
|
||||||
<a class="ml-1 text-lg font-bold tracking-tight" href="/">Massage CMS</a>
|
<a class="ml-1 text-lg font-bold tracking-tight" href="/pages">Massage CMS</a>
|
||||||
</header>
|
</header>
|
||||||
<main class="mx-auto w-full max-w-7xl flex-1 p-4 md:p-8">
|
<main class="mx-auto w-full max-w-7xl flex-1 p-4 md:p-8">
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|
@ -94,7 +97,7 @@
|
||||||
<div class="drawer-side z-40">
|
<div class="drawer-side z-40">
|
||||||
<label for="admin-nav" class="drawer-overlay" aria-label="Close menu"></label>
|
<label for="admin-nav" class="drawer-overlay" aria-label="Close menu"></label>
|
||||||
<aside class="flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100">
|
<aside class="flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100">
|
||||||
<a class="block px-6 pt-6 pb-4 text-lg font-bold tracking-tight" href="/">Massage CMS</a>
|
<a class="block px-6 pt-6 pb-4 text-lg font-bold tracking-tight" href="/pages">Massage CMS</a>
|
||||||
<nav class="flex-1" aria-label="Main">
|
<nav class="flex-1" aria-label="Main">
|
||||||
<ul class="menu w-full gap-0.5 px-3">
|
<ul class="menu w-full gap-0.5 px-3">
|
||||||
{#each navGroups as group (group.title)}
|
{#each navGroups as group (group.title)}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
import { env } from '$env/dynamic/private';
|
|
||||||
import { loadDashboard } from '$lib/server/dashboard';
|
|
||||||
import type { PageServerLoad } from './$types';
|
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals }) => ({
|
|
||||||
dashboard: await loadDashboard(locals.pb, env.SITE_TIMEZONE || 'Europe/Oslo')
|
|
||||||
});
|
|
||||||
|
|
@ -1,215 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import IncomeChart from '$lib/admin/IncomeChart.svelte';
|
|
||||||
import { DISPLAY_LOCALE, formatDateTime, formatInstant, formatPrice, zonedDateKey } from '$lib/calendar';
|
|
||||||
import { formatDuration } from '$shared/items';
|
|
||||||
|
|
||||||
let { data } = $props();
|
|
||||||
let dashboard = $derived(data.dashboard);
|
|
||||||
|
|
||||||
const hoursFormat = new Intl.NumberFormat(DISPLAY_LOCALE, { maximumFractionDigits: 1 });
|
|
||||||
const hours = (minutes: number) => `${hoursFormat.format(minutes / 60)} h`;
|
|
||||||
const money = (amount: number) => formatPrice(amount, data.currency);
|
|
||||||
// Whole units for the chart axis; falls back to the full price if the currency code is unknown.
|
|
||||||
const roundMoney = (amount: number) => {
|
|
||||||
try {
|
|
||||||
return new Intl.NumberFormat(DISPLAY_LOCALE, { style: 'currency', currency: data.currency, maximumFractionDigits: 0 }).format(amount);
|
|
||||||
} catch {
|
|
||||||
return money(amount);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Mid-month noon UTC is inside the same month in every timezone.
|
|
||||||
const monthLabel = (month: string, options: Intl.DateTimeFormatOptions = { month: 'long', year: 'numeric' }) =>
|
|
||||||
formatInstant(`${month}-15T12:00:00Z`, data.timezone, options);
|
|
||||||
const dayLabel = (value: string) => formatInstant(value, data.timezone, { weekday: 'long', day: 'numeric', month: 'short' });
|
|
||||||
const timeLabel = (value: string) => formatInstant(value, data.timezone, { hour: '2-digit', minute: '2-digit' });
|
|
||||||
|
|
||||||
let thisMonthName = $derived(monthLabel(dashboard.thisMonth.month, { month: 'long' }));
|
|
||||||
let incomeChange = $derived(dashboard.thisMonth.income - dashboard.lastMonth.income);
|
|
||||||
let chartMonths = $derived(dashboard.months.map((m) => ({ ...m, label: monthLabel(m.month, { month: 'short' }), name: monthLabel(m.month) })));
|
|
||||||
let utilisationPercent = $derived(dashboard.utilisation ? Math.round((dashboard.utilisation.booked / dashboard.utilisation.open) * 100) : null);
|
|
||||||
let todayKey = $derived(zonedDateKey(new Date().toISOString(), data.timezone));
|
|
||||||
// Coming up, one group per day (bookings arrive sorted by start).
|
|
||||||
let upcomingDays = $derived.by(() => {
|
|
||||||
const days: { key: string; label: string; bookings: typeof dashboard.upcoming }[] = [];
|
|
||||||
for (const booking of dashboard.upcoming) {
|
|
||||||
const key = zonedDateKey(booking.start, data.timezone);
|
|
||||||
if (days.at(-1)?.key !== key) days.push({ key, label: dayLabel(booking.start), bookings: [] });
|
|
||||||
days.at(-1)!.bookings.push(booking);
|
|
||||||
}
|
|
||||||
return days;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<svelte:head><title>Dashboard | CMS</title></svelte:head>
|
|
||||||
|
|
||||||
{#snippet tile(label: string, value: string, note: string)}
|
|
||||||
<div class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<p class="text-sm text-base-content/60">{label}</p>
|
|
||||||
<p class="mt-1 text-2xl font-bold tabular-nums sm:text-3xl">{value}</p>
|
|
||||||
<p class="mt-1 text-sm text-base-content/60">{note}</p>
|
|
||||||
</div>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet salesTable(rows: typeof dashboard.sales, nameOf: (row: (typeof dashboard.sales)[number]) => string, empty: string)}
|
|
||||||
{#if rows.length}
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead><tr><th></th><th class="text-right">Sold</th><th class="text-right">Income</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{#each rows as row, i (i)}
|
|
||||||
<tr><td>{nameOf(row)}</td><td class="text-right tabular-nums">{row.count}</td><td class="text-right tabular-nums">{money(row.income)}</td></tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{:else}
|
|
||||||
<p class="text-base-content/60">{empty}</p>
|
|
||||||
{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<div class="mb-6">
|
|
||||||
<h1 class="text-3xl font-bold">Dashboard</h1>
|
|
||||||
<p class="text-base-content/60">How the studio is doing. Income is paid orders, in the month they were paid; hours are booked appointment time, with group sessions counted once.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- What's next and what needs doing first; the figures follow. -->
|
|
||||||
<div class="grid gap-6 xl:grid-cols-2">
|
|
||||||
<section class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<div class="mb-3 flex flex-wrap items-baseline justify-between gap-x-4">
|
|
||||||
<h2 class="text-2xl font-bold">Coming up</h2>
|
|
||||||
<p class="text-sm text-base-content/60">
|
|
||||||
Next {dashboard.upcomingDays} days: {dashboard.upcoming.length} {dashboard.upcoming.length === 1 ? 'booking' : 'bookings'}, {hours(dashboard.upcomingMinutes)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{#if upcomingDays.length}
|
|
||||||
<div class="space-y-4">
|
|
||||||
{#each upcomingDays as day (day.key)}
|
|
||||||
<div>
|
|
||||||
<h3 class="mb-1 text-sm font-semibold">{day.key === todayKey ? 'Today' : day.label}</h3>
|
|
||||||
<ul class="divide-y divide-base-300 rounded-box bg-base-200/60 px-3">
|
|
||||||
{#each day.bookings as booking, i (i)}
|
|
||||||
<li class="flex gap-3 py-2">
|
|
||||||
<span class="w-14 shrink-0 font-semibold tabular-nums">{timeLabel(booking.start)}</span>
|
|
||||||
<span class="min-w-0 flex-1">
|
|
||||||
<span class="block">{booking.name}{#if booking.quantity > 1}<span class="text-base-content/60"> × {booking.quantity}</span>{/if}</span>
|
|
||||||
<span class="block text-sm text-base-content/60">{formatDuration(booking.minutes)}{#if booking.customer} · {booking.customer}{/if}</span>
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<p class="text-base-content/60">Nothing booked in the next {dashboard.upcomingDays} days.</p>
|
|
||||||
{/if}
|
|
||||||
<a class="btn btn-sm mt-4" href="/orders">All orders</a>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<div class="mb-3 flex flex-wrap items-baseline justify-between gap-x-4">
|
|
||||||
<h2 class="text-2xl font-bold">Needs attention</h2>
|
|
||||||
<p class="text-sm text-base-content/60">Sessions and codes: next {dashboard.attentionDays} days</p>
|
|
||||||
</div>
|
|
||||||
{#if dashboard.attention.length}
|
|
||||||
<ul class="divide-y divide-base-300">
|
|
||||||
{#each dashboard.attention as item, i (i)}
|
|
||||||
<li class="flex flex-wrap items-center gap-x-3 gap-y-1 py-2">
|
|
||||||
{#if item.kind === 'email'}
|
|
||||||
<span class="badge badge-warning badge-sm">⚠ Email failed</span>
|
|
||||||
<span class="order-last basis-full">Booking email for {item.customer}{#if item.created}<span class="text-base-content/60"> · ordered {formatDateTime(item.created, data.timezone)}</span>{/if}</span>
|
|
||||||
<a class="btn btn-ghost btn-xs ml-auto" href="/orders">Resend in Orders</a>
|
|
||||||
{:else if item.kind === 'session'}
|
|
||||||
<span class="badge badge-info badge-sm">◔ Nearly full</span>
|
|
||||||
<span class="order-last basis-full">{item.name || 'Group session'} · {formatDateTime(item.start, data.timezone)}<span class="text-base-content/60"> · {item.taken} of {item.capacity} places taken</span></span>
|
|
||||||
<a class="btn btn-ghost btn-xs ml-auto" href="/slots">Slots</a>
|
|
||||||
{:else}
|
|
||||||
<span class="badge badge-sm">⏱ Expires soon</span>
|
|
||||||
<span class="order-last basis-full">{item.code} ({item.name}) · {item.left} {item.left === 1 ? 'session' : 'sessions'} left<span class="text-base-content/60"> · expires {formatDateTime(item.expiresAt, data.timezone)}</span></span>
|
|
||||||
<a class="btn btn-ghost btn-xs ml-auto" href="/passes?q={encodeURIComponent(item.code)}">Vouchers & codes</a>
|
|
||||||
{/if}
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
{:else}
|
|
||||||
<p class="text-base-content/60">✓ All clear: no failed emails, nearly full sessions or codes about to expire.</p>
|
|
||||||
{/if}
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-6 grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4">
|
|
||||||
{@render tile(`Income in ${thisMonthName}`, money(dashboard.thisMonth.income), `${incomeChange >= 0 ? '+' : '−'}${money(Math.abs(incomeChange))} on ${monthLabel(dashboard.lastMonth.month, { month: 'long' })}`)}
|
|
||||||
{@render tile(`Hours worked in ${thisMonthName}`, hours(dashboard.minutesDoneThisMonth), `${hours(dashboard.minutesAheadThisMonth)} still booked`)}
|
|
||||||
{@render tile(
|
|
||||||
'Opened time booked',
|
|
||||||
utilisationPercent === null ? '—' : `${utilisationPercent} %`,
|
|
||||||
dashboard.utilisation ? `${hours(dashboard.utilisation.booked)} of ${hours(dashboard.utilisation.open)} in Slots this month` : 'No slots opened this month'
|
|
||||||
)}
|
|
||||||
{@render tile('Codes owed', money(dashboard.valueOutstanding), `${dashboard.codesOutstanding} ${dashboard.codesOutstanding === 1 ? 'code' : 'codes'} with sessions to book`)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section class="mt-6 rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<div class="mb-4 flex flex-wrap items-end justify-between gap-x-6 gap-y-2">
|
|
||||||
<div>
|
|
||||||
<h2 class="text-2xl font-bold">Income</h2>
|
|
||||||
<p class="text-sm text-base-content/60">Per month, last {dashboard.months.length} months</p>
|
|
||||||
</div>
|
|
||||||
<div class="sm:text-right">
|
|
||||||
<p class="text-sm text-base-content/60">Income in {dashboard.thisMonth.month.slice(0, 4)}</p>
|
|
||||||
<p class="text-2xl font-bold tabular-nums sm:text-3xl">{money(dashboard.incomeThisYear)}</p>
|
|
||||||
<p class="text-sm text-base-content/60">
|
|
||||||
{dashboard.thisMonth.orders} {dashboard.thisMonth.orders === 1 ? 'order' : 'orders'} this month{#if dashboard.thisMonth.orders}, {money(dashboard.thisMonth.income / dashboard.thisMonth.orders)} on average{/if}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<IncomeChart months={chartMonths} format={money} tickFormat={roundMoney} current={dashboard.thisMonth.month} />
|
|
||||||
<details class="mt-2">
|
|
||||||
<summary class="cursor-pointer text-sm font-medium">Show as table</summary>
|
|
||||||
<div class="mt-2 overflow-x-auto">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr><th>Month</th><th class="text-right">Orders</th><th class="text-right">Income</th><th class="text-right">Hours</th></tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{#each [...dashboard.months].reverse() as row (row.month)}
|
|
||||||
<tr class={row.month === dashboard.thisMonth.month ? 'bg-primary/10' : ''}>
|
|
||||||
<td>{monthLabel(row.month, { month: 'short', year: 'numeric' })}</td>
|
|
||||||
<td class="text-right tabular-nums">{row.orders}</td>
|
|
||||||
<td class="text-right tabular-nums">{money(row.income)}</td>
|
|
||||||
<td class="text-right tabular-nums">{hours(row.minutes)}</td>
|
|
||||||
</tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="mt-6 grid gap-6 lg:grid-cols-2 xl:grid-cols-3">
|
|
||||||
<section class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<h2 class="mb-1 text-2xl font-bold">Customers</h2>
|
|
||||||
<p class="mb-3 text-sm text-base-content/60">
|
|
||||||
{dashboard.newCustomers + dashboard.returningCustomers} in {thisMonthName}: {dashboard.newCustomers} new, {dashboard.returningCustomers} returning
|
|
||||||
</p>
|
|
||||||
<h3 class="font-semibold">Regulars</h3>
|
|
||||||
{#if dashboard.regulars.length}
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead><tr><th></th><th class="text-right">Orders</th><th class="text-right">Spent</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{#each dashboard.regulars as regular, i (i)}
|
|
||||||
<tr><td>{regular.name}</td><td class="text-right tabular-nums">{regular.orders}</td><td class="text-right tabular-nums">{money(regular.spent)}</td></tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{:else}
|
|
||||||
<p class="text-base-content/60">Nobody has ordered more than once yet.</p>
|
|
||||||
{/if}
|
|
||||||
</section>
|
|
||||||
<section class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<h2 class="mb-3 text-2xl font-bold">What sells</h2>
|
|
||||||
{@render salesTable(dashboard.sales, (row) => row.name, 'Nothing sold yet.')}
|
|
||||||
</section>
|
|
||||||
<section class="rounded-box bg-base-100 p-4 shadow sm:p-5">
|
|
||||||
<h2 class="mb-3 text-2xl font-bold">Popular lengths</h2>
|
|
||||||
{@render salesTable(dashboard.lengths, (row) => `${row.name} · ${formatDuration(row.minutes)}`, 'No bookings yet.')}
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<p class="mt-2 text-sm text-base-content/60">Regulars, what sells and popular lengths cover the last {dashboard.months.length} months.</p>
|
|
||||||
|
|
@ -100,25 +100,24 @@
|
||||||
{#if form?.message}<div class="alert alert-error" role="alert">{form.message}</div>{/if}
|
{#if form?.message}<div class="alert alert-error" role="alert">{form.message}</div>{/if}
|
||||||
|
|
||||||
<div class="rounded-box bg-base-100 p-5 shadow">
|
<div class="rounded-box bg-base-100 p-5 shadow">
|
||||||
<div class="mb-4 flex items-center justify-between gap-2">
|
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||||
<button class="btn btn-outline btn-sm" type="button" aria-label="Previous month" onclick={previousMonth}>←<span class="hidden sm:inline"> Previous</span></button>
|
<button class="btn btn-outline btn-sm" type="button" onclick={previousMonth}>← Previous</button>
|
||||||
<h2 class="text-center text-xl font-bold sm:text-2xl">{month.label}</h2>
|
<h2 class="text-2xl font-bold">{month.label}</h2>
|
||||||
<button class="btn btn-outline btn-sm" type="button" aria-label="Next month" onclick={nextMonth}><span class="hidden sm:inline">Next </span>→</button>
|
<button class="btn btn-outline btn-sm" type="button" onclick={nextMonth}>Next →</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-7 gap-1 text-center text-xs font-semibold uppercase text-base-content/50 sm:gap-2">
|
<div class="grid grid-cols-7 gap-2 text-center text-xs font-semibold uppercase text-base-content/50">
|
||||||
{#each weekdays as weekday}<div>{weekday}</div>{/each}
|
{#each weekdays as weekday}<div>{weekday}</div>{/each}
|
||||||
</div>
|
</div>
|
||||||
<!-- On a phone the days only show coloured bars (tap one to edit); the list below names them. -->
|
<div class="mt-2 grid grid-cols-7 gap-2">
|
||||||
<div class="mt-2 grid grid-cols-7 gap-1 sm:gap-2">
|
|
||||||
{#each month.days as day}
|
{#each month.days as day}
|
||||||
<div class="min-h-16 rounded-box border border-base-300 bg-base-200/60 p-1 sm:min-h-32 sm:p-2" class:opacity-40={!day.inMonth}>
|
<div class="min-h-32 rounded-box border border-base-300 bg-base-200/60 p-2" class:opacity-40={!day.inMonth}>
|
||||||
<button class="btn btn-circle btn-xs mb-1 {day.isToday ? 'btn-primary' : 'btn-ghost'}" type="button" title="Create an event on this day" aria-current={day.isToday ? 'date' : undefined} onclick={() => createEvent(day.dateKey)}>{day.dayNumber}</button>
|
<button class="btn btn-circle btn-xs mb-1 {day.isToday ? 'btn-primary' : 'btn-ghost'}" type="button" title="Create an event on this day" aria-current={day.isToday ? 'date' : undefined} onclick={() => createEvent(day.dateKey)}>{day.dayNumber}</button>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
{#each eventsForDay(day.date) as event}
|
{#each eventsForDay(day.date) as event}
|
||||||
<button class="block h-3 w-full rounded-lg text-left text-xs font-semibold text-white shadow sm:h-auto sm:px-2 sm:py-1" style={`background:${event.color || '#8a9a7b'}`} type="button" title={event.name} aria-label="Edit {event.name}" onclick={() => editEvent(event)}>
|
<button class="w-full rounded-lg px-2 py-1 text-left text-xs font-semibold text-white shadow" style={`background:${event.color || '#8a9a7b'}`} type="button" onclick={() => editEvent(event)}>
|
||||||
<span class="hidden truncate sm:block">{event.name}</span>
|
<span class="block truncate">{event.name}</span>
|
||||||
<span class="hidden truncate text-[0.65rem] opacity-80 sm:block">{formatEventDateRange(event)}</span>
|
<span class="block truncate text-[0.65rem] opacity-80">{formatEventDateRange(event)}</span>
|
||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -131,16 +130,13 @@
|
||||||
<h2 class="mb-4 text-xl font-bold">All events</h2>
|
<h2 class="mb-4 text-xl font-bold">All events</h2>
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr><th>Name</th><th class="hidden sm:table-cell">Date</th><th class="hidden md:table-cell">Categories</th><th>Status</th><th></th></tr></thead>
|
<thead><tr><th>Name</th><th>Date</th><th>Categories</th><th>Status</th><th></th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each events as event (event.id)}
|
{#each events as event (event.id)}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td><span class="mr-2 inline-block h-3 w-3 rounded-full" style={`background:${event.color}`}></span>{event.name}</td>
|
||||||
<span class="mr-2 inline-block h-3 w-3 rounded-full" style={`background:${event.color}`}></span>{event.name}
|
<td>{formatEventDateRange(event)}</td>
|
||||||
<span class="block text-xs text-base-content/60 sm:hidden">{formatEventDateRange(event)}</span>
|
<td>{event.categories.join(', ')}</td>
|
||||||
</td>
|
|
||||||
<td class="hidden whitespace-nowrap sm:table-cell">{formatEventDateRange(event)}</td>
|
|
||||||
<td class="hidden md:table-cell">{event.categories.join(', ')}</td>
|
|
||||||
<td><span class="badge" class:badge-success={event.published}>{event.published ? 'Published' : 'Draft'}</span></td>
|
<td><span class="badge" class:badge-success={event.published}>{event.published ? 'Published' : 'Draft'}</span></td>
|
||||||
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => editEvent(event)}>Edit</button></td>
|
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => editEvent(event)}>Edit</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ import { fail, redirect } from '@sveltejs/kit';
|
||||||
import { ClientResponseError } from 'pocketbase';
|
import { ClientResponseError } from 'pocketbase';
|
||||||
import { PRIVACY_PAGE_SLUG, privacyTemplateHtml } from '$lib/admin/privacyTemplate';
|
import { PRIVACY_PAGE_SLUG, privacyTemplateHtml } from '$lib/admin/privacyTemplate';
|
||||||
import { attempt } from '$lib/server/actions';
|
import { attempt } from '$lib/server/actions';
|
||||||
import { defaultColors, defaultFooter, defaultHeader, defaultStyle } from '$lib/types';
|
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||||
import type { Actions, PageServerLoad } from './$types';
|
import type { Actions, PageServerLoad } from './$types';
|
||||||
|
|
||||||
const SECTIONS = ['header', 'footer', 'colors', 'style'] as const;
|
const SECTIONS = ['header', 'footer', 'colors'] as const;
|
||||||
|
|
||||||
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -21,11 +21,10 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals }) => {
|
export const load: PageServerLoad = async ({ locals }) => {
|
||||||
const [header, footer, colors, style] = await Promise.all([
|
const [header, footer, colors] = await Promise.all([
|
||||||
getGlobal(locals.pb, 'header', defaultHeader),
|
getGlobal(locals.pb, 'header', defaultHeader),
|
||||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||||
getGlobal(locals.pb, 'colors', defaultColors),
|
getGlobal(locals.pb, 'colors', defaultColors)
|
||||||
getGlobal(locals.pb, 'style', defaultStyle)
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// All pages for the page selectors, with what the basket setting warns
|
// All pages for the page selectors, with what the basket setting warns
|
||||||
|
|
@ -36,7 +35,7 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||||
return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasCheckout: types.has('checkout') };
|
return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasCheckout: types.has('checkout') };
|
||||||
});
|
});
|
||||||
|
|
||||||
return { header, footer, colors, style, pages };
|
return { header, footer, colors, pages };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,14 @@
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import { fly, slide } from 'svelte/transition';
|
import { fly, slide } from 'svelte/transition';
|
||||||
import ImagePicker from '$lib/admin/editors/ImagePicker.svelte';
|
import ImagePicker from '$lib/admin/editors/ImagePicker.svelte';
|
||||||
import SegmentedControl from '$lib/admin/editors/SegmentedControl.svelte';
|
|
||||||
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
||||||
import { defaultStyle, shopLinks } from '$lib/types';
|
import { shopLinks } from '$lib/types';
|
||||||
import { SITE_FONTS, readableTextOn, siteStyleVars } from '$shared/theme';
|
|
||||||
import type { SubmitFunction } from '@sveltejs/kit';
|
import type { SubmitFunction } from '@sveltejs/kit';
|
||||||
|
|
||||||
let { data, form } = $props();
|
let { data, form } = $props();
|
||||||
let header = $state(structuredClone(data.header.data));
|
let header = $state(structuredClone(data.header.data));
|
||||||
let footer = $state(structuredClone(data.footer.data));
|
let footer = $state(structuredClone(data.footer.data));
|
||||||
let colors = $state(structuredClone(data.colors.data));
|
let colors = $state(structuredClone(data.colors.data));
|
||||||
let style = $state({ ...defaultStyle, ...data.style.data });
|
|
||||||
// The sample below the style settings: the variables the public site gets, as an inline style.
|
|
||||||
let styleSample = $derived(Object.entries(siteStyleVars(style)).map(([name, value]) => `${name}:${value}`).join(';'));
|
|
||||||
let saving = $state('');
|
let saving = $state('');
|
||||||
// Older records may predate the CTA button and the basket page; the inputs below need values.
|
// Older records may predate the CTA button and the basket page; the inputs below need values.
|
||||||
header.ctaButton ??= { label: '', href: '' };
|
header.ctaButton ??= { label: '', href: '' };
|
||||||
|
|
@ -101,7 +96,7 @@
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
{#snippet info(text: string)}
|
{#snippet info(text: string)}
|
||||||
<span class="tooltip tooltip-bottom sm:tooltip-right font-sans font-normal before:max-w-48" data-tip={text}>
|
<span class="tooltip tooltip-right font-sans font-normal before:max-w-48" data-tip={text}>
|
||||||
<button class="btn btn-circle btn-ghost btn-xs text-base-content/60" type="button" aria-label={text}>
|
<button class="btn btn-circle btn-ghost btn-xs text-base-content/60" type="button" aria-label={text}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||||
<circle cx="12" cy="12" r="9" /><path stroke-linecap="round" d="M12 11v5M12 8h.01" />
|
<circle cx="12" cy="12" r="9" /><path stroke-linecap="round" d="M12 11v5M12 8h.01" />
|
||||||
|
|
@ -121,10 +116,10 @@
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h1 class="text-3xl font-bold">Site design</h1>
|
<h1 class="text-3xl font-bold">Site design</h1>
|
||||||
<p class="text-base-content/60">The header, footer, colors and style shared by every page of the site.</p>
|
<p class="text-base-content/60">The header, footer and colors shared by every page of the site.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid gap-6 xl:grid-cols-2 2xl:grid-cols-4">
|
<div class="grid gap-6 xl:grid-cols-3">
|
||||||
<form class="flex flex-col rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save" use:enhance={submit}>
|
<form class="flex flex-col rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save" use:enhance={submit}>
|
||||||
<input type="hidden" name="id" value={data.header.id} />
|
<input type="hidden" name="id" value={data.header.id} />
|
||||||
<input type="hidden" name="section" value="header" />
|
<input type="hidden" name="section" value="header" />
|
||||||
|
|
@ -223,53 +218,4 @@
|
||||||
{/each}
|
{/each}
|
||||||
{@render saveButton('colors', 'Save colors')}
|
{@render saveButton('colors', 'Save colors')}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="flex flex-col rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save" use:enhance={submit}>
|
|
||||||
<input type="hidden" name="id" value={data.style.id} />
|
|
||||||
<input type="hidden" name="section" value="style" />
|
|
||||||
<input type="hidden" name="data" value={JSON.stringify(style)} />
|
|
||||||
<h2 class="mb-4 text-2xl font-bold">Style</h2>
|
|
||||||
<p class="mb-2 text-sm text-base-content/60">Fonts and shapes for the public site. The fonts come with the site, so visitors' browsers don't contact Google for them.</p>
|
|
||||||
{#snippet fontSelect(label: string, key: 'headingFont' | 'bodyFont')}
|
|
||||||
<label class="fieldset py-1">
|
|
||||||
<span class="fieldset-legend pb-0">{label}</span>
|
|
||||||
<select class="select w-full" bind:value={style[key]}>
|
|
||||||
<optgroup label="Serif">
|
|
||||||
{#each SITE_FONTS.filter((font) => font.serif) as font (font.id)}
|
|
||||||
<option value={font.id} style="font-family: '{font.family}'">{font.label}</option>
|
|
||||||
{/each}
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Sans-serif">
|
|
||||||
{#each SITE_FONTS.filter((font) => !font.serif) as font (font.id)}
|
|
||||||
<option value={font.id} style="font-family: '{font.family}'">{font.label}</option>
|
|
||||||
{/each}
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
{/snippet}
|
|
||||||
{@render fontSelect('Headings', 'headingFont')}
|
|
||||||
{@render fontSelect('Body text', 'bodyFont')}
|
|
||||||
<div class="mt-3 space-y-2">
|
|
||||||
<SegmentedControl label="Corners" options={['sharp', 'soft', 'round']} value={style.corners} onChange={(v) => (style.corners = v as typeof style.corners)} />
|
|
||||||
<SegmentedControl label="Text size" options={['small', 'normal', 'large']} value={style.textSize} onChange={(v) => (style.textSize = v as typeof style.textSize)} />
|
|
||||||
<SegmentedControl label="Shadows" options={['none', 'soft', 'strong']} value={style.shadows} onChange={(v) => (style.shadows = v as typeof style.shadows)} />
|
|
||||||
<SegmentedControl label="Page width" options={['narrow', 'normal', 'wide']} value={style.width} onChange={(v) => (style.width = v as typeof style.width)} />
|
|
||||||
</div>
|
|
||||||
<p class="mt-1 text-sm text-base-content/60">Page width is how wide text and sections may get on a big screen; phones are unaffected.</p>
|
|
||||||
|
|
||||||
<!-- How the choices look. Inline styles, because the radius and shadow tokens in app.css
|
|
||||||
are worked out once for the whole page and can't follow variables set on this box. -->
|
|
||||||
<div
|
|
||||||
class="mt-4 border border-base-300 p-4"
|
|
||||||
style="{styleSample}; background: {colors.background}; color: {colors.text}; font-family: var(--site-font-body); font-size: var(--site-text-size); border-radius: calc(1rem * var(--site-corners))"
|
|
||||||
aria-label="Style sample"
|
|
||||||
>
|
|
||||||
<p class="text-2xl font-semibold" style="font-family: var(--site-font-heading); color: {colors.heading}">A calm space for you</p>
|
|
||||||
<div class="mt-3 bg-white p-3" style="border-radius: calc(1rem * var(--site-corners)); box-shadow: 0 1px 3px 0 rgb(0 0 0 / calc(0.1 * var(--site-shadow))), 0 1px 2px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow)))">
|
|
||||||
<p>Body text looks like this. Sessions last an hour.</p>
|
|
||||||
<span class="mt-3 inline-block px-5 py-2 text-sm font-medium" style="border-radius: var(--site-button-radius); background: {colors.primary}; color: {readableTextOn(colors.primary)}">Book</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{@render saveButton('style', 'Save style')}
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ function parseDurationRows(data: FormData): ItemDuration[] | { error: string } {
|
||||||
return durations.sort((a, b) => a.minutes - b.minutes);
|
return durations.sort((a, b) => a.minutes - b.minutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Priorities go from -this to this (the field's limits in pb_schema.json). Set by dragging the list (?/reorder), never typed. */
|
|
||||||
const MAX_PRIORITY = 1000;
|
|
||||||
|
|
||||||
/** Most units of one thing a bundle can hold. */
|
/** Most units of one thing a bundle can hold. */
|
||||||
const MAX_PART_COUNT = 50;
|
const MAX_PART_COUNT = 50;
|
||||||
|
|
||||||
|
|
@ -120,14 +117,14 @@ function itemPayload(data: FormData, items: Record<string, any>[]) {
|
||||||
|
|
||||||
/** Every item, for checking what a bundle may contain. */
|
/** Every item, for checking what a bundle may contain. */
|
||||||
function allItems(pb: App.Locals['pb']) {
|
function allItems(pb: App.Locals['pb']) {
|
||||||
return pb.collection('items').getFullList({ fields: 'id,name,type,durations,priority' }).catch(() => []);
|
return pb.collection('items').getFullList({ fields: 'id,name,type,durations' }).catch(() => []);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ locals }) => {
|
export const load: PageServerLoad = async ({ locals }) => {
|
||||||
const [records, waiting] = await Promise.all([
|
const [records, waiting] = await Promise.all([
|
||||||
locals.pb
|
locals.pb
|
||||||
.collection('items')
|
.collection('items')
|
||||||
.getFullList({ sort: '-priority,name', expand: 'image' })
|
.getFullList({ sort: 'name', expand: 'image' })
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
codesWaiting(locals.pb).catch(() => ({}) as Record<string, number>)
|
codesWaiting(locals.pb).catch(() => ({}) as Record<string, number>)
|
||||||
]);
|
]);
|
||||||
|
|
@ -136,13 +133,9 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
create: async ({ request, locals }) => {
|
create: async ({ request, locals }) => {
|
||||||
const items = await allItems(locals.pb);
|
const result = itemPayload(await request.formData(), await allItems(locals.pb));
|
||||||
const result = itemPayload(await request.formData(), items);
|
|
||||||
if ('error' in result) return fail(400, { message: result.error });
|
if ('error' in result) return fail(400, { message: result.error });
|
||||||
// New items go to the end of the shop order; drag them up from there.
|
const created = await attempt('Could not create the item.', () => locals.pb.collection('items').create(result.payload));
|
||||||
const lowest = items.length ? Math.min(...items.map((item) => Number(item.priority) || 0)) : 1;
|
|
||||||
const priority = Math.max(-MAX_PRIORITY, lowest - 1);
|
|
||||||
const created = await attempt('Could not create the item.', () => locals.pb.collection('items').create({ ...result.payload, priority }));
|
|
||||||
if (!created.ok) return created.failure;
|
if (!created.ok) return created.failure;
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
},
|
},
|
||||||
|
|
@ -156,33 +149,6 @@ export const actions: Actions = {
|
||||||
if (!updated.ok) return updated.failure;
|
if (!updated.ok) return updated.failure;
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* The list's new order (`order`: JSON item ids, first = shown first) →
|
|
||||||
* priorities n…1. Only items whose priority changes are written; items
|
|
||||||
* missing from the list (added meanwhile) go after it.
|
|
||||||
*/
|
|
||||||
reorder: async ({ request, locals }) => {
|
|
||||||
let ids: unknown;
|
|
||||||
try {
|
|
||||||
ids = JSON.parse(String((await request.formData()).get('order') || '[]'));
|
|
||||||
} catch {
|
|
||||||
ids = null;
|
|
||||||
}
|
|
||||||
if (!Array.isArray(ids) || !ids.every((id) => typeof id === 'string')) return fail(400, { message: 'Could not read the new order — reload the page and try again.' });
|
|
||||||
const records = await locals.pb.collection('items').getFullList({ fields: 'id,priority', sort: '-priority,name' });
|
|
||||||
const known = new Set(records.map((record) => record.id));
|
|
||||||
const listed = [...new Set(ids as string[])].filter((id) => known.has(id));
|
|
||||||
const ordered = [...listed, ...records.map((record) => record.id).filter((id) => !listed.includes(id))];
|
|
||||||
if (ordered.length > MAX_PRIORITY) return fail(400, { message: `The order can only be set for up to ${MAX_PRIORITY} items.` });
|
|
||||||
const current = new Map(records.map((record) => [record.id, Number(record.priority) || 0]));
|
|
||||||
for (const [index, id] of ordered.entries()) {
|
|
||||||
const priority = ordered.length - index;
|
|
||||||
if (current.get(id) === priority) continue;
|
|
||||||
const saved = await attempt('Could not save the order.', () => locals.pb.collection('items').update(id, { priority }));
|
|
||||||
if (!saved.ok) return saved.failure;
|
|
||||||
}
|
|
||||||
return { ok: true, message: 'Order saved.' };
|
|
||||||
},
|
|
||||||
delete: async ({ request, locals }) => {
|
delete: async ({ request, locals }) => {
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
const id = String(data.get('id') || '');
|
const id = String(data.get('id') || '');
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
|
||||||
import ImagePicker from '$lib/admin/editors/ImagePicker.svelte';
|
import ImagePicker from '$lib/admin/editors/ImagePicker.svelte';
|
||||||
import { confirmSubmit } from '$lib/admin/confirm';
|
import { confirmSubmit } from '$lib/admin/confirm';
|
||||||
import Modal from '$lib/admin/Modal.svelte';
|
import Modal from '$lib/admin/Modal.svelte';
|
||||||
import SaveStatus from '$lib/admin/SaveStatus.svelte';
|
|
||||||
import { warnOnUnsavedChanges } from '$lib/admin/unsaved.svelte';
|
|
||||||
import type { ItemRecord, ItemType } from '$lib/types';
|
import type { ItemRecord, ItemType } from '$lib/types';
|
||||||
import { formatDuration } from '$shared/items';
|
import { formatDuration } from '$shared/items';
|
||||||
|
|
||||||
|
|
@ -13,85 +10,6 @@
|
||||||
let showEditor = $state(false);
|
let showEditor = $state(false);
|
||||||
let uploading = $state(false);
|
let uploading = $state(false);
|
||||||
|
|
||||||
// ── Shop order ─────────────────────────────────────────────────────
|
|
||||||
// The list is in shop order (highest priority first). Dragging a row (or
|
|
||||||
// the arrow keys on its handle) changes `order` here; "Save order" turns
|
|
||||||
// it into priorities on the server (?/reorder). null = as saved.
|
|
||||||
let order = $state<string[] | null>(null);
|
|
||||||
let shown = $derived.by(() => {
|
|
||||||
if (!order) return items;
|
|
||||||
const byId = new Map(items.map((item: ItemRecord) => [item.id, item]));
|
|
||||||
const listed = order.map((id) => byId.get(id)).filter((item): item is ItemRecord => !!item);
|
|
||||||
// Anything added meanwhile (another tab) goes at the end.
|
|
||||||
return [...listed, ...items.filter((item: ItemRecord) => !order!.includes(item.id))];
|
|
||||||
});
|
|
||||||
let orderChanged = $derived(!!order && shown.map((item) => item.id).join() !== items.map((item: ItemRecord) => item.id).join());
|
|
||||||
let savingOrder = $state(false);
|
|
||||||
warnOnUnsavedChanges(() => orderChanged);
|
|
||||||
|
|
||||||
function move(from: number, to: number) {
|
|
||||||
if (to < 0 || to >= shown.length || from === to) return;
|
|
||||||
const ids = shown.map((item) => item.id);
|
|
||||||
const [id] = ids.splice(from, 1);
|
|
||||||
ids.splice(to, 0, id);
|
|
||||||
order = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mouse: native drag and drop on the whole row. Touch: phones don't fire
|
|
||||||
// drag events, so the handle follows the finger with pointer events (as
|
|
||||||
// in the page editor's block list).
|
|
||||||
let dragIndex = $state<number | null>(null);
|
|
||||||
let dropIndex = $state<number | null>(null);
|
|
||||||
|
|
||||||
function endDrag() {
|
|
||||||
if (dragIndex !== null && dropIndex !== null) move(dragIndex, dropIndex);
|
|
||||||
dragIndex = null;
|
|
||||||
dropIndex = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rowDrag(index: number) {
|
|
||||||
return {
|
|
||||||
draggable: true,
|
|
||||||
ondragstart: (e: DragEvent) => {
|
|
||||||
dragIndex = index;
|
|
||||||
// Firefox won't start a drag without data.
|
|
||||||
e.dataTransfer?.setData('text/plain', String(index));
|
|
||||||
if (e.dataTransfer) e.dataTransfer.effectAllowed = 'move';
|
|
||||||
},
|
|
||||||
ondragover: (e: DragEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
dropIndex = index;
|
|
||||||
},
|
|
||||||
ondrop: (e: DragEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
endDrag();
|
|
||||||
},
|
|
||||||
ondragend: () => {
|
|
||||||
dragIndex = null;
|
|
||||||
dropIndex = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function touchDragStart(e: PointerEvent, index: number) {
|
|
||||||
if (e.pointerType === 'mouse') return;
|
|
||||||
e.preventDefault();
|
|
||||||
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
||||||
dragIndex = index;
|
|
||||||
dropIndex = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
function touchDragMove(e: PointerEvent) {
|
|
||||||
if (dragIndex === null) return;
|
|
||||||
// The rows are the children of the list (phones) or the table body.
|
|
||||||
const rows = [...((e.currentTarget as HTMLElement).closest('ul, tbody')?.children ?? [])] as HTMLElement[];
|
|
||||||
const over = rows.findIndex((row) => e.clientY < row.getBoundingClientRect().bottom);
|
|
||||||
dropIndex = over === -1 ? rows.length - 1 : over;
|
|
||||||
// The handle blocks scrolling, so scroll for the finger near the screen's edges.
|
|
||||||
if (e.clientY < 64) window.scrollBy(0, -12);
|
|
||||||
else if (e.clientY > window.innerHeight - 64) window.scrollBy(0, 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
type ItemDraft = {
|
type ItemDraft = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -212,162 +130,57 @@
|
||||||
<div class="flex flex-col justify-between gap-4 md:flex-row md:items-end">
|
<div class="flex flex-col justify-between gap-4 md:flex-row md:items-end">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-3xl font-bold">Services & products</h1>
|
<h1 class="text-3xl font-bold">Services & products</h1>
|
||||||
<p class="text-base-content/60">Bookable services, products and bundles (codes for sessions booked later). Shop blocks show them in this order (their <em>Recommended</em> order): drag <span aria-hidden="true">⠿</span> to change it.</p>
|
<p class="text-base-content/60">Bookable services, products and bundles (codes for sessions booked later), shown in Shop blocks.</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" type="button" onclick={() => createItem()}>Add service or product</button>
|
<button class="btn btn-primary" type="button" onclick={() => createItem()}>Add service or product</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SaveStatus result={form} />
|
{#if form?.message}<div class="alert alert-error" role="alert">{form.message}</div>{/if}
|
||||||
|
|
||||||
{#if orderChanged}
|
<div class="rounded-box bg-base-100 p-5 shadow">
|
||||||
<!-- Sticky, so Save stays in reach while dragging down a long list. -->
|
|
||||||
<form
|
|
||||||
method="POST"
|
|
||||||
action="?/reorder"
|
|
||||||
class="sticky top-2 z-10 flex flex-wrap items-center gap-3 rounded-box bg-base-100 p-3 shadow-lg"
|
|
||||||
use:enhance={() => {
|
|
||||||
savingOrder = true;
|
|
||||||
return async ({ result, update }) => {
|
|
||||||
await update();
|
|
||||||
savingOrder = false;
|
|
||||||
// Saved: the reloaded list is in the new order.
|
|
||||||
if (result.type === 'success') order = null;
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input type="hidden" name="order" value={JSON.stringify(shown.map((item) => item.id))} />
|
|
||||||
<span class="badge badge-warning">Unsaved order</span>
|
|
||||||
<span class="min-w-40 flex-1 text-sm text-base-content/70">Shop blocks change once it’s saved.</span>
|
|
||||||
<span class="ml-auto flex gap-2">
|
|
||||||
<button class="btn btn-sm" type="button" disabled={savingOrder} onclick={() => (order = null)}>Undo</button>
|
|
||||||
<button class="btn btn-primary btn-sm" type="submit" disabled={savingOrder}>Save order</button>
|
|
||||||
</span>
|
|
||||||
</form>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#snippet thumbnail(item: ItemRecord)}
|
|
||||||
{#if item.imageUrl}
|
|
||||||
<img class="size-10 shrink-0 rounded-box object-cover" src={item.imageUrl} alt="" />
|
|
||||||
{:else}
|
|
||||||
<div class="size-10 shrink-0 rounded-box bg-base-200"></div>
|
|
||||||
{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet handle(item: ItemRecord, index: number)}
|
|
||||||
<!-- A button so the keyboard can move it too (↑/↓); the pointer drags the whole row. -->
|
|
||||||
<button
|
|
||||||
class="btn btn-ghost btn-sm btn-square shrink-0 cursor-grab touch-none text-xl text-base-content/50"
|
|
||||||
type="button"
|
|
||||||
title="Drag to change the order (or focus and press ↑/↓)"
|
|
||||||
aria-label="Move {item.name} — use the arrow keys"
|
|
||||||
disabled={shown.length < 2}
|
|
||||||
onpointerdown={(e) => touchDragStart(e, index)}
|
|
||||||
onpointermove={touchDragMove}
|
|
||||||
onpointerup={endDrag}
|
|
||||||
onpointercancel={() => {
|
|
||||||
dragIndex = null;
|
|
||||||
dropIndex = null;
|
|
||||||
}}
|
|
||||||
onkeydown={(e) => {
|
|
||||||
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
|
|
||||||
e.preventDefault();
|
|
||||||
const to = index + (e.key === 'ArrowUp' ? -1 : 1);
|
|
||||||
move(index, to);
|
|
||||||
// Keep the focus on this item's handle in its new place.
|
|
||||||
const button = e.currentTarget;
|
|
||||||
requestAnimationFrame(() => (button.closest('ul, tbody')?.children[Math.max(0, Math.min(to, shown.length - 1))]?.querySelector('button') as HTMLElement | null)?.focus());
|
|
||||||
}}>⠿</button
|
|
||||||
>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet typeBadge(item: ItemRecord)}
|
|
||||||
<span class="badge">{item.type === 'item_with_time' ? 'Service' : item.type === 'bundle' ? 'Bundle' : 'Product'}</span>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet price(item: ItemRecord)}{item.durations.length > 1 ? `from ${money.format(item.price)}` : money.format(item.price)}{/snippet}
|
|
||||||
|
|
||||||
{#snippet details(item: ItemRecord)}
|
|
||||||
{#if item.type === 'item_with_time'}
|
|
||||||
{durationList(item)}{item.bufferMinutes ? ` + ${item.bufferMinutes} min get-ready` : ''}{(item.capacity ?? 1) > 1 ? ` · ${item.capacity} places` : ''}
|
|
||||||
{:else if item.type === 'bundle'}
|
|
||||||
{bundleList(item)} · {item.validMonths ? `valid ${item.validMonths} months` : 'no expiry'}
|
|
||||||
{:else}—{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet status(item: ItemRecord, problem: string)}
|
|
||||||
{#if problem}
|
|
||||||
<span class="badge badge-warning whitespace-nowrap">Not on sale</span>
|
|
||||||
{:else}
|
|
||||||
<span class="badge whitespace-nowrap" class:badge-success={item.active}>{item.active ? 'Active' : 'Inactive'}</span>
|
|
||||||
{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet notes(problem: string, waiting: number)}
|
|
||||||
{#if problem}
|
|
||||||
<span class="mt-1 block text-xs text-base-content/60">{problem}</span>
|
|
||||||
{/if}
|
|
||||||
{#if waiting}
|
|
||||||
<span class="mt-1 block text-xs text-base-content/70">{waiting === 1 ? '1 code has' : `${waiting} codes have`} sessions of this left to book — they can’t while it’s inactive.</span>
|
|
||||||
{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<!-- Phones and tablets: one card per item (seven columns didn't fit; long bundle lists made rows very tall). -->
|
|
||||||
<ul class="divide-y divide-base-200 rounded-box bg-base-100 shadow lg:hidden">
|
|
||||||
{#each shown as item, i (item.id)}
|
|
||||||
{@const problem = item.type === 'bundle' && item.active ? bundleProblem(item) : ''}
|
|
||||||
{@const waiting = !item.active && item.type === 'item_with_time' ? (data.waiting[item.id] ?? 0) : 0}
|
|
||||||
<li class="p-4 pl-2 transition-colors" class:opacity-50={dragIndex === i} class:bg-base-200={dropIndex === i && dragIndex !== i} {...rowDrag(i)}>
|
|
||||||
<div class="flex items-start gap-2">
|
|
||||||
{@render handle(item, i)}
|
|
||||||
{@render thumbnail(item)}
|
|
||||||
<div class="min-w-0 flex-1">
|
|
||||||
<span class="block font-semibold break-words">{item.name}</span>
|
|
||||||
<div class="mt-1 flex flex-wrap items-center gap-2 text-sm">
|
|
||||||
{@render typeBadge(item)}
|
|
||||||
{@render status(item, problem)}
|
|
||||||
<span class="text-base-content/70">{@render price(item)}{item.type === 'item' ? ` · stock ${item.stock ?? '∞'}` : ''}</span>
|
|
||||||
</div>
|
|
||||||
{#if item.type !== 'item'}
|
|
||||||
<p class="mt-2 text-sm text-base-content/70">{@render details(item)}</p>
|
|
||||||
{/if}
|
|
||||||
{@render notes(problem, waiting)}
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-sm shrink-0" type="button" onclick={() => editItem(item)}>Edit</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li class="py-10 text-center text-base-content/60">No items yet — create a service or product.</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="hidden rounded-box bg-base-100 p-5 shadow lg:block">
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr><th class="w-0"><span class="sr-only">Order</span></th><th>Name</th><th>Type</th><th>Price</th><th>Stock</th><th>Duration</th><th>Status</th><th></th></tr></thead>
|
<thead><tr><th>Name</th><th>Type</th><th>Price</th><th>Stock</th><th>Duration</th><th>Status</th><th></th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each shown as item, i (item.id)}
|
{#each items as item (item.id)}
|
||||||
{@const problem = item.type === 'bundle' && item.active ? bundleProblem(item) : ''}
|
{@const problem = item.type === 'bundle' && item.active ? bundleProblem(item) : ''}
|
||||||
{@const waiting = !item.active && item.type === 'item_with_time' ? (data.waiting[item.id] ?? 0) : 0}
|
{@const waiting = !item.active && item.type === 'item_with_time' ? (data.waiting[item.id] ?? 0) : 0}
|
||||||
<tr class="transition-colors" class:opacity-50={dragIndex === i} class:bg-base-200={dropIndex === i && dragIndex !== i} {...rowDrag(i)}>
|
<tr>
|
||||||
<td class="pr-0">{@render handle(item, i)}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
{@render thumbnail(item)}
|
{#if item.imageUrl}
|
||||||
|
<img class="size-10 rounded-box object-cover" src={item.imageUrl} alt="" />
|
||||||
|
{:else}
|
||||||
|
<div class="size-10 rounded-box bg-base-200"></div>
|
||||||
|
{/if}
|
||||||
<span class="font-semibold">{item.name}</span>
|
<span class="font-semibold">{item.name}</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{@render typeBadge(item)}</td>
|
<td><span class="badge">{item.type === 'item_with_time' ? 'Service' : item.type === 'bundle' ? 'Bundle' : 'Product'}</span></td>
|
||||||
<td>{@render price(item)}</td>
|
<td>{item.durations.length > 1 ? `from ${money.format(item.price)}` : money.format(item.price)}</td>
|
||||||
<td>{item.type === 'item' ? (item.stock ?? '∞') : '—'}</td>
|
<td>{item.type === 'item' ? (item.stock ?? '∞') : '—'}</td>
|
||||||
<td>{@render details(item)}</td>
|
|
||||||
<td>
|
<td>
|
||||||
{@render status(item, problem)}
|
{#if item.type === 'item_with_time'}
|
||||||
{@render notes(problem, waiting)}
|
{durationList(item)}{item.bufferMinutes ? ` + ${item.bufferMinutes} min get-ready` : ''}{(item.capacity ?? 1) > 1 ? ` · ${item.capacity} places` : ''}
|
||||||
|
{:else if item.type === 'bundle'}
|
||||||
|
{bundleList(item)} · {item.validMonths ? `valid ${item.validMonths} months` : 'no expiry'}
|
||||||
|
{:else}—{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{#if problem}
|
||||||
|
<span class="badge badge-warning whitespace-nowrap">Not on sale</span>
|
||||||
|
<span class="mt-1 block text-xs text-base-content/60">{problem}</span>
|
||||||
|
{:else}
|
||||||
|
<span class="badge" class:badge-success={item.active}>{item.active ? 'Active' : 'Inactive'}</span>
|
||||||
|
{/if}
|
||||||
|
{#if waiting}
|
||||||
|
<span class="mt-1 block text-xs text-base-content/70">{waiting === 1 ? '1 code has' : `${waiting} codes have`} sessions of this left to book — they can’t while it’s inactive.</span>
|
||||||
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => editItem(item)}>Edit</button></td>
|
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => editItem(item)}>Edit</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
{:else}
|
{:else}
|
||||||
<tr><td colspan="8" class="py-10 text-center text-base-content/60">No items yet — create a service or product.</td></tr>
|
<tr><td colspan="7" class="py-10 text-center text-base-content/60">No items yet — create a service or product.</td></tr>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
@ -497,9 +310,9 @@
|
||||||
</ImagePicker>
|
</ImagePicker>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="label mt-2 cursor-pointer gap-3 whitespace-normal text-base-content">
|
<label class="label mt-2 cursor-pointer gap-3 text-base-content">
|
||||||
<input class="toggle toggle-success shrink-0" type="checkbox" bind:checked={draft.active} />
|
<input class="toggle toggle-success" type="checkbox" bind:checked={draft.active} />
|
||||||
<span>Active <span class="text-base-content/60">— inactive items are hidden from the shop</span></span>
|
Active <span class="text-base-content/60">— inactive items are hidden from the shop</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="modal-action justify-between">
|
<div class="modal-action justify-between">
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export const actions: Actions = {
|
||||||
return fail(400, { email, message: 'Invalid email or password.' });
|
return fail(400, { email, message: 'Invalid email or password.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
throw redirect(303, '/');
|
throw redirect(303, '/pages');
|
||||||
},
|
},
|
||||||
logout: async ({ locals }) => {
|
logout: async ({ locals }) => {
|
||||||
locals.pb.authStore.clear();
|
locals.pb.authStore.clear();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let { form } = $props();
|
let { form } = $props();
|
||||||
let submitting = $state(false);
|
let submitting = $state(false);
|
||||||
let showPassword = $state(false);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head><title>Sign in | CMS</title></svelte:head>
|
<svelte:head><title>Sign in | CMS</title></svelte:head>
|
||||||
|
|
@ -24,16 +23,10 @@
|
||||||
<!-- svelte-ignore a11y_autofocus -->
|
<!-- svelte-ignore a11y_autofocus -->
|
||||||
<input class="input w-full" name="email" type="email" autocomplete="username" defaultValue={form?.email ?? ''} required autofocus />
|
<input class="input w-full" name="email" type="email" autocomplete="username" defaultValue={form?.email ?? ''} required autofocus />
|
||||||
</label>
|
</label>
|
||||||
<div class="flex flex-col gap-1">
|
<label class="flex flex-col gap-1">
|
||||||
<label class="fieldset-legend p-0" for="password">Password</label>
|
<span class="fieldset-legend p-0">Password</span>
|
||||||
<!-- DaisyUI's input wrapper: the field and the Show button share one box. -->
|
<input class="input w-full" name="password" type="password" autocomplete="current-password" required />
|
||||||
<div class="input w-full pr-1">
|
</label>
|
||||||
<input class="grow" id="password" name="password" type={showPassword ? 'text' : 'password'} autocomplete="current-password" required />
|
|
||||||
<button class="btn btn-ghost btn-xs" type="button" aria-controls="password" aria-pressed={showPassword} onclick={() => (showPassword = !showPassword)}>
|
|
||||||
{showPassword ? 'Hide' : 'Show'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button class="btn btn-primary w-full" type="submit" disabled={submitting}>
|
<button class="btn btn-primary w-full" type="submit" disabled={submitting}>
|
||||||
{#if submitting}<span class="loading loading-spinner loading-sm"></span>{/if}
|
{#if submitting}<span class="loading loading-spinner loading-sm"></span>{/if}
|
||||||
|
|
|
||||||
|
|
@ -24,45 +24,7 @@
|
||||||
<div class="alert alert-error mb-4" role="alert">{form.message}</div>
|
<div class="alert alert-error mb-4" role="alert">{form.message}</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#snippet actions(page: (typeof data.pages)[number])}
|
<div class="overflow-x-auto rounded-box bg-base-100 shadow">
|
||||||
<a class="btn btn-sm" href={`/pages/${page.slug}`}>Edit</a>
|
|
||||||
{#if siteUrl && page.published}
|
|
||||||
<a class="btn btn-sm" href={publicUrl(page.slug)} target="_blank" rel="noopener" title="Open on the live site">View</a>
|
|
||||||
{/if}
|
|
||||||
<form method="POST" action="?/toggle">
|
|
||||||
<input type="hidden" name="id" value={page.id} />
|
|
||||||
<input type="hidden" name="published" value={page.published} />
|
|
||||||
<button class="btn btn-sm btn-outline" type="submit">{page.published ? 'Unpublish' : 'Publish'}</button>
|
|
||||||
</form>
|
|
||||||
<form method="POST" action="?/delete" onsubmit={confirmSubmit(`Delete the page "${page.title}"? This cannot be undone.`)}>
|
|
||||||
<input type="hidden" name="id" value={page.id} />
|
|
||||||
<button class="btn btn-sm btn-error btn-outline" type="submit">Delete</button>
|
|
||||||
</form>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet status(page: (typeof data.pages)[number])}
|
|
||||||
<span class="badge" class:badge-success={page.published}>{page.published ? 'Published' : 'Draft'}</span>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<!-- Phones: one card per page, buttons under the title (a four-column table didn't fit). -->
|
|
||||||
<ul class="divide-y divide-base-200 rounded-box bg-base-100 shadow md:hidden">
|
|
||||||
{#each data.pages as page (page.id)}
|
|
||||||
<li class="p-4">
|
|
||||||
<div class="flex items-start justify-between gap-3">
|
|
||||||
<a class="min-w-0" href={`/pages/${page.slug}`}>
|
|
||||||
<span class="block font-semibold break-words">{page.title}</span>
|
|
||||||
<span class="block font-mono text-sm break-all text-base-content/60">/{page.slug}</span>
|
|
||||||
</a>
|
|
||||||
<span class="shrink-0">{@render status(page)}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-3 flex flex-wrap gap-2">{@render actions(page)}</div>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li class="py-10 text-center text-base-content/60">No pages yet — create your first one.</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="hidden overflow-x-auto rounded-box bg-base-100 shadow md:block">
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Slug</th><th>Title</th><th>Status</th><th class="text-right">Actions</th></tr>
|
<tr><th>Slug</th><th>Title</th><th>Status</th><th class="text-right">Actions</th></tr>
|
||||||
|
|
@ -72,9 +34,23 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-mono">{page.slug}</td>
|
<td class="font-mono">{page.slug}</td>
|
||||||
<td>{page.title}</td>
|
<td>{page.title}</td>
|
||||||
<td>{@render status(page)}</td>
|
<td><span class="badge" class:badge-success={page.published}>{page.published ? 'Published' : 'Draft'}</span></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="flex flex-wrap justify-end gap-2 xl:flex-nowrap">{@render actions(page)}</div>
|
<div class="flex flex-wrap justify-end gap-2">
|
||||||
|
<a class="btn btn-sm" href={`/pages/${page.slug}`}>Edit</a>
|
||||||
|
{#if siteUrl && page.published}
|
||||||
|
<a class="btn btn-sm" href={publicUrl(page.slug)} target="_blank" rel="noopener" title="Open on the live site">View</a>
|
||||||
|
{/if}
|
||||||
|
<form method="POST" action="?/toggle">
|
||||||
|
<input type="hidden" name="id" value={page.id} />
|
||||||
|
<input type="hidden" name="published" value={page.published} />
|
||||||
|
<button class="btn btn-sm btn-outline" type="submit">{page.published ? 'Unpublish' : 'Publish'}</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action="?/delete" onsubmit={confirmSubmit(`Delete the page "${page.title}"? This cannot be undone.`)}>
|
||||||
|
<input type="hidden" name="id" value={page.id} />
|
||||||
|
<button class="btn btn-sm btn-error btn-outline" type="submit">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import type { SubmitFunction } from '@sveltejs/kit';
|
import type { SubmitFunction } from '@sveltejs/kit';
|
||||||
import type { PassPart } from '$lib/types';
|
|
||||||
import { formatDateTime, toZonedDatetimeInput } from '$lib/calendar';
|
import { formatDateTime, toZonedDatetimeInput } from '$lib/calendar';
|
||||||
import { confirmSubmit } from '$lib/admin/confirm';
|
import { confirmSubmit } from '$lib/admin/confirm';
|
||||||
import Modal from '$lib/admin/Modal.svelte';
|
import Modal from '$lib/admin/Modal.svelte';
|
||||||
|
|
@ -97,48 +96,13 @@
|
||||||
{#if !data.bundles.length}<div class="alert" role="status">No bundles yet — add one under Services & products (type “Bundle / voucher”).</div>{/if}
|
{#if !data.bundles.length}<div class="alert" role="status">No bundles yet — add one under Services & products (type “Bundle / voucher”).</div>{/if}
|
||||||
|
|
||||||
<div class="rounded-box bg-base-100 p-5 shadow">
|
<div class="rounded-box bg-base-100 p-5 shadow">
|
||||||
<form method="GET" class="mb-4 flex gap-2">
|
<form method="GET" class="mb-4 flex flex-wrap gap-2">
|
||||||
<input class="input min-w-0 flex-1 sm:w-80 sm:flex-none" type="search" name="q" placeholder="Code, email, name or bundle" aria-label="Search codes" value={data.q} />
|
<input class="input w-80 max-w-full" type="search" name="q" placeholder="Code, email, name or bundle" aria-label="Search codes" value={data.q} />
|
||||||
<button class="btn" type="submit">Search</button>
|
<button class="btn" type="submit">Search</button>
|
||||||
{#if data.q}<a class="btn btn-ghost" href="/passes">Show all</a>{/if}
|
{#if data.q}<a class="btn btn-ghost" href="/passes">Show all</a>{/if}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{#snippet buyer(pass: (typeof passes)[number])}
|
<div class="overflow-x-auto">
|
||||||
<span class="block">{pass.email || (pass.anonymisedAt ? 'Anonymised' : pass.order ? '—' : 'Issued here')}</span>
|
|
||||||
{#if pass.recipientName}<span class="block text-sm text-base-content/60">for {pass.recipientName}</span>{/if}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet leftToBook(pass: (typeof passes)[number])}
|
|
||||||
{#each bookable(pass) as part (`${part.item}|${part.minutes}`)}
|
|
||||||
<span class="block">{part.left}/{part.count} {partLabel(part)}{part.held ? ` · ${part.held} in a basket` : ''}</span>
|
|
||||||
{/each}
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<!-- Phones and tablets: one card per code (seven columns didn't fit). -->
|
|
||||||
<ul class="-mx-5 divide-y divide-base-200 border-t border-base-200 lg:hidden">
|
|
||||||
{#each passes as pass (pass.id)}
|
|
||||||
{@const s = passStatus(pass)}
|
|
||||||
<li class="px-5 py-4">
|
|
||||||
<div class="flex items-start gap-3">
|
|
||||||
<div class="min-w-0 flex-1">
|
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
|
||||||
<span class="font-mono font-semibold tracking-wider">{pass.code}</span>
|
|
||||||
<span class="badge {s.badge}">{s.label}</span>
|
|
||||||
</div>
|
|
||||||
<span class="mt-1 block font-medium break-words">{pass.name}</span>
|
|
||||||
<div class="mt-1 text-sm break-words">{@render buyer(pass)}</div>
|
|
||||||
<div class="mt-2 text-sm text-base-content/70">{@render leftToBook(pass)}</div>
|
|
||||||
<span class="mt-1 block text-sm text-base-content/60">Expires {pass.expiresAt ? dateOnly(pass.expiresAt) : 'never'}</span>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-sm shrink-0" type="button" onclick={() => manage(pass)}>Manage</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li class="py-10 text-center text-base-content/60">{data.q ? 'No codes match that search.' : 'No codes yet — they appear here when a bundle is bought.'}</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="hidden overflow-x-auto lg:block">
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead><tr><th>Code</th><th>Bundle</th><th>Bought by / for</th><th>Left to book</th><th>Expires</th><th>Status</th><th></th></tr></thead>
|
<thead><tr><th>Code</th><th>Bundle</th><th>Bought by / for</th><th>Left to book</th><th>Expires</th><th>Status</th><th></th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -147,8 +111,15 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font-mono font-semibold tracking-wider whitespace-nowrap">{pass.code}</td>
|
<td class="font-mono font-semibold tracking-wider whitespace-nowrap">{pass.code}</td>
|
||||||
<td>{pass.name}</td>
|
<td>{pass.name}</td>
|
||||||
<td>{@render buyer(pass)}</td>
|
<td>
|
||||||
<td class="whitespace-nowrap">{@render leftToBook(pass)}</td>
|
<span class="block">{pass.email || (pass.anonymisedAt ? 'Anonymised' : pass.order ? '—' : 'Issued here')}</span>
|
||||||
|
{#if pass.recipientName}<span class="block text-sm text-base-content/60">for {pass.recipientName}</span>{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{#each bookable(pass) as part (`${part.item}|${part.minutes}`)}
|
||||||
|
<span class="block whitespace-nowrap">{part.left}/{part.count} {partLabel(part)}{part.held ? ` · ${part.held} in a basket` : ''}</span>
|
||||||
|
{/each}
|
||||||
|
</td>
|
||||||
<td class="whitespace-nowrap">{pass.expiresAt ? dateOnly(pass.expiresAt) : 'Never'}</td>
|
<td class="whitespace-nowrap">{pass.expiresAt ? dateOnly(pass.expiresAt) : 'Never'}</td>
|
||||||
<td><span class="badge {s.badge}">{s.label}</span></td>
|
<td><span class="badge {s.badge}">{s.label}</span></td>
|
||||||
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => manage(pass)}>Manage</button></td>
|
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => manage(pass)}>Manage</button></td>
|
||||||
|
|
@ -172,40 +143,22 @@
|
||||||
{managing.created ? `Created ${formatDateTime(managing.created, data.timezone)}` : ''}{managing.order ? ` · order ${managing.order}` : ' · issued here'}
|
{managing.created ? `Created ${formatDateTime(managing.created, data.timezone)}` : ''}{managing.order ? ` · order ${managing.order}` : ' · issued here'}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{#snippet share(part: PassPart)}{money.format(part.value)}{part.count > 1 ? ` (${money.format(part.value / part.count)} each)` : ''}{/snippet}
|
<table class="table table-sm mt-3">
|
||||||
|
<thead><tr><th>Part</th><th>Used</th><th>In a basket</th><th>Left</th><th class="text-right">Share of the price</th></tr></thead>
|
||||||
<!-- Phones: one row per part (five columns didn't fit). -->
|
<tbody>
|
||||||
<ul class="mt-3 divide-y divide-base-200 sm:hidden">
|
{#each managing.parts as part (`${part.item}|${part.minutes}`)}
|
||||||
{#each managing.parts as part (`${part.item}|${part.minutes}`)}
|
<tr>
|
||||||
<li class="flex items-start justify-between gap-3 py-2 text-sm">
|
<td>{part.count}× {partLabel(part)}</td>
|
||||||
<span class="min-w-0">
|
{#if part.redeemable}
|
||||||
<span class="block font-medium">{part.count}× {partLabel(part)}</span>
|
<td>{part.used}</td><td>{part.held}</td><td>{part.left}</td>
|
||||||
<span class="block text-base-content/60">{part.redeemable ? `${part.left} left · ${part.used} used${part.held ? ` · ${part.held} in a basket` : ''}` : 'Handed over with the purchase'}</span>
|
{:else}
|
||||||
</span>
|
<td colspan="3" class="text-base-content/60">Handed over with the purchase</td>
|
||||||
<span class="shrink-0 text-right">{@render share(part)}</span>
|
{/if}
|
||||||
</li>
|
<td class="text-right">{money.format(part.value)}{part.count > 1 ? ` (${money.format(part.value / part.count)} each)` : ''}</td>
|
||||||
{/each}
|
</tr>
|
||||||
</ul>
|
{/each}
|
||||||
|
</tbody>
|
||||||
<!-- Hidden through a wrapper: the table's own "table" class also sets display: table, which beats "hidden". -->
|
</table>
|
||||||
<div class="mt-3 hidden sm:block">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead><tr><th>Part</th><th>Used</th><th>In a basket</th><th>Left</th><th class="text-right">Share of the price</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{#each managing.parts as part (`${part.item}|${part.minutes}`)}
|
|
||||||
<tr>
|
|
||||||
<td>{part.count}× {partLabel(part)}</td>
|
|
||||||
{#if part.redeemable}
|
|
||||||
<td>{part.used}</td><td>{part.held}</td><td>{part.left}</td>
|
|
||||||
{:else}
|
|
||||||
<td colspan="3" class="text-base-content/60">Handed over with the purchase</td>
|
|
||||||
{/if}
|
|
||||||
<td class="text-right">{@render share(part)}</td>
|
|
||||||
</tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<p class="mt-1 text-xs text-base-content/60">The share of the price is what each part is worth for a partial refund (refund in Stripe, then mark the booking’s order refunded to give its place back).</p>
|
<p class="mt-1 text-xs text-base-content/60">The share of the price is what each part is worth for a partial refund (refund in Stripe, then mark the booking’s order refunded to give its place back).</p>
|
||||||
|
|
||||||
<form method="POST" action="?/expiry" use:enhance={submitManage} class="mt-4 flex flex-wrap items-end gap-2">
|
<form method="POST" action="?/expiry" use:enhance={submitManage} class="mt-4 flex flex-wrap items-end gap-2">
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Preview</title>
|
<title>Preview</title>
|
||||||
<!-- Full site colours and style so the draft looks like the public site. -->
|
<!-- Full site colours so the draft looks like the public site. -->
|
||||||
{@html rootStyleTag(siteThemeVars(data.colors, data.style))}
|
{@html rootStyleTag(siteThemeVars(data.colors))}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if blocks.length}
|
{#if blocks.length}
|
||||||
|
|
|
||||||
|
|
@ -444,12 +444,10 @@
|
||||||
<span class="fieldset-legend">Services that can be booked in this window</span>
|
<span class="fieldset-legend">Services that can be booked in this window</span>
|
||||||
<div class="grid gap-1 sm:grid-cols-2">
|
<div class="grid gap-1 sm:grid-cols-2">
|
||||||
{#each items as item (item.id)}
|
{#each items as item (item.id)}
|
||||||
<label class="label cursor-pointer items-start gap-2 whitespace-normal text-base-content">
|
<label class="label cursor-pointer gap-2 text-base-content">
|
||||||
<input class="checkbox checkbox-sm mt-0.5" type="checkbox" name="items" value={item.id} bind:group={draft.items} />
|
<input class="checkbox checkbox-sm" type="checkbox" name="items" value={item.id} bind:group={draft.items} />
|
||||||
<span>
|
{item.name}
|
||||||
<span class="block">{item.name}</span>
|
<span class="text-xs text-base-content/50">{item.durations.map((d) => formatDuration(d.minutes)).join(' / ')}</span>
|
||||||
<span class="block text-xs text-base-content/50">{item.durations.map((d) => formatDuration(d.minutes)).join(' / ')}</span>
|
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -465,14 +463,11 @@
|
||||||
onChange={(v) => (draft.startTimes = v as StartTimesMode)}
|
onChange={(v) => (draft.startTimes = v as StartTimesMode)}
|
||||||
/>
|
/>
|
||||||
{#if draft.startTimes === 'grid'}
|
{#if draft.startTimes === 'grid'}
|
||||||
<!-- Laid out like the Start times row above: label on the left, or above it in a narrow row. -->
|
<label class="mt-2 flex items-center gap-3">
|
||||||
<label class="mt-2 @container block">
|
<span class="w-28 shrink-0 text-sm font-medium">Step</span>
|
||||||
<span class="flex flex-col gap-1 @sm:flex-row @sm:items-center @sm:gap-3">
|
<select class="select select-sm w-40" name="gridMinutes" bind:value={draft.gridMinutes}>
|
||||||
<span class="shrink-0 text-sm font-medium @sm:w-28">Step</span>
|
{#each GRID_STEP_OPTIONS as step (step)}<option value={step}>Every {step} min</option>{/each}
|
||||||
<select class="select select-sm w-full @sm:flex-1" name="gridMinutes" bind:value={draft.gridMinutes}>
|
</select>
|
||||||
{#each GRID_STEP_OPTIONS as step (step)}<option value={step}>Every {step} min</option>{/each}
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
<span class="label whitespace-normal">{startTimesHint(draft.startTimes, draft.gridMinutes)}</span>
|
<span class="label whitespace-normal">{startTimesHint(draft.startTimes, draft.gridMinutes)}</span>
|
||||||
|
|
|
||||||
167
app-public/package-lock.json
generated
167
app-public/package-lock.json
generated
|
|
@ -13,25 +13,12 @@
|
||||||
"@tailwindcss/vite": "^4.3.0",
|
"@tailwindcss/vite": "^4.3.0",
|
||||||
"daisyui": "^5.5.19",
|
"daisyui": "^5.5.19",
|
||||||
"nodemailer": "^10.0.12",
|
"nodemailer": "^10.0.12",
|
||||||
"pocketbase": "^0.28.2",
|
"pocketbase": "^0.26.9",
|
||||||
"tailwindcss": "^4.3.0"
|
"tailwindcss": "^4.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/cormorant-garamond": "^5.3.0",
|
"@fontsource/dm-sans": "^5.3.0",
|
||||||
"@fontsource-variable/dm-sans": "^5.3.0",
|
"@fontsource/playfair-display": "^5.3.0",
|
||||||
"@fontsource-variable/eb-garamond": "^5.3.0",
|
|
||||||
"@fontsource-variable/fraunces": "^5.3.0",
|
|
||||||
"@fontsource-variable/inter": "^5.3.0",
|
|
||||||
"@fontsource-variable/josefin-sans": "^5.3.0",
|
|
||||||
"@fontsource-variable/libre-baskerville": "^5.3.0",
|
|
||||||
"@fontsource-variable/lora": "^5.3.0",
|
|
||||||
"@fontsource-variable/manrope": "^5.3.0",
|
|
||||||
"@fontsource-variable/montserrat": "^5.3.0",
|
|
||||||
"@fontsource-variable/nunito": "^5.3.0",
|
|
||||||
"@fontsource-variable/outfit": "^5.3.0",
|
|
||||||
"@fontsource-variable/playfair-display": "^5.3.0",
|
|
||||||
"@fontsource-variable/raleway": "^5.3.0",
|
|
||||||
"@fontsource-variable/work-sans": "^5.3.0",
|
|
||||||
"@sveltejs/kit": "^2.57.0",
|
"@sveltejs/kit": "^2.57.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||||
"@types/node": "^25.8.0",
|
"@types/node": "^25.8.0",
|
||||||
|
|
@ -42,150 +29,20 @@
|
||||||
"vite": "^8.0.7"
|
"vite": "^8.0.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fontsource-variable/cormorant-garamond": {
|
"node_modules/@fontsource/dm-sans": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/cormorant-garamond/-/cormorant-garamond-5.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fontsource/dm-sans/-/dm-sans-5.3.0.tgz",
|
||||||
"integrity": "sha512-rgZJ/5w3hi60swAPnrOXpZf5wEH6NTrvm4H8D9Y4b1QIFUqlX14eM3QTMU/eAznjfh0eXpO1QUqsFhiy58aoMg==",
|
"integrity": "sha512-lYJtMXXO28q1z+yz+z8XKd0s4hXaa9QdkETzkyD760sidCv5heI86weYA0sx0Nc4pAMAQTUuyf4gO44cYKKS9g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "OFL-1.1",
|
"license": "OFL-1.1",
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
"url": "https://github.com/sponsors/ayuhito"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fontsource-variable/dm-sans": {
|
"node_modules/@fontsource/playfair-display": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/dm-sans/-/dm-sans-5.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fontsource/playfair-display/-/playfair-display-5.3.0.tgz",
|
||||||
"integrity": "sha512-BpUG5bqePiDFMBM4ZtLSlPdAIOM990uB1dlXzIf4aw21yQR7BmykedLXXXMqGWsR18aMLOsbWccwJNh3ztTQaA==",
|
"integrity": "sha512-uJSABalvdWc10fEPppQjQocamT21LEyRfzzWfRfqbkPz+sRv+kKpYDKyluBUskvJREkJTos9epj1WjQROGu99Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/eb-garamond": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/eb-garamond/-/eb-garamond-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-656OJsA9Vv24yhqRZFEzXnzS2AYgKdEILLgHJYLzzXndgcWFKfSXFqzbRI5/6Yk1Yt7UfWrUeppE5nRQPQMwlQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/fraunces": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/fraunces/-/fraunces-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-9BYGySn4AHEJdgp9Z28tQ3X+laJMEOITXkQarZXeloWQZDq5oOvXJ3kDA8c7MGIfpogIaZfjrQBqmda8POOCKA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/inter": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/josefin-sans": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/josefin-sans/-/josefin-sans-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-duVgkuzE/co4iuIfJ7jM2qX0ED3b6qdY+SlSjNMs6zfhz7EE7kJxV0qF65hQCv1kN0A20j4FwsGAYJvfpU+iSg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/libre-baskerville": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/libre-baskerville/-/libre-baskerville-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-lIjXwDhcdr0OxSdzlAU4G7Tnny1LhgAiPFdp3/PjwRMqYt2JLU6pQiLwz/M5lRBs/kRtHwxknPUqRt37AnqPFg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/lora": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/lora/-/lora-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-2ph8KiZ8Bn141hWuC3ErtpJ+Ui8p2MJQn8TJNRSRmLmnCIOCtHfiBM9R7WLRPeUG/q6hXyHOxWQ8DvRSX+ixvQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/manrope": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/manrope/-/manrope-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-6D5dgokHsWDDMtmXHznKa0hK229NN+1a4BLPmUCLqcO1Pw5EEhWY5RFt0AcXnVRAljFFPfRtLkJePQj6LSsV6g==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/montserrat": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/montserrat/-/montserrat-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-7PaZoxaxrWLAyrhO46v65An9LhUhfkTExWLhfbywYZCnZEgg/W1rEHnlNmZKjNZ3nJTVYyicqxlJt10z/26yTA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/nunito": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/nunito/-/nunito-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-tw0ch7evIDSwoeUy+0XzocYHfbRWLeCRPJy22KgbrLjDLAbNw/fErBiil10Ssrs3Sjr55zaZrr36a975j8cBkQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/outfit": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/outfit/-/outfit-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-fPb5XnYK0k7SbR++HEmm4+ZqDszmLKQ+sPRUr8oQ/KNC0vy6r6hazJFe8iYozv4cqlHbvJ/JECkJWrfDodUMVQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/playfair-display": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/playfair-display/-/playfair-display-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-IHdzTvE8eGIXHteZql7KXoqdc3Gfm+Zs1u4XlSC3MeplkwviT3sx/P6gI0tLwg/xIYLF4ZJYveZ5V+bl9cnDwA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/raleway": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/raleway/-/raleway-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-aSV2k+V6Zz+od0dHpBOzkVxEzmgEdiXcxDfant39jLOx+T89dielQRrZylukwK3Fp+FY255gPqz67ruOfs1rqA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "OFL-1.1",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ayuhito"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fontsource-variable/work-sans": {
|
|
||||||
"version": "5.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/work-sans/-/work-sans-5.3.0.tgz",
|
|
||||||
"integrity": "sha512-le8h/OIIuhm5Z7TdvuMw0yKg2gaCZUiMec8zaumsVVjzeJRBPEF0bQI/MkaZDHCVzZDvZoP/O2LiGOSfDLSbaw==",
|
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "OFL-1.1",
|
"license": "OFL-1.1",
|
||||||
"funding": {
|
"funding": {
|
||||||
|
|
@ -1964,9 +1821,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pocketbase": {
|
"node_modules/pocketbase": {
|
||||||
"version": "0.28.2",
|
"version": "0.26.9",
|
||||||
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.26.9.tgz",
|
||||||
"integrity": "sha512-5lS4g7iDZi90LxLai8kyUK4r5u1GkEAoZ3yuzTEFX97FyDQAoEmXWbTqf+pYA1hz5e/icBQu1MCUjM/9V8mitg==",
|
"integrity": "sha512-Tiv1/hNuUzRdvT0d8hF03dfzuefQ1WdSRp1A1q3wzFC/WYhQcbU/Qlaubl/3ZDo6xvFXBS8JAgBS/L+ms7nkVQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,8 @@
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/cormorant-garamond": "^5.3.0",
|
"@fontsource/dm-sans": "^5.3.0",
|
||||||
"@fontsource-variable/dm-sans": "^5.3.0",
|
"@fontsource/playfair-display": "^5.3.0",
|
||||||
"@fontsource-variable/eb-garamond": "^5.3.0",
|
|
||||||
"@fontsource-variable/fraunces": "^5.3.0",
|
|
||||||
"@fontsource-variable/inter": "^5.3.0",
|
|
||||||
"@fontsource-variable/josefin-sans": "^5.3.0",
|
|
||||||
"@fontsource-variable/libre-baskerville": "^5.3.0",
|
|
||||||
"@fontsource-variable/lora": "^5.3.0",
|
|
||||||
"@fontsource-variable/manrope": "^5.3.0",
|
|
||||||
"@fontsource-variable/montserrat": "^5.3.0",
|
|
||||||
"@fontsource-variable/nunito": "^5.3.0",
|
|
||||||
"@fontsource-variable/outfit": "^5.3.0",
|
|
||||||
"@fontsource-variable/playfair-display": "^5.3.0",
|
|
||||||
"@fontsource-variable/raleway": "^5.3.0",
|
|
||||||
"@fontsource-variable/work-sans": "^5.3.0",
|
|
||||||
"@sveltejs/kit": "^2.57.0",
|
"@sveltejs/kit": "^2.57.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||||
"@types/node": "^25.8.0",
|
"@types/node": "^25.8.0",
|
||||||
|
|
@ -40,7 +27,7 @@
|
||||||
"@tailwindcss/vite": "^4.3.0",
|
"@tailwindcss/vite": "^4.3.0",
|
||||||
"daisyui": "^5.5.19",
|
"daisyui": "^5.5.19",
|
||||||
"nodemailer": "^10.0.12",
|
"nodemailer": "^10.0.12",
|
||||||
"pocketbase": "^0.28.2",
|
"pocketbase": "^0.26.9",
|
||||||
"tailwindcss": "^4.3.0"
|
"tailwindcss": "^4.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,28 +3,9 @@
|
||||||
themes: light --default;
|
themes: light --default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Site design → Style sets the --site-* variables (siteStyleVars in
|
|
||||||
$shared/theme) on the public site and the admin preview; without them
|
|
||||||
(the admin's own pages) every token below is its usual value. Corners,
|
|
||||||
shadows and widths are scaled here, so blocks just use rounded-xl,
|
|
||||||
shadow-sm, max-w-6xl… Buttons and chips use rounded-button (a pill when
|
|
||||||
Round); dots and avatars stay rounded-full. */
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-sans: var(--site-font-body, 'DM Sans Variable', ui-sans-serif, system-ui, sans-serif);
|
--font-sans: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||||
--font-serif: var(--site-font-heading, 'Playfair Display Variable', Georgia, serif);
|
--font-serif: 'Playfair Display', Georgia, serif;
|
||||||
--radius-lg: calc(0.5rem * var(--site-corners, 1));
|
|
||||||
--radius-xl: calc(0.75rem * var(--site-corners, 1));
|
|
||||||
--radius-2xl: calc(1rem * var(--site-corners, 1));
|
|
||||||
--radius-card: calc(1.25rem * var(--site-corners, 1));
|
|
||||||
--radius-panel: calc(2rem * var(--site-corners, 1));
|
|
||||||
--radius-button: var(--site-button-radius, 9999px);
|
|
||||||
--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 1px 2px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 2px 4px -2px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 4px 6px -4px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 8px 10px -6px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
|
||||||
--container-3xl: calc(48rem * var(--site-width, 1));
|
|
||||||
--container-6xl: calc(72rem * var(--site-width, 1));
|
|
||||||
--container-7xl: calc(80rem * var(--site-width, 1));
|
|
||||||
--color-warm: var(--color-bg, #faf8f5);
|
--color-warm: var(--color-bg, #faf8f5);
|
||||||
--color-charcoal: var(--color-heading, #2c2c2c);
|
--color-charcoal: var(--color-heading, #2c2c2c);
|
||||||
--color-sage: var(--color-primary, #8a9a7b);
|
--color-sage: var(--color-primary, #8a9a7b);
|
||||||
|
|
@ -63,9 +44,7 @@
|
||||||
--fg-body: var(--color-text, #2c2c2c);
|
--fg-body: var(--color-text, #2c2c2c);
|
||||||
background: var(--color-bg, #faf8f5);
|
background: var(--color-bg, #faf8f5);
|
||||||
color: var(--fg-body);
|
color: var(--fg-body);
|
||||||
font-family: var(--font-sans);
|
font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||||
/* Site design → Style → Text size; rem-sized spacing grows with it. */
|
|
||||||
font-size: var(--site-text-size, 100%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Foreground colour utilities (set per-block via BackgroundWrapper) ── */
|
/* ── Foreground colour utilities (set per-block via BackgroundWrapper) ── */
|
||||||
|
|
@ -95,7 +74,7 @@ h1,
|
||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
h4 {
|
h4 {
|
||||||
font-family: var(--font-serif);
|
font-family: 'Playfair Display', Georgia, serif;
|
||||||
color: var(--fg-heading, #2c2c2c);
|
color: var(--fg-heading, #2c2c2c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +114,7 @@ h4 {
|
||||||
margin: 0.75rem 0;
|
margin: 0.75rem 0;
|
||||||
padding-left: 1.25rem;
|
padding-left: 1.25rem;
|
||||||
border-left: 3px solid var(--color-primary, #8a9a7b);
|
border-left: 3px solid var(--color-primary, #8a9a7b);
|
||||||
font-family: var(--font-serif);
|
font-family: 'Playfair Display', Georgia, serif;
|
||||||
font-size: 1.35rem;
|
font-size: 1.35rem;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
@ -157,13 +136,12 @@ h4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Scroll-reveal animations ── */
|
/* ── Scroll-reveal animations ── */
|
||||||
/* Kept short: blocks fading in while someone scrolls are what slows scrolling down. */
|
|
||||||
.reveal {
|
.reveal {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(16px);
|
transform: translateY(30px);
|
||||||
transition:
|
transition:
|
||||||
opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
|
opacity 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
|
||||||
transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
|
transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal-visible {
|
.reveal-visible {
|
||||||
|
|
@ -174,8 +152,8 @@ h4 {
|
||||||
/* ── Hero fade-in stagger ── */
|
/* ── Hero fade-in stagger ── */
|
||||||
.animate-fade-in {
|
.animate-fade-in {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(12px);
|
transform: translateY(20px);
|
||||||
animation: fadeInUp 0.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
|
animation: fadeInUp 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeInUp {
|
@keyframes fadeInUp {
|
||||||
|
|
@ -189,27 +167,3 @@ h4 {
|
||||||
html {
|
html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No animations on devices that can't keep up (scrollReveal.ts adds .plain-motion
|
|
||||||
to <html>) or for people whose device asks for less motion. */
|
|
||||||
html.plain-motion .reveal,
|
|
||||||
html.plain-motion .animate-fade-in {
|
|
||||||
opacity: 1;
|
|
||||||
transform: none;
|
|
||||||
transition: none;
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.reveal,
|
|
||||||
.animate-fade-in {
|
|
||||||
opacity: 1;
|
|
||||||
transform: none;
|
|
||||||
transition: none;
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
scroll-behavior: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<header class="sticky top-0 z-40 border-b border-charcoal/5 bg-warm/95">
|
<header class="sticky top-0 z-40 border-b border-charcoal/5 bg-warm/90 backdrop-blur">
|
||||||
<div class="mx-auto flex max-w-6xl items-center justify-between gap-3 px-4 py-3 sm:px-6 md:gap-4 md:py-4">
|
<div class="mx-auto flex max-w-6xl items-center justify-between gap-3 px-4 py-3 sm:px-6 md:gap-4 md:py-4">
|
||||||
<a class="flex min-w-0 items-center gap-3" href="/" aria-label="Home">
|
<a class="flex min-w-0 items-center gap-3" href="/" aria-label="Home">
|
||||||
{#if header.logo?.url}
|
{#if header.logo?.url}
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
<div class="flex shrink-0 items-center gap-2 md:gap-3">
|
<div class="flex shrink-0 items-center gap-2 md:gap-3">
|
||||||
{#if hasItems}
|
{#if hasItems}
|
||||||
<a
|
<a
|
||||||
class="relative flex items-center gap-2 rounded-button border border-charcoal/10 px-3 py-2 text-sm font-semibold text-charcoal/80 transition hover:border-sage hover:text-sage-dark md:px-4"
|
class="relative flex items-center gap-2 rounded-full border border-charcoal/10 px-3 py-2 text-sm font-semibold text-charcoal/80 transition hover:border-sage hover:text-sage-dark md:px-4"
|
||||||
href={links.basket}
|
href={links.basket}
|
||||||
aria-label="View your basket ({basket.count})"
|
aria-label="View your basket ({basket.count})"
|
||||||
>
|
>
|
||||||
|
|
@ -74,10 +74,10 @@
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if header.ctaButton?.label}
|
{#if header.ctaButton?.label}
|
||||||
<a class="cta btn hidden rounded-button border-0 px-6 hover:opacity-90 md:inline-flex" href={links.booking}>{header.ctaButton.label}</a>
|
<a class="cta btn hidden rounded-full border-0 px-6 hover:opacity-90 md:inline-flex" href={links.booking}>{header.ctaButton.label}</a>
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
class="grid h-10 w-10 place-items-center rounded-button text-charcoal/80 transition hover:bg-charcoal/5 md:hidden"
|
class="grid h-10 w-10 place-items-center rounded-full text-charcoal/80 transition hover:bg-charcoal/5 md:hidden"
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Open menu"
|
aria-label="Open menu"
|
||||||
aria-haspopup="dialog"
|
aria-haspopup="dialog"
|
||||||
|
|
@ -98,7 +98,7 @@
|
||||||
<div class="flex h-full flex-col">
|
<div class="flex h-full flex-col">
|
||||||
<div class="flex items-center justify-between border-b border-charcoal/10 px-6 py-4">
|
<div class="flex items-center justify-between border-b border-charcoal/10 px-6 py-4">
|
||||||
<span class="font-serif text-xl font-bold text-charcoal">Menu</span>
|
<span class="font-serif text-xl font-bold text-charcoal">Menu</span>
|
||||||
<button class="grid h-10 w-10 place-items-center rounded-button text-charcoal/80 transition hover:bg-charcoal/5" type="button" aria-label="Close menu" onclick={closeMenu}>
|
<button class="grid h-10 w-10 place-items-center rounded-full text-charcoal/80 transition hover:bg-charcoal/5" type="button" aria-label="Close menu" onclick={closeMenu}>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
|
||||||
<path stroke-linecap="round" d="M6 6l12 12M18 6L6 18" />
|
<path stroke-linecap="round" d="M6 6l12 12M18 6L6 18" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
{#if header.ctaButton?.label}
|
{#if header.ctaButton?.label}
|
||||||
<div class="border-t border-charcoal/10 p-6">
|
<div class="border-t border-charcoal/10 p-6">
|
||||||
<a class="cta btn btn-block rounded-button border-0 hover:opacity-90" href={links.booking}>{header.ctaButton.label}</a>
|
<a class="cta btn btn-block rounded-full border-0 hover:opacity-90" href={links.booking}>{header.ctaButton.label}</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
// The fonts Site design → Style offers (SITE_FONTS in $shared/theme), bundled
|
|
||||||
// and served by this app, not loaded from Google: a Google Fonts request sends
|
|
||||||
// every visitor's IP address to Google (GDPR). Each import only declares the
|
|
||||||
// font; a browser downloads the files of the fonts a page actually uses.
|
|
||||||
import '@fontsource-variable/playfair-display';
|
|
||||||
import '@fontsource-variable/cormorant-garamond';
|
|
||||||
import '@fontsource-variable/eb-garamond';
|
|
||||||
import '@fontsource-variable/libre-baskerville';
|
|
||||||
import '@fontsource-variable/lora';
|
|
||||||
import '@fontsource-variable/fraunces';
|
|
||||||
import '@fontsource-variable/dm-sans';
|
|
||||||
import '@fontsource-variable/inter';
|
|
||||||
import '@fontsource-variable/manrope';
|
|
||||||
import '@fontsource-variable/montserrat';
|
|
||||||
import '@fontsource-variable/nunito';
|
|
||||||
import '@fontsource-variable/outfit';
|
|
||||||
import '@fontsource-variable/raleway';
|
|
||||||
import '@fontsource-variable/work-sans';
|
|
||||||
import '@fontsource-variable/josefin-sans';
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { defaultColors, defaultFooter, defaultHeader, defaultStyle } from '$lib/types';
|
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||||
import type { ItemRecord } from '$lib/types';
|
import type { ItemRecord } from '$lib/types';
|
||||||
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
|
import { BASKET_COOKIE, getBasket } from '$lib/server/shop';
|
||||||
import { loadShopData } from '$shared/server/shop';
|
import { loadShopData } from '$shared/server/shop';
|
||||||
|
|
@ -21,11 +21,10 @@ export const load: LayoutServerLoad = async ({ locals, cookies, url }) => {
|
||||||
// Shop blocks fetch bookable times themselves (GET /api/slots).
|
// Shop blocks fetch bookable times themselves (GET /api/slots).
|
||||||
void url.pathname;
|
void url.pathname;
|
||||||
|
|
||||||
const [header, footer, colors, style] = await Promise.all([
|
const [header, footer, colors] = await Promise.all([
|
||||||
getGlobal(locals.pb, 'header', defaultHeader),
|
getGlobal(locals.pb, 'header', defaultHeader),
|
||||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||||
getGlobal(locals.pb, 'colors', defaultColors),
|
getGlobal(locals.pb, 'colors', defaultColors)
|
||||||
getGlobal(locals.pb, 'style', defaultStyle)
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!header.homePage) header.homePage = defaultHeader.homePage;
|
if (!header.homePage) header.homePage = defaultHeader.homePage;
|
||||||
|
|
@ -48,5 +47,5 @@ export const load: LayoutServerLoad = async ({ locals, cookies, url }) => {
|
||||||
// Prices are shown in the currency Stripe charges in.
|
// Prices are shown in the currency Stripe charges in.
|
||||||
const currency = shopCurrency(env.STRIPE_CURRENCY);
|
const currency = shopCurrency(env.STRIPE_CURRENCY);
|
||||||
|
|
||||||
return { header, footer, colors, style, user: locals.user, basket, items, timezone, currency };
|
return { header, footer, colors, user: locals.user, basket, items, timezone, currency };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
import '$lib/fonts';
|
// Fonts are bundled and served by this app, not loaded from Google: a
|
||||||
|
// Google Fonts request sends every visitor's IP address to Google (GDPR).
|
||||||
|
import '@fontsource/dm-sans/400.css';
|
||||||
|
import '@fontsource/dm-sans/500.css';
|
||||||
|
import '@fontsource/dm-sans/600.css';
|
||||||
|
import '@fontsource/dm-sans/700.css';
|
||||||
|
import '@fontsource/playfair-display/600.css';
|
||||||
|
import '@fontsource/playfair-display/700.css';
|
||||||
import favicon from '$lib/assets/favicon.svg';
|
import favicon from '$lib/assets/favicon.svg';
|
||||||
import Header from '$lib/components/Header.svelte';
|
import Header from '$lib/components/Header.svelte';
|
||||||
import Footer from '$lib/components/Footer.svelte';
|
import Footer from '$lib/components/Footer.svelte';
|
||||||
|
|
@ -28,9 +35,9 @@
|
||||||
<!-- Home-screen icon on phones; iOS ignores SVG, so only for an uploaded logo. -->
|
<!-- Home-screen icon on phones; iOS ignores SVG, so only for an uploaded logo. -->
|
||||||
{#if icon !== favicon}<link rel="apple-touch-icon" href={icon} />{/if}
|
{#if icon !== favicon}<link rel="apple-touch-icon" href={icon} />{/if}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<!-- Site colours and style, rendered server-side (previously applied in onMount, which
|
<!-- Site colours, rendered server-side (previously applied in onMount, which
|
||||||
flashed the defaults on every page load). Values are sanitised. -->
|
flashed the defaults on every page load). Values are sanitised. -->
|
||||||
{@html rootStyleTag(siteThemeVars(data.colors, data.style))}
|
{@html rootStyleTag(siteThemeVars(data.colors))}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Header header={data.header} />
|
<Header header={data.header} />
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
Your booking is confirmed. A receipt was sent to <strong>{data.order.email}</strong>.
|
Your booking is confirmed. A receipt was sent to <strong>{data.order.email}</strong>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="mt-8 rounded-2xl border border-charcoal/10 bg-white/60 p-6 text-left">
|
<div class="mt-8 rounded-box border border-charcoal/10 bg-white/60 p-6 text-left">
|
||||||
<h2 class="font-serif text-xl">Your order</h2>
|
<h2 class="font-serif text-xl">Your order</h2>
|
||||||
<ul class="mt-4 space-y-3">
|
<ul class="mt-4 space-y-3">
|
||||||
{#each data.order.lines ?? [] as line}
|
{#each data.order.lines ?? [] as line}
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
{#if data.order.passes?.length}
|
{#if data.order.passes?.length}
|
||||||
<!-- Bundles bought: their codes (also in the confirmation email). -->
|
<!-- Bundles bought: their codes (also in the confirmation email). -->
|
||||||
<div class="mt-6 rounded-2xl border border-sage/40 bg-sage/10 p-6 text-left">
|
<div class="mt-6 rounded-box border border-sage/40 bg-sage/10 p-6 text-left">
|
||||||
<h2 class="font-serif text-xl">Your {data.order.passes.length === 1 ? 'code' : 'codes'}</h2>
|
<h2 class="font-serif text-xl">Your {data.order.passes.length === 1 ? 'code' : 'codes'}</h2>
|
||||||
<p class="mt-1 text-sm text-charcoal/70">Enter a code in the basket when you book — the sessions it includes are then already paid for.</p>
|
<p class="mt-1 text-sm text-charcoal/70">Enter a code in the basket when you book — the sessions it includes are then already paid for.</p>
|
||||||
{#each data.order.passes as pass (pass.id)}
|
{#each data.order.passes as pass (pass.id)}
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<a class="btn mt-8 rounded-button border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Book another</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Book another</a>
|
||||||
{:else if data.state === 'processing'}
|
{:else if data.state === 'processing'}
|
||||||
<h1 class="font-serif text-4xl">Processing your payment…</h1>
|
<h1 class="font-serif text-4xl">Processing your payment…</h1>
|
||||||
<p class="mt-3 text-charcoal/70">
|
<p class="mt-3 text-charcoal/70">
|
||||||
|
|
@ -82,10 +82,10 @@
|
||||||
{:else if data.state === 'canceled' || data.state === 'failed'}
|
{:else if data.state === 'canceled' || data.state === 'failed'}
|
||||||
<h1 class="font-serif text-4xl">Payment not completed</h1>
|
<h1 class="font-serif text-4xl">Payment not completed</h1>
|
||||||
<p class="mt-3 text-charcoal/70">Your payment didn't go through — no money was captured. Please try again.</p>
|
<p class="mt-3 text-charcoal/70">Your payment didn't go through — no money was captured. Please try again.</p>
|
||||||
<a class="btn mt-8 rounded-button border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.basket}>Back to your basket</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.basket}>Back to your basket</a>
|
||||||
{:else}
|
{:else}
|
||||||
<h1 class="font-serif text-4xl">Nothing to see here</h1>
|
<h1 class="font-serif text-4xl">Nothing to see here</h1>
|
||||||
<p class="mt-3 text-charcoal/70">This link is missing a payment reference.</p>
|
<p class="mt-3 text-charcoal/70">This link is missing a payment reference.</p>
|
||||||
<a class="btn mt-8 rounded-button border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Back to the shop</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Back to the shop</a>
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,12 @@ services:
|
||||||
# Pinned: schema (pb_schema.json) and migrations target this version's
|
# Pinned: schema (pb_schema.json) and migrations target this version's
|
||||||
# format/JS API. Upgrade deliberately — read the PocketBase changelog,
|
# format/JS API. Upgrade deliberately — read the PocketBase changelog,
|
||||||
# back up pb_data, then bump the tag and test migrations locally.
|
# back up pb_data, then bump the tag and test migrations locally.
|
||||||
# Digest-pinned too, so a re-pushed tag can't change what runs.
|
image: docker.io/spectado/pocketbase:0.23.12
|
||||||
# This image runs as a non-root `pocketbase` user (uid 100) on port 8090
|
|
||||||
# and finds /pb_migrations and /pb_hooks next to /pb_data by default.
|
|
||||||
# Data written by the old root-run image (spectado/pocketbase, now gone)
|
|
||||||
# must be chown'ed once — see the README's "Switching PocketBase image".
|
|
||||||
image: docker.io/elestio/pocketbase:v0.40.6@sha256:936756ccefb13cedaf2e7c49745412455bc81f2d1a511132f4012e411b970437
|
|
||||||
container_name: massage-pocketbase
|
container_name: massage-pocketbase
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# Internal only — accessed via the caddy reverse proxy
|
# Internal only — accessed via the caddy reverse proxy
|
||||||
expose:
|
expose:
|
||||||
- "8090"
|
- "80"
|
||||||
volumes:
|
volumes:
|
||||||
- pocketbase:/pb_data
|
- pocketbase:/pb_data
|
||||||
# Versioned schema changes; PocketBase applies pending ones on start.
|
# Versioned schema changes; PocketBase applies pending ones on start.
|
||||||
|
|
@ -38,7 +33,7 @@ services:
|
||||||
- pocketbase
|
- pocketbase
|
||||||
environment:
|
environment:
|
||||||
PORT: 3001
|
PORT: 3001
|
||||||
POCKETBASE_INTERNAL_URL: http://pocketbase:8090
|
POCKETBASE_INTERNAL_URL: http://pocketbase:80
|
||||||
# Browser-facing URLs. They must match the address bar exactly, or
|
# Browser-facing URLs. They must match the address bar exactly, or
|
||||||
# SvelteKit rejects logins/forms ("Cross-site POST form submissions are
|
# SvelteKit rejects logins/forms ("Cross-site POST form submissions are
|
||||||
# forbidden"). Behind a TLS proxy: URL_SCHEME=https and URL_PORT= (empty).
|
# forbidden"). Behind a TLS proxy: URL_SCHEME=https and URL_PORT= (empty).
|
||||||
|
|
@ -69,7 +64,7 @@ services:
|
||||||
- pocketbase
|
- pocketbase
|
||||||
environment:
|
environment:
|
||||||
PORT: 3000
|
PORT: 3000
|
||||||
POCKETBASE_INTERNAL_URL: http://pocketbase:8090
|
POCKETBASE_INTERNAL_URL: http://pocketbase:80
|
||||||
PUBLIC_POCKETBASE_URL: ${URL_SCHEME:-http}://db.${DOMAIN:-localhost}${URL_PORT-:8080}
|
PUBLIC_POCKETBASE_URL: ${URL_SCHEME:-http}://db.${DOMAIN:-localhost}${URL_PORT-:8080}
|
||||||
ORIGIN: ${URL_SCHEME:-http}://www.${DOMAIN:-localhost}${URL_PORT-:8080}
|
ORIGIN: ${URL_SCHEME:-http}://www.${DOMAIN:-localhost}${URL_PORT-:8080}
|
||||||
# No PocketBase or Stripe secrets here: shop writes happen in PocketBase
|
# No PocketBase or Stripe secrets here: shop writes happen in PocketBase
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@stripe/stripe-js": "^9.12.1",
|
"@stripe/stripe-js": "^9.12.1",
|
||||||
"nodemailer": "^10.0.12",
|
"nodemailer": "^10.0.12",
|
||||||
"pocketbase": "^0.28.2"
|
"pocketbase": "^0.26.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/nodemailer": "^8.0.2"
|
"@types/nodemailer": "^8.0.2"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
<div class="flex {alignmentClasses[data.alignment] || 'justify-center'}">
|
<div class="flex {alignmentClasses[data.alignment] || 'justify-center'}">
|
||||||
<a
|
<a
|
||||||
href={data.href || '#'}
|
href={data.href || '#'}
|
||||||
class="btn rounded-button {variantClasses[data.variant] || 'btn-primary'} {sizeClasses[data.size] || ''}"
|
class="btn {variantClasses[data.variant] || 'btn-primary'} {sizeClasses[data.size] || ''}"
|
||||||
style={data.color ? `background-color: ${data.color}; border-color: ${data.color};` : ''}
|
style={data.color ? `background-color: ${data.color}; border-color: ${data.color};` : ''}
|
||||||
>
|
>
|
||||||
{data.label || 'Button'}
|
{data.label || 'Button'}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="mt-6 grid gap-6 grid-cols-[repeat(auto-fit,minmax(200px,1fr))]">
|
<div class="mt-6 grid gap-6 grid-cols-[repeat(auto-fit,minmax(200px,1fr))]">
|
||||||
{#each data.items || [] as card, i (i)}
|
{#each data.items || [] as card, i (i)}
|
||||||
<!-- Cards are white whatever the block's colours, so they use the site's own text colour. -->
|
<!-- Cards are white whatever the block's colours, so they use the site's own text colour. -->
|
||||||
<div class="relative overflow-hidden rounded-card bg-white text-[color-mix(in_srgb,var(--color-text,#2c2c2c)_85%,transparent)] shadow-sm transition-shadow {card.href ? 'hover:shadow-lg' : ''}">
|
<div class="relative overflow-hidden rounded-[1.25rem] bg-white text-[color-mix(in_srgb,var(--color-text,#2c2c2c)_85%,transparent)] shadow-[0_1px_6px_rgba(0,0,0,0.08)] transition-shadow {card.href ? 'hover:shadow-lg' : ''}">
|
||||||
{#if !numbered && card.imageUrl}
|
{#if !numbered && card.imageUrl}
|
||||||
<img class="block aspect-[4/3] w-full object-cover" src={card.imageUrl} alt={card.imageAlt || ''} />
|
<img class="block aspect-[4/3] w-full object-cover" src={card.imageUrl} alt={card.imageAlt || ''} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@
|
||||||
{#if shopAbove}
|
{#if shopAbove}
|
||||||
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
|
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
|
||||||
{:else}
|
{:else}
|
||||||
<a class="mt-6 inline-flex rounded-button bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark" href={bookingHref}>Book a session</a>
|
<a class="mt-6 inline-flex rounded-full bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark" href={bookingHref}>Book a session</a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
@ -380,7 +380,7 @@
|
||||||
{#if ending && payState !== 'confirming'}
|
{#if ending && payState !== 'confirming'}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded-button border border-charcoal/20 bg-white px-4 py-1.5 font-medium transition hover:bg-charcoal/5 disabled:opacity-60"
|
class="rounded-full border border-charcoal/20 bg-white px-4 py-1.5 font-medium transition hover:bg-charcoal/5 disabled:opacity-60"
|
||||||
disabled={renewing}
|
disabled={renewing}
|
||||||
onclick={renewHolds}
|
onclick={renewHolds}
|
||||||
>
|
>
|
||||||
|
|
@ -394,8 +394,7 @@
|
||||||
<ul class="{holdLeftMs !== null && slotLineCount ? 'mt-4' : 'mt-8'} space-y-4">
|
<ul class="{holdLeftMs !== null && slotLineCount ? 'mt-4' : 'mt-8'} space-y-4">
|
||||||
{#each basket.lines as line (line.id)}
|
{#each basket.lines as line (line.id)}
|
||||||
{@const pending = pendingLines.has(line.id)}
|
{@const pending = pendingLines.has(line.id)}
|
||||||
<!-- On a phone the quantity, price and remove button go on a row of their own under the description. -->
|
<li class="flex items-center gap-4 rounded-2xl border border-charcoal/10 bg-white p-4 shadow-sm">
|
||||||
<li class="flex flex-wrap items-center gap-x-4 gap-y-3 rounded-2xl border border-charcoal/10 bg-white p-4 shadow-sm">
|
|
||||||
{#if line.itemImageUrl}
|
{#if line.itemImageUrl}
|
||||||
<img
|
<img
|
||||||
src={line.itemImageUrl}
|
src={line.itemImageUrl}
|
||||||
|
|
@ -409,7 +408,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="min-w-0 flex-1">
|
<div class="min-w-0 flex-1">
|
||||||
<p class="break-words font-medium">{line.itemName ?? 'Item'}</p>
|
<p class="truncate font-medium">{line.itemName ?? 'Item'}</p>
|
||||||
{#if line.lineType === 'slot' && line.start}
|
{#if line.lineType === 'slot' && line.start}
|
||||||
<p class="text-sm text-fg-body/70">{formatSlotTime(line.start)}{line.minutes ? ` · ${formatDuration(line.minutes)}` : ''}</p>
|
<p class="text-sm text-fg-body/70">{formatSlotTime(line.start)}{line.minutes ? ` · ${formatDuration(line.minutes)}` : ''}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -454,46 +453,44 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex w-full items-center gap-3 sm:w-auto">
|
<!-- Products, and places in a group session (capacity > 1); the server checks what's left. -->
|
||||||
<!-- Products, and places in a group session (capacity > 1); the server checks what's left. -->
|
{#if line.lineType === 'item' || (line.slotCapacity ?? 1) > 1}
|
||||||
{#if line.lineType === 'item' || (line.slotCapacity ?? 1) > 1}
|
<div class="flex items-center gap-2">
|
||||||
<div class="flex items-center gap-2">
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none disabled:opacity-40"
|
||||||
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none disabled:opacity-40"
|
disabled={pending || line.quantity <= 1}
|
||||||
disabled={pending || line.quantity <= 1}
|
aria-label="Decrease quantity"
|
||||||
aria-label="Decrease quantity"
|
onclick={() => changeQuantity(line.id, line.quantity, -1)}
|
||||||
onclick={() => changeQuantity(line.id, line.quantity, -1)}
|
>
|
||||||
>
|
−
|
||||||
−
|
</button>
|
||||||
</button>
|
<span class="w-6 text-center">{line.quantity}</span>
|
||||||
<span class="w-6 text-center">{line.quantity}</span>
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none disabled:opacity-40"
|
||||||
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none disabled:opacity-40"
|
disabled={pending}
|
||||||
disabled={pending}
|
aria-label="Increase quantity"
|
||||||
aria-label="Increase quantity"
|
onclick={() => changeQuantity(line.id, line.quantity, 1)}
|
||||||
onclick={() => changeQuantity(line.id, line.quantity, 1)}
|
>
|
||||||
>
|
+
|
||||||
+
|
</button>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
|
||||||
|
|
||||||
<p class="ml-auto shrink-0 whitespace-nowrap text-right font-medium sm:min-w-20">
|
<p class="w-20 shrink-0 text-right font-medium">
|
||||||
{formatPrice((line.itemPrice ?? 0) * line.quantity, currency)}
|
{formatPrice((line.itemPrice ?? 0) * line.quantity, currency)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-button text-charcoal/50 transition-colors hover:bg-terracotta/10 hover:text-terracotta disabled:opacity-40"
|
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-charcoal/50 transition-colors hover:bg-terracotta/10 hover:text-terracotta disabled:opacity-40"
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
aria-label="Remove {line.itemName ?? 'item'}"
|
aria-label="Remove {line.itemName ?? 'item'}"
|
||||||
onclick={() => removeLine(line.id)}
|
onclick={() => removeLine(line.id)}
|
||||||
>
|
>
|
||||||
✕
|
✕
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -542,7 +539,7 @@
|
||||||
class="w-36 rounded-xl border border-charcoal/15 bg-white px-3 py-2 font-mono tracking-wider uppercase focus:ring-2 focus:ring-sage/50 focus:outline-none"
|
class="w-36 rounded-xl border border-charcoal/15 bg-white px-3 py-2 font-mono tracking-wider uppercase focus:ring-2 focus:ring-sage/50 focus:outline-none"
|
||||||
bind:value={codeInput}
|
bind:value={codeInput}
|
||||||
/>
|
/>
|
||||||
<button type="submit" class="rounded-button border border-charcoal/20 px-4 py-2 text-sm font-medium transition hover:bg-charcoal/5 disabled:opacity-50" disabled={codeBusy || !codeInput.trim()}>
|
<button type="submit" class="rounded-full border border-charcoal/20 px-4 py-2 text-sm font-medium transition hover:bg-charcoal/5 disabled:opacity-50" disabled={codeBusy || !codeInput.trim()}>
|
||||||
{codeBusy ? 'Checking…' : 'Apply'}
|
{codeBusy ? 'Checking…' : 'Apply'}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -617,7 +614,7 @@
|
||||||
{#if payState === 'idle' || payState === 'creating'}
|
{#if payState === 'idle' || payState === 'creating'}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn w-full rounded-button border-0 text-primary-content"
|
class="btn w-full rounded-full border-0 text-primary-content"
|
||||||
style="background-color: var(--color-primary, #8a9a7b);"
|
style="background-color: var(--color-primary, #8a9a7b);"
|
||||||
disabled={payState === 'creating'}
|
disabled={payState === 'creating'}
|
||||||
>
|
>
|
||||||
|
|
@ -652,7 +649,7 @@
|
||||||
{#if payState === 'ready' || payState === 'confirming'}
|
{#if payState === 'ready' || payState === 'confirming'}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn mt-4 w-full rounded-button border-0 text-primary-content"
|
class="btn mt-4 w-full rounded-full border-0 text-primary-content"
|
||||||
style="background-color: var(--color-primary, #8a9a7b);"
|
style="background-color: var(--color-primary, #8a9a7b);"
|
||||||
disabled={payState === 'confirming'}
|
disabled={payState === 'confirming'}
|
||||||
onclick={confirmPayment}
|
onclick={confirmPayment}
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@
|
||||||
|
|
||||||
<section class="relative flex min-h-[80vh] items-center justify-center overflow-hidden px-6 py-20 md:min-h-[90vh]">
|
<section class="relative flex min-h-[80vh] items-center justify-center overflow-hidden px-6 py-20 md:min-h-[90vh]">
|
||||||
<div class="relative z-10 mx-auto max-w-4xl text-center">
|
<div class="relative z-10 mx-auto max-w-4xl text-center">
|
||||||
<h1 class="animate-fade-in text-5xl leading-tight text-fg-heading md:text-7xl lg:text-8xl">
|
<h1 class="animate-fade-in text-5xl leading-tight text-fg-heading md:text-7xl lg:text-8xl" style="font-family: 'Playfair Display', Georgia, serif;">
|
||||||
{data.heading || 'Holistic and Experiential Learning about Happiness'}
|
{data.heading || 'Holistic and Experiential Learning about Happiness'}
|
||||||
</h1>
|
</h1>
|
||||||
{#if data.subheading}
|
{#if data.subheading}
|
||||||
<p class="animate-fade-in mx-auto mt-6 max-w-2xl text-lg leading-relaxed text-fg-subheading/70 md:text-xl" style="animation-delay: 0.1s;">
|
<p class="animate-fade-in mx-auto mt-6 max-w-2xl text-lg leading-relaxed text-fg-subheading/70 md:text-xl" style="animation-delay: 0.15s;">
|
||||||
{data.subheading}
|
{data.subheading}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.buttonLabel}
|
{#if data.buttonLabel}
|
||||||
<div class="animate-fade-in mt-10" style="animation-delay: 0.2s;">
|
<div class="animate-fade-in mt-10" style="animation-delay: 0.3s;">
|
||||||
<a class="btn rounded-button border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || shopLinks(page.data.header).booking}>
|
<a class="btn rounded-full border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || shopLinks(page.data.header).booking}>
|
||||||
{data.buttonLabel}
|
{data.buttonLabel}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<section use:scrollReveal class="reveal mx-auto max-w-6xl px-6 py-14 md:py-20">
|
<section use:scrollReveal class="reveal mx-auto max-w-6xl px-6 py-14 md:py-20">
|
||||||
<div class="grid items-center gap-10 md:grid-cols-2">
|
<div class="grid items-center gap-10 md:grid-cols-2">
|
||||||
<div class:md:order-2={data.imagePosition === 'right'} class="overflow-hidden rounded-panel bg-sage/10 shadow-sm">
|
<div class:md:order-2={data.imagePosition === 'right'} class="overflow-hidden rounded-[2rem] bg-sage/10 shadow-sm">
|
||||||
{#if data.url}
|
{#if data.url}
|
||||||
<img class="aspect-[4/5] w-full object-cover" src={data.url} alt={data.alt || ''} />
|
<img class="aspect-[4/5] w-full object-cover" src={data.url} alt={data.alt || ''} />
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { shopLinks, type BasketLine, type BookableTime, type ShopBlockData, type ShopSort, type ItemRecord } from '$shared/types';
|
import { shopLinks, type BasketLine, type BookableTime, type ShopBlockData, type ItemRecord } from '$shared/types';
|
||||||
import { getBasketContext } from '$shared/basket.svelte';
|
import { getBasketContext } from '$shared/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
|
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
|
||||||
import { SHOP_SORTS, bundleListPrice, formatDuration, lowestPrice, sortItems } from '$shared/items';
|
import { bundleListPrice, formatDuration, lowestPrice } from '$shared/items';
|
||||||
import { addDaysToKey, formatDateKey } from '$shared/slots';
|
import { addDaysToKey, formatDateKey } from '$shared/slots';
|
||||||
|
|
||||||
let { data = {}, items = [] } = $props<{
|
let { data = {}, items = [] } = $props<{
|
||||||
|
|
@ -55,22 +55,13 @@
|
||||||
}
|
}
|
||||||
if (data.itemIds?.length) {
|
if (data.itemIds?.length) {
|
||||||
const wanted = new Set(data.itemIds);
|
const wanted = new Set(data.itemIds);
|
||||||
result = result.filter((i) => wanted.has(i.id));
|
result = result
|
||||||
|
.filter((i) => wanted.has(i.id))
|
||||||
|
.sort((a, b) => data.itemIds!.indexOf(a.id) - data.itemIds!.indexOf(b.id));
|
||||||
}
|
}
|
||||||
return sortItems(result, sort);
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** What the visitor picked in "Sort by" (only while the menu is shown); else the block's own order. */
|
|
||||||
let pickedSort = $state<ShopSort | null>(null);
|
|
||||||
// "Most popular" needs recent sales to go by; without any it would only repeat Recommended, so it's left out.
|
|
||||||
let hasSales = $derived(items.some((item: ItemRecord) => item.popularRank !== null));
|
|
||||||
let sort = $derived.by<ShopSort>(() => {
|
|
||||||
const wanted = (data.showSort && pickedSort) || data.sort || 'recommended';
|
|
||||||
return wanted === 'popular' && !hasSales ? 'recommended' : wanted;
|
|
||||||
});
|
|
||||||
let sortChoices = $derived(SHOP_SORTS.filter((choice) => choice.value !== 'popular' || hasSales));
|
|
||||||
let showSortMenu = $derived(!!data.showSort && visibleItems.length > 1);
|
|
||||||
|
|
||||||
let isList = $derived(data.layout === 'list');
|
let isList = $derived(data.layout === 'list');
|
||||||
|
|
||||||
/** Item id → name, for what bundles contain. */
|
/** Item id → name, for what bundles contain. */
|
||||||
|
|
@ -286,24 +277,7 @@
|
||||||
|
|
||||||
<section class="mx-auto max-w-6xl px-6 py-16">
|
<section class="mx-auto max-w-6xl px-6 py-16">
|
||||||
{#if data.title}
|
{#if data.title}
|
||||||
<h2 class={showSortMenu ? 'mb-8 text-center font-serif text-3xl text-charcoal md:text-4xl' : 'mb-12 text-center font-serif text-3xl text-charcoal md:text-4xl'}>{data.title}</h2>
|
<h2 class="mb-12 text-center font-serif text-3xl text-charcoal md:text-4xl">{data.title}</h2>
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if showSortMenu}
|
|
||||||
<div class="mb-6 flex justify-end">
|
|
||||||
<label class="inline-flex items-center gap-2 text-sm text-charcoal/70">
|
|
||||||
Sort by
|
|
||||||
<select
|
|
||||||
class="rounded-button border border-charcoal/15 bg-white py-1.5 pr-8 pl-3.5 text-sm text-charcoal"
|
|
||||||
value={sort}
|
|
||||||
onchange={(e) => (pickedSort = e.currentTarget.value as ShopSort)}
|
|
||||||
>
|
|
||||||
{#each sortChoices as choice (choice.value)}
|
|
||||||
<option value={choice.value}>{choice.label}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if !visibleItems.length}
|
{#if !visibleItems.length}
|
||||||
|
|
@ -379,11 +353,11 @@
|
||||||
{#if duration}
|
{#if duration}
|
||||||
<span class="text-xs text-charcoal/60">{formatDuration(duration.minutes)}</span>
|
<span class="text-xs text-charcoal/60">{formatDuration(duration.minutes)}</span>
|
||||||
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
|
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
|
||||||
<span class="rounded-button bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
|
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
|
||||||
Only {item.stock} left
|
Only {item.stock} left
|
||||||
</span>
|
</span>
|
||||||
{:else if soldOut}
|
{:else if soldOut}
|
||||||
<span class="rounded-button bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
|
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
|
||||||
Sold out
|
Sold out
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -412,7 +386,7 @@
|
||||||
{#if isService}
|
{#if isService}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center justify-center gap-2 rounded-button px-6 py-2.5 text-sm font-medium transition {ui?.pickerOpen
|
class="inline-flex items-center justify-center gap-2 rounded-full px-6 py-2.5 text-sm font-medium transition {ui?.pickerOpen
|
||||||
? 'border border-charcoal/15 text-charcoal hover:bg-charcoal/5'
|
? 'border border-charcoal/15 text-charcoal hover:bg-charcoal/5'
|
||||||
: bookable
|
: bookable
|
||||||
? 'bg-sage text-primary-content hover:bg-sage-dark'
|
? 'bg-sage text-primary-content hover:bg-sage-dark'
|
||||||
|
|
@ -426,7 +400,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center justify-center gap-2 rounded-button bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark disabled:cursor-not-allowed disabled:bg-charcoal/10 disabled:text-charcoal/50"
|
class="inline-flex items-center justify-center gap-2 rounded-full bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark disabled:cursor-not-allowed disabled:bg-charcoal/10 disabled:text-charcoal/50"
|
||||||
disabled={soldOut || ui?.adding}
|
disabled={soldOut || ui?.adding}
|
||||||
onclick={() => addItem(item.id)}
|
onclick={() => addItem(item.id)}
|
||||||
>
|
>
|
||||||
|
|
@ -483,7 +457,7 @@
|
||||||
<div class="mb-3 flex items-center justify-between gap-2">
|
<div class="mb-3 flex items-center justify-between gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
|
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
|
||||||
aria-label="Previous month"
|
aria-label="Previous month"
|
||||||
disabled={ui.monthOffset <= 0}
|
disabled={ui.monthOffset <= 0}
|
||||||
onclick={() => ui.monthOffset--}
|
onclick={() => ui.monthOffset--}
|
||||||
|
|
@ -496,7 +470,7 @@
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
|
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
|
||||||
aria-label="Next month"
|
aria-label="Next month"
|
||||||
disabled={ui.monthOffset >= MAX_MONTH_OFFSET}
|
disabled={ui.monthOffset >= MAX_MONTH_OFFSET}
|
||||||
onclick={() => ui.monthOffset++}
|
onclick={() => ui.monthOffset++}
|
||||||
|
|
@ -515,7 +489,7 @@
|
||||||
<span>The next available date for {formatDuration(duration.minutes)} is <strong>{longDate(zonedDateKey(ui.next, timezone))}</strong>.</span>
|
<span>The next available date for {formatDuration(duration.minutes)} is <strong>{longDate(zonedDateKey(ui.next, timezone))}</strong>.</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded-button bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
|
class="rounded-full bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
|
||||||
onclick={() => showDay(item.id, ui.next!)}
|
onclick={() => showDay(item.id, ui.next!)}
|
||||||
>
|
>
|
||||||
Go to next available date →
|
Go to next available date →
|
||||||
|
|
@ -542,7 +516,7 @@
|
||||||
disabled={!selectable}
|
disabled={!selectable}
|
||||||
aria-pressed={selected}
|
aria-pressed={selected}
|
||||||
onclick={() => (ui.selectedDayKey = day.dateKey)}
|
onclick={() => (ui.selectedDayKey = day.dateKey)}
|
||||||
class="aspect-square rounded-button text-sm transition {selected
|
class="aspect-square rounded-full text-sm transition {selected
|
||||||
? 'bg-sage font-semibold text-primary-content'
|
? 'bg-sage font-semibold text-primary-content'
|
||||||
: selectable
|
: selectable
|
||||||
? 'cursor-pointer bg-sage/15 font-medium text-charcoal hover:bg-sage/35'
|
? 'cursor-pointer bg-sage/15 font-medium text-charcoal hover:bg-sage/35'
|
||||||
|
|
@ -571,12 +545,12 @@
|
||||||
{@const label = `${formatTime(entry.start)}–${formatTime(entry.end)}`}
|
{@const label = `${formatTime(entry.start)}–${formatTime(entry.end)}`}
|
||||||
{#if isGroup && entry.line}
|
{#if isGroup && entry.line}
|
||||||
<!-- Places in a group session already in the basket: − / + -->
|
<!-- Places in a group session already in the basket: − / + -->
|
||||||
<div class="inline-flex items-center gap-2 rounded-button bg-sage/15 py-1 pr-1 pl-3.5 text-sm text-sage-dark">
|
<div class="inline-flex items-center gap-2 rounded-full bg-sage/15 py-1 pr-1 pl-3.5 text-sm text-sage-dark">
|
||||||
<span>{label} · {placesLeft(free)}</span>
|
<span>{label} · {placesLeft(free)}</span>
|
||||||
<span class="inline-flex items-center gap-1 rounded-button bg-white px-1 py-0.5">
|
<span class="inline-flex items-center gap-1 rounded-full bg-white px-1 py-0.5">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex h-6 w-6 items-center justify-center rounded-button leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
|
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
|
||||||
aria-label="One place fewer"
|
aria-label="One place fewer"
|
||||||
disabled={ui.adding}
|
disabled={ui.adding}
|
||||||
onclick={() => changeSeats(item.id, entry, -1)}
|
onclick={() => changeSeats(item.id, entry, -1)}
|
||||||
|
|
@ -589,7 +563,7 @@
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex h-6 w-6 items-center justify-center rounded-button leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
|
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
|
||||||
aria-label="One place more"
|
aria-label="One place more"
|
||||||
disabled={ui.adding || free <= 0}
|
disabled={ui.adding || free <= 0}
|
||||||
onclick={() => changeSeats(item.id, entry, 1)}
|
onclick={() => changeSeats(item.id, entry, 1)}
|
||||||
|
|
@ -603,7 +577,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
disabled={!!entry.line || !entry.time || ui.adding}
|
disabled={!!entry.line || !entry.time || ui.adding}
|
||||||
onclick={() => entry.time && addTime(item, duration.minutes, entry.time)}
|
onclick={() => entry.time && addTime(item, duration.minutes, entry.time)}
|
||||||
class="inline-flex items-center gap-1.5 rounded-button border px-3.5 py-1.5 text-sm transition {entry.line
|
class="inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-sm transition {entry.line
|
||||||
? 'cursor-not-allowed border-transparent bg-sage/15 text-sage-dark'
|
? 'cursor-not-allowed border-transparent bg-sage/15 text-sage-dark'
|
||||||
: 'border-charcoal/15 bg-white text-charcoal hover:border-sage hover:bg-sage/10'} disabled:opacity-60 {ui.adding &&
|
: 'border-charcoal/15 bg-white text-charcoal hover:border-sage hover:bg-sage/10'} disabled:opacity-60 {ui.adding &&
|
||||||
!entry.line
|
!entry.line
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={prev}
|
onclick={prev}
|
||||||
class="w-10 h-10 rounded-button flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
|
class="w-10 h-10 rounded-full flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
|
||||||
aria-label="Previous slide"
|
aria-label="Previous slide"
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">
|
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={next}
|
onclick={next}
|
||||||
class="w-10 h-10 rounded-button flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
|
class="w-10 h-10 rounded-full flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
|
||||||
aria-label="Next slide"
|
aria-label="Next slide"
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">
|
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@
|
||||||
let items = $derived(data.items?.length ? data.items : [
|
let items = $derived(data.items?.length ? data.items : [
|
||||||
{ title: 'Your story here', description: 'Add milestones, training, or the journey behind the practice.' }
|
{ title: 'Your story here', description: 'Add milestones, training, or the journey behind the practice.' }
|
||||||
]);
|
]);
|
||||||
// Desktop only: cards alternate sides and overlap a little; on a phone they stack in one column.
|
|
||||||
let widths = $derived(items.map((_: TimelineItem, i: number) => {
|
let widths = $derived(items.map((_: TimelineItem, i: number) => {
|
||||||
const opts = ['md:w-[78%]', 'md:w-[85%]', 'md:w-[90%]', 'md:w-[95%]', 'md:w-[98%]'];
|
const opts = ['w-[78%]', 'w-[85%]', 'w-[90%]', 'w-[95%]', 'w-[98%]'];
|
||||||
return opts[(i * 7 + 3) % opts.length];
|
return opts[(i * 7 + 3) % opts.length];
|
||||||
}));
|
}));
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -20,9 +19,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="relative md:before:absolute md:before:left-1/2 md:before:top-0 md:before:h-full md:before:w-px md:before:bg-sage/30">
|
<div class="relative md:before:absolute md:before:left-1/2 md:before:top-0 md:before:h-full md:before:w-px md:before:bg-sage/30">
|
||||||
{#each items as item, index}
|
{#each items as item, index}
|
||||||
<div use:scrollReveal class="reveal relative mb-4 grid gap-4 md:mb-[-1rem] md:grid-cols-2 md:gap-8">
|
<div use:scrollReveal class="reveal relative mb-[-1rem] grid gap-4 md:grid-cols-2 md:gap-8">
|
||||||
<div class="hidden md:block" class:md:order-2={index % 2 === 0}></div>
|
<div class="hidden md:block" class:md:order-2={index % 2 === 0}></div>
|
||||||
<article class="rounded-2xl bg-white/75 p-5 shadow-sm ring-1 ring-charcoal/5 md:-mt-4 {widths[index]} {index % 2 === 0 ? 'md:ml-auto md:text-right' : ''}">
|
<article class="rounded-2xl bg-white/75 p-5 shadow-sm ring-1 ring-charcoal/5 -mt-4 {widths[index]} {index % 2 === 0 ? 'md:ml-auto md:text-right' : ''}">
|
||||||
<h3 class="text-xl">{item.title}</h3>
|
<h3 class="text-xl">{item.title}</h3>
|
||||||
<p class="mt-2 text-sm leading-6 text-fg-body/70">{item.description}</p>
|
<p class="mt-2 text-sm leading-6 text-fg-body/70">{item.description}</p>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
dateKey,
|
dateKey,
|
||||||
eventMatchesCategories,
|
eventMatchesCategories,
|
||||||
eventOverlapsDay,
|
eventOverlapsDay,
|
||||||
eventOverlapsRange,
|
|
||||||
eventRange,
|
eventRange,
|
||||||
formatEventDateRange,
|
formatEventDateRange,
|
||||||
getCurrentAndNextMonths,
|
getCurrentAndNextMonths,
|
||||||
|
|
@ -27,12 +26,6 @@
|
||||||
return visibleEvents.filter((event) => eventOverlapsDay(event, date));
|
return visibleEvents.filter((event) => eventOverlapsDay(event, date));
|
||||||
}
|
}
|
||||||
|
|
||||||
// On a phone the grid only shows coloured bars; this list under it says what they are.
|
|
||||||
function eventsInMonth(days: { date: Date; inMonth: boolean }[]) {
|
|
||||||
const inMonth = days.filter((day) => day.inMonth);
|
|
||||||
return visibleEvents.filter((event) => eventOverlapsRange(event, inMonth[0].date, inMonth[inMonth.length - 1].date));
|
|
||||||
}
|
|
||||||
|
|
||||||
function eventStyle(event: CalendarEventRecord) {
|
function eventStyle(event: CalendarEventRecord) {
|
||||||
return `--event-color: ${event.color || '#8a9a7b'};`;
|
return `--event-color: ${event.color || '#8a9a7b'};`;
|
||||||
}
|
}
|
||||||
|
|
@ -49,11 +42,10 @@
|
||||||
return {
|
return {
|
||||||
showLabel: visualStart,
|
showLabel: visualStart,
|
||||||
classes: [
|
classes: [
|
||||||
// Continuing bars reach across the cell padding and the gap (p-1/p-2 + gap-1).
|
visualStart ? 'rounded-l-xl' : 'rounded-l-none -ml-3',
|
||||||
visualStart ? 'rounded-l-xl' : 'rounded-l-none -ml-2 sm:-ml-3',
|
visualEnd ? 'rounded-r-xl' : 'rounded-r-none -mr-3',
|
||||||
visualEnd ? 'rounded-r-xl' : 'rounded-r-none -mr-2 sm:-mr-3',
|
|
||||||
visualStart && visualEnd ? 'mx-0' : '',
|
visualStart && visualEnd ? 'mx-0' : '',
|
||||||
!visualStart && !visualEnd ? '-mx-2 sm:-mx-3' : ''
|
!visualStart && !visualEnd ? '-mx-3' : ''
|
||||||
].filter(Boolean).join(' ')
|
].filter(Boolean).join(' ')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -65,20 +57,20 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if visibleEvents.length === 0}
|
{#if visibleEvents.length === 0}
|
||||||
<div class="mx-auto max-w-2xl rounded-panel border border-sage/20 bg-white/70 p-8 text-center shadow-sm">
|
<div class="mx-auto max-w-2xl rounded-[2rem] border border-sage/20 bg-white/70 p-8 text-center shadow-sm">
|
||||||
<p class="text-charcoal/70">No upcoming events are available for the selected categories.</p>
|
<p class="text-charcoal/70">No upcoming events are available for the selected categories.</p>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="isolate grid gap-8 lg:grid-cols-2">
|
<div class="isolate grid gap-8 lg:grid-cols-2">
|
||||||
{#each months as month}
|
{#each months as month}
|
||||||
<div class="relative z-0 overflow-visible rounded-panel border border-sage/15 bg-white/90 p-3 shadow-sm sm:p-5 hover:z-[9000] focus-within:z-[9000]">
|
<div class="relative z-0 overflow-visible rounded-[2rem] border border-sage/15 bg-white/80 p-5 shadow-sm backdrop-blur hover:z-[9000] focus-within:z-[9000]">
|
||||||
<h3 class="font-display mb-5 text-center text-3xl text-charcoal">{month.label}</h3>
|
<h3 class="font-display mb-5 text-center text-3xl text-charcoal">{month.label}</h3>
|
||||||
<div class="mb-2 grid grid-cols-7 gap-1 text-center text-xs font-semibold uppercase tracking-wide text-charcoal/45">
|
<div class="mb-2 grid grid-cols-7 gap-1 text-center text-xs font-semibold uppercase tracking-wide text-charcoal/45">
|
||||||
{#each weekdays as weekday}<div>{weekday}</div>{/each}
|
{#each weekdays as weekday}<div>{weekday}</div>{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-7 gap-1 overflow-visible">
|
<div class="grid grid-cols-7 gap-1 overflow-visible">
|
||||||
{#each month.days as day}
|
{#each month.days as day}
|
||||||
<div class="relative min-h-14 overflow-visible rounded-xl border p-1 sm:min-h-28 sm:rounded-2xl sm:p-2 {day.inMonth ? 'border-sage/10 bg-warm/60' : 'border-sage/5 bg-warm/25'}" class:ring-2={day.isToday} class:ring-sage={day.isToday}>
|
<div class="relative min-h-28 overflow-visible rounded-2xl border p-2 {day.inMonth ? 'border-sage/10 bg-warm/60' : 'border-sage/5 bg-warm/25'}" class:ring-2={day.isToday} class:ring-sage={day.isToday}>
|
||||||
<div class="mb-1 flex items-center justify-between">
|
<div class="mb-1 flex items-center justify-between">
|
||||||
<span class="text-sm font-semibold {day.inMonth ? 'text-charcoal/70' : 'text-charcoal/30'}">{day.dayNumber}</span>
|
<span class="text-sm font-semibold {day.inMonth ? 'text-charcoal/70' : 'text-charcoal/30'}">{day.dayNumber}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -89,7 +81,7 @@
|
||||||
{@const segment = segmentMeta(event, day.date)}
|
{@const segment = segmentMeta(event, day.date)}
|
||||||
{#if href}
|
{#if href}
|
||||||
<a
|
<a
|
||||||
class="group/event relative z-10 block h-2 px-2 text-left text-[0.7rem] sm:h-auto sm:py-1 font-semibold leading-tight text-white shadow-sm hover:z-[9999] hover:shadow-md focus:z-[9999] focus:outline-none focus:ring-2 focus:ring-charcoal/30 {segment.classes}"
|
class="group/event relative z-10 block px-2 py-1 text-left text-[0.7rem] font-semibold leading-tight text-white shadow-sm hover:z-[9999] hover:shadow-md focus:z-[9999] focus:outline-none focus:ring-2 focus:ring-charcoal/30 {segment.classes}"
|
||||||
href={href}
|
href={href}
|
||||||
target={isExternalLink(href) ? '_blank' : undefined}
|
target={isExternalLink(href) ? '_blank' : undefined}
|
||||||
rel={isExternalLink(href) ? 'noreferrer' : undefined}
|
rel={isExternalLink(href) ? 'noreferrer' : undefined}
|
||||||
|
|
@ -97,8 +89,8 @@
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
>
|
>
|
||||||
<span class="absolute inset-0 bg-[var(--event-color)] {segment.classes}"></span>
|
<span class="absolute inset-0 bg-[var(--event-color)] {segment.classes}"></span>
|
||||||
<span class="relative hidden truncate sm:block">{segment.showLabel ? event.name : '\u00a0'}</span>
|
<span class="relative block truncate">{segment.showLabel ? event.name : '\u00a0'}</span>
|
||||||
<span class="pointer-events-none absolute bottom-full z-[10000] mb-2 hidden w-64 rounded-xl bg-charcoal p-3 text-xs font-normal leading-relaxed text-white shadow-xl sm:group-hover/event:block sm:group-focus/event:block {day.date.getDay() >= 4 ? 'right-0' : 'left-0'}">
|
<span class="pointer-events-none absolute bottom-full left-0 z-[10000] mb-2 hidden w-64 rounded-xl bg-charcoal p-3 text-xs font-normal leading-relaxed text-white shadow-xl group-hover/event:block group-focus/event:block">
|
||||||
<strong class="block">{event.name}</strong>
|
<strong class="block">{event.name}</strong>
|
||||||
<span class="block opacity-80">{formatEventDateRange(event)}</span>
|
<span class="block opacity-80">{formatEventDateRange(event)}</span>
|
||||||
{#if event.description}<span class="mt-1 block">{event.description}</span>{/if}
|
{#if event.description}<span class="mt-1 block">{event.description}</span>{/if}
|
||||||
|
|
@ -106,15 +98,15 @@
|
||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<span
|
<span
|
||||||
class="group/event relative z-10 block h-2 px-2 text-left text-[0.7rem] sm:h-auto sm:py-1 font-semibold leading-tight text-white shadow-sm hover:z-[9999] focus:z-[9999] focus:outline-none focus:ring-2 focus:ring-charcoal/30 {segment.classes}"
|
class="group/event relative z-10 block px-2 py-1 text-left text-[0.7rem] font-semibold leading-tight text-white shadow-sm hover:z-[9999] focus:z-[9999] focus:outline-none focus:ring-2 focus:ring-charcoal/30 {segment.classes}"
|
||||||
style={eventStyle(event)}
|
style={eventStyle(event)}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
role="button"
|
role="button"
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
>
|
>
|
||||||
<span class="absolute inset-0 bg-[var(--event-color)] {segment.classes}"></span>
|
<span class="absolute inset-0 bg-[var(--event-color)] {segment.classes}"></span>
|
||||||
<span class="relative hidden truncate sm:block">{segment.showLabel ? event.name : '\u00a0'}</span>
|
<span class="relative block truncate">{segment.showLabel ? event.name : '\u00a0'}</span>
|
||||||
<span class="pointer-events-none absolute bottom-full z-[10000] mb-2 hidden w-64 rounded-xl bg-charcoal p-3 text-xs font-normal leading-relaxed text-white shadow-xl sm:group-hover/event:block sm:group-focus/event:block {day.date.getDay() >= 4 ? 'right-0' : 'left-0'}">
|
<span class="pointer-events-none absolute bottom-full left-0 z-[10000] mb-2 hidden w-64 rounded-xl bg-charcoal p-3 text-xs font-normal leading-relaxed text-white shadow-xl group-hover/event:block group-focus/event:block">
|
||||||
<strong class="block">{event.name}</strong>
|
<strong class="block">{event.name}</strong>
|
||||||
<span class="block opacity-80">{formatEventDateRange(event)}</span>
|
<span class="block opacity-80">{formatEventDateRange(event)}</span>
|
||||||
{#if event.description}<span class="mt-1 block">{event.description}</span>{/if}
|
{#if event.description}<span class="mt-1 block">{event.description}</span>{/if}
|
||||||
|
|
@ -126,25 +118,6 @@
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{#if eventsInMonth(month.days).length}
|
|
||||||
<ul class="mt-4 space-y-3 sm:hidden">
|
|
||||||
{#each eventsInMonth(month.days) as event}
|
|
||||||
{@const href = normalizeLink(event.link)}
|
|
||||||
<li class="flex gap-3 text-sm" style={eventStyle(event)}>
|
|
||||||
<span class="mt-1 h-3 w-3 shrink-0 rounded-full bg-[var(--event-color)]" aria-hidden="true"></span>
|
|
||||||
<div class="min-w-0">
|
|
||||||
{#if href}
|
|
||||||
<a class="font-semibold text-charcoal underline underline-offset-2" {href} target={isExternalLink(href) ? '_blank' : undefined} rel={isExternalLink(href) ? 'noreferrer' : undefined}>{event.name}</a>
|
|
||||||
{:else}
|
|
||||||
<span class="font-semibold text-charcoal">{event.name}</span>
|
|
||||||
{/if}
|
|
||||||
<span class="text-charcoal/60"> · {formatEventDateRange(event)}</span>
|
|
||||||
{#if event.description}<p class="break-words text-charcoal/70">{event.description}</p>{/if}
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// the Shop block and the checkout. Which duration costs what is decided
|
// the Shop block and the checkout. Which duration costs what is decided
|
||||||
// (and charged) by the shop hooks in PocketBase; this only reads and shows it.
|
// (and charged) by the shop hooks in PocketBase; this only reads and shows it.
|
||||||
|
|
||||||
import type { BundlePart, ItemDuration, ItemRecord, ShopSort } from './types';
|
import type { BundlePart, ItemDuration, ItemRecord } from './types';
|
||||||
|
|
||||||
/** A service's `durations` field (JSON, possibly hand-edited) → valid entries, shortest first, one per length. */
|
/** A service's `durations` field (JSON, possibly hand-edited) → valid entries, shortest first, one per length. */
|
||||||
export function parseDurations(raw: unknown): ItemDuration[] {
|
export function parseDurations(raw: unknown): ItemDuration[] {
|
||||||
|
|
@ -49,37 +49,3 @@ export function bundleListPrice(parts: BundlePart[], items: ItemRecord[]) {
|
||||||
}
|
}
|
||||||
return Math.round(total * 100) / 100;
|
return Math.round(total * 100) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The Shop block's sort choices, in menu order, with what visitors see. */
|
|
||||||
export const SHOP_SORTS: { value: ShopSort; label: string }[] = [
|
|
||||||
{ value: 'recommended', label: 'Recommended' },
|
|
||||||
{ value: 'popular', label: 'Most popular' },
|
|
||||||
{ value: 'price_asc', label: 'Price: low to high' },
|
|
||||||
{ value: 'price_desc', label: 'Price: high to low' },
|
|
||||||
{ value: 'name', label: 'Name (A–Z)' }
|
|
||||||
];
|
|
||||||
|
|
||||||
const byName = (a: ItemRecord, b: ItemRecord) => a.name.localeCompare(b.name, 'en-GB', { sensitivity: 'base' });
|
|
||||||
const byPriority = (a: ItemRecord, b: ItemRecord) => b.priority - a.priority || byName(a, b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* `items` in the Shop block's `sort` order (a new array). Ties — and, for
|
|
||||||
* "Most popular", items that haven't sold lately — fall back to Recommended,
|
|
||||||
* so the admin's priorities still decide whatever the numbers don't.
|
|
||||||
* Services sort by their lowest price (what "from …" shows).
|
|
||||||
*/
|
|
||||||
export function sortItems(items: ItemRecord[], sort: ShopSort = 'recommended') {
|
|
||||||
const list = [...items];
|
|
||||||
switch (sort) {
|
|
||||||
case 'popular':
|
|
||||||
return list.sort((a, b) => (a.popularRank ?? Infinity) - (b.popularRank ?? Infinity) || byPriority(a, b));
|
|
||||||
case 'price_asc':
|
|
||||||
return list.sort((a, b) => a.price - b.price || byPriority(a, b));
|
|
||||||
case 'price_desc':
|
|
||||||
return list.sort((a, b) => b.price - a.price || byPriority(a, b));
|
|
||||||
case 'name':
|
|
||||||
return list.sort(byName);
|
|
||||||
default:
|
|
||||||
return list.sort(byPriority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,88 +2,9 @@
|
||||||
* Scroll reveal Svelte action — applies a CSS class when the element enters the viewport.
|
* Scroll reveal Svelte action — applies a CSS class when the element enters the viewport.
|
||||||
* Usage: <div use:scrollReveal class="reveal">...</div>
|
* Usage: <div use:scrollReveal class="reveal">...</div>
|
||||||
* The `reveal` class is hidden initially; `reveal-visible` is added on intersection.
|
* The `reveal` class is hidden initially; `reveal-visible` is added on intersection.
|
||||||
*
|
|
||||||
* On a device that can't keep up, the animations are switched off for the rest
|
|
||||||
* of the visit (`plain-motion` on <html>, see app.css): one with very few cores
|
|
||||||
* or little memory straight away, any other once scrolling is seen to stutter.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PLAIN = 'plain-motion';
|
|
||||||
const STORAGE_KEY = 'plain-motion';
|
|
||||||
/** Scrolled frames to look at before deciding, and how many may run late. */
|
|
||||||
const SAMPLE_FRAMES = 120;
|
|
||||||
const LATE_SHARE = 0.1;
|
|
||||||
/** A frame this long missed at least one refresh of a 60 Hz screen. */
|
|
||||||
const LATE_MS = 25;
|
|
||||||
|
|
||||||
let watching = false;
|
|
||||||
|
|
||||||
function usePlainMotion() {
|
|
||||||
document.documentElement.classList.add(PLAIN);
|
|
||||||
try {
|
|
||||||
sessionStorage.setItem(STORAGE_KEY, '1');
|
|
||||||
} catch {
|
|
||||||
// Storage blocked: decided again on the next page.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function weakHardware() {
|
|
||||||
const memory = (navigator as Navigator & { deviceMemory?: number }).deviceMemory;
|
|
||||||
return (navigator.hardwareConcurrency || 8) <= 2 || (memory !== undefined && memory <= 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Times frames while the page scrolls; too many late ones switch the animations off. */
|
|
||||||
function watchScrolling() {
|
|
||||||
if (watching || typeof window === 'undefined') return;
|
|
||||||
watching = true;
|
|
||||||
|
|
||||||
let stored = false;
|
|
||||||
try {
|
|
||||||
stored = sessionStorage.getItem(STORAGE_KEY) === '1';
|
|
||||||
} catch {
|
|
||||||
// Storage blocked: measure instead.
|
|
||||||
}
|
|
||||||
if (stored || weakHardware()) {
|
|
||||||
usePlainMotion();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let frames = 0;
|
|
||||||
let late = 0;
|
|
||||||
let last = 0;
|
|
||||||
let lastScroll = 0;
|
|
||||||
let running = false;
|
|
||||||
|
|
||||||
function tick(now: number) {
|
|
||||||
if (last) {
|
|
||||||
frames++;
|
|
||||||
if (now - last > LATE_MS) late++;
|
|
||||||
}
|
|
||||||
last = now;
|
|
||||||
if (frames >= SAMPLE_FRAMES) {
|
|
||||||
window.removeEventListener('scroll', onScroll);
|
|
||||||
if (late / frames > LATE_SHARE) usePlainMotion();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Only frames while scrolling count; stop shortly after it ends.
|
|
||||||
if (now - lastScroll < 300) requestAnimationFrame(tick);
|
|
||||||
else running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScroll() {
|
|
||||||
lastScroll = performance.now();
|
|
||||||
if (running) return;
|
|
||||||
running = true;
|
|
||||||
last = 0;
|
|
||||||
requestAnimationFrame(tick);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('scroll', onScroll, { passive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
export function scrollReveal(node: HTMLElement, delay: number = 0) {
|
export function scrollReveal(node: HTMLElement, delay: number = 0) {
|
||||||
watchScrolling();
|
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,9 @@ export function mapItemRecord(record: Record<string, any>): ItemRecord {
|
||||||
durations: type === 'item_with_time' ? parseDurations(record.durations) : [],
|
durations: type === 'item_with_time' ? parseDurations(record.durations) : [],
|
||||||
bundleParts: type === 'bundle' ? parseBundleParts(record.bundleParts) : [],
|
bundleParts: type === 'bundle' ? parseBundleParts(record.bundleParts) : [],
|
||||||
validMonths: type === 'bundle' ? Number(record.validMonths) || null : null,
|
validMonths: type === 'bundle' ? Number(record.validMonths) || null : null,
|
||||||
// PocketBase reads an empty number back as 0, never null: 0 means "not set" for both
|
bufferMinutes: record.bufferMinutes ?? null,
|
||||||
// (and a 0 in the admin form would fail capacity's min of 1, blocking every save).
|
capacity: record.capacity ?? null,
|
||||||
bufferMinutes: Number(record.bufferMinutes) || null,
|
active: record.active !== false
|
||||||
capacity: Number(record.capacity) || null,
|
|
||||||
active: record.active !== false,
|
|
||||||
priority: Number(record.priority) || 0,
|
|
||||||
popularRank: null
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,16 +41,8 @@ export function mapItemRecord(record: Record<string, any>): ItemRecord {
|
||||||
* (see `loadBookableTimes`). Errors propagate.
|
* (see `loadBookableTimes`). Errors propagate.
|
||||||
*/
|
*/
|
||||||
export async function loadShopData(pb: PocketBase): Promise<{ items: ItemRecord[] }> {
|
export async function loadShopData(pb: PocketBase): Promise<{ items: ItemRecord[] }> {
|
||||||
const [records, popular] = await Promise.all([
|
const records = await pb.collection('items').getFullList({ filter: 'active = true', sort: 'name', expand: 'image' });
|
||||||
pb.collection('items').getFullList({ filter: 'active = true', sort: '-priority,name', expand: 'image' }),
|
const items = records.map(mapItemRecord);
|
||||||
// Only orders the "Most popular" sort; without it the shop still works.
|
|
||||||
pb.send<{ items: string[] }>('/api/shop/popular', { requestKey: null }).catch((e) => {
|
|
||||||
console.warn('Best sellers unavailable ("Most popular" falls back to Recommended):', e instanceof Error ? e.message : e);
|
|
||||||
return { items: [] as string[] };
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
const rank = new Map(popular.items.map((id, i) => [id, i]));
|
|
||||||
const items = records.map((record) => ({ ...mapItemRecord(record), popularRank: rank.get(record.id) ?? null }));
|
|
||||||
// A bundle with a part that isn't on sale (inactive, deleted, or a length
|
// A bundle with a part that isn't on sale (inactive, deleted, or a length
|
||||||
// the service dropped) can't be bought — the shop hook refuses it too.
|
// the service dropped) can't be bought — the shop hook refuses it too.
|
||||||
return { items: items.filter((item) => item.type !== 'bundle' || bundleListPrice(item.bundleParts, items) !== null) };
|
return { items: items.filter((item) => item.type !== 'bundle' || bundleListPrice(item.bundleParts, items) !== null) };
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { defaultColors, defaultStyle, type ColorsGlobal, type StyleGlobal } from './types';
|
import { defaultColors, type ColorsGlobal } from './types';
|
||||||
|
|
||||||
// Site colours (Site design → Colors) as CSS variables, rendered server-side
|
// Site colours (Site design → Colors) as CSS variables, rendered server-side
|
||||||
// into a <style> tag so pages don't flash the default colours on load.
|
// into a <style> tag so pages don't flash the default colours on load.
|
||||||
|
|
@ -56,68 +56,9 @@ export function brandThemeVars(colors: Partial<ColorsGlobal> | null | undefined)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fonts to pick from in Site design → Style. Each is bundled by both apps
|
/** Every site colour variable — public site and the admin preview. */
|
||||||
// (src/lib/fonts.ts, @fontsource-variable packages) and a browser downloads
|
export function siteThemeVars(colors: Partial<ColorsGlobal> | null | undefined): Record<string, string> {
|
||||||
// only the ones a page uses. Adding one: install the package in both apps,
|
|
||||||
// import it in both fonts.ts files, add it here.
|
|
||||||
export const SITE_FONTS = [
|
|
||||||
{ id: 'playfair-display', label: 'Playfair Display', family: 'Playfair Display Variable', serif: true },
|
|
||||||
{ id: 'cormorant-garamond', label: 'Cormorant Garamond', family: 'Cormorant Garamond Variable', serif: true },
|
|
||||||
{ id: 'eb-garamond', label: 'EB Garamond', family: 'EB Garamond Variable', serif: true },
|
|
||||||
{ id: 'libre-baskerville', label: 'Libre Baskerville', family: 'Libre Baskerville Variable', serif: true },
|
|
||||||
{ id: 'lora', label: 'Lora', family: 'Lora Variable', serif: true },
|
|
||||||
{ id: 'fraunces', label: 'Fraunces', family: 'Fraunces Variable', serif: true },
|
|
||||||
{ id: 'dm-sans', label: 'DM Sans', family: 'DM Sans Variable', serif: false },
|
|
||||||
{ id: 'inter', label: 'Inter', family: 'Inter Variable', serif: false },
|
|
||||||
{ id: 'manrope', label: 'Manrope', family: 'Manrope Variable', serif: false },
|
|
||||||
{ id: 'montserrat', label: 'Montserrat', family: 'Montserrat Variable', serif: false },
|
|
||||||
{ id: 'nunito', label: 'Nunito', family: 'Nunito Variable', serif: false },
|
|
||||||
{ id: 'outfit', label: 'Outfit', family: 'Outfit Variable', serif: false },
|
|
||||||
{ id: 'raleway', label: 'Raleway', family: 'Raleway Variable', serif: false },
|
|
||||||
{ id: 'work-sans', label: 'Work Sans', family: 'Work Sans Variable', serif: false },
|
|
||||||
{ id: 'josefin-sans', label: 'Josefin Sans', family: 'Josefin Sans Variable', serif: false }
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
/** CSS font-family for a SITE_FONTS id (unknown ids get `fallbackId`'s font). */
|
|
||||||
export function fontStack(id: unknown, fallbackId: string): string {
|
|
||||||
const font = SITE_FONTS.find((f) => f.id === id) ?? SITE_FONTS.find((f) => f.id === fallbackId)!;
|
|
||||||
return `'${font.family}', ${font.serif ? 'Georgia, serif' : 'ui-sans-serif, system-ui, sans-serif'}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// What each Style choice sets. The variables are read by the @theme in both
|
|
||||||
// apps' app.css (radius, shadow, container and font tokens), so every
|
|
||||||
// rounded-xl, shadow-sm, max-w-6xl… on the public site follows them.
|
|
||||||
const CORNERS = {
|
|
||||||
sharp: { scale: '0', button: '0' },
|
|
||||||
soft: { scale: '0.4', button: '0.375rem' },
|
|
||||||
round: { scale: '1', button: '9999px' }
|
|
||||||
};
|
|
||||||
const TEXT_SIZES = { small: '93.75%', normal: '100%', large: '112.5%' };
|
|
||||||
const SHADOWS = { none: '0', soft: '1', strong: '2.2' };
|
|
||||||
const WIDTHS = { narrow: '0.85', normal: '1', wide: '1.2' };
|
|
||||||
|
|
||||||
function pick<T>(table: Record<string, T>, key: unknown, fallback: string): T {
|
|
||||||
return table[String(key)] ?? table[fallback];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Site design → Style as CSS variables — public site and the admin preview. */
|
|
||||||
export function siteStyleVars(style: Partial<StyleGlobal> | null | undefined): Record<string, string> {
|
|
||||||
const corners = pick(CORNERS, style?.corners, defaultStyle.corners);
|
|
||||||
return {
|
return {
|
||||||
'--site-font-heading': fontStack(style?.headingFont, defaultStyle.headingFont),
|
|
||||||
'--site-font-body': fontStack(style?.bodyFont, defaultStyle.bodyFont),
|
|
||||||
'--site-corners': corners.scale,
|
|
||||||
'--site-button-radius': corners.button,
|
|
||||||
'--site-text-size': pick(TEXT_SIZES, style?.textSize, defaultStyle.textSize),
|
|
||||||
'--site-shadow': pick(SHADOWS, style?.shadows, defaultStyle.shadows),
|
|
||||||
'--site-width': pick(WIDTHS, style?.width, defaultStyle.width)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Every site colour and style variable — public site and the admin preview. */
|
|
||||||
export function siteThemeVars(colors: Partial<ColorsGlobal> | null | undefined, style?: Partial<StyleGlobal> | null): Record<string, string> {
|
|
||||||
return {
|
|
||||||
...siteStyleVars(style),
|
|
||||||
'--color-bg': safeColor(colors?.background, defaultColors.background),
|
'--color-bg': safeColor(colors?.background, defaultColors.background),
|
||||||
'--color-heading': safeColor(colors?.heading, defaultColors.heading),
|
'--color-heading': safeColor(colors?.heading, defaultColors.heading),
|
||||||
'--color-subheading': safeColor(colors?.subheading, defaultColors.subheading),
|
'--color-subheading': safeColor(colors?.subheading, defaultColors.subheading),
|
||||||
|
|
|
||||||
|
|
@ -156,10 +156,6 @@ export type ItemRecord = {
|
||||||
bufferMinutes: number | null; // get-ready time after each appointment
|
bufferMinutes: number | null; // get-ready time after each appointment
|
||||||
capacity: number | null; // places in a new group session (>1 = group)
|
capacity: number | null; // places in a new group session (>1 = group)
|
||||||
active: boolean;
|
active: boolean;
|
||||||
/** Shop order under "Recommended": higher first, then by name (0 = not set). */
|
|
||||||
priority: number;
|
|
||||||
/** Place among the best sellers (0 = best), null if it hasn't sold lately. Set only by `loadShopData`. */
|
|
||||||
popularRank: number | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** `window`: a stretch of time in which its services can be booked; `session`: one service at a fixed time with places. */
|
/** `window`: a stretch of time in which its services can be booked; `session`: one service at a fixed time with places. */
|
||||||
|
|
@ -295,18 +291,11 @@ export type OrderLine = {
|
||||||
|
|
||||||
// ── Block data types ──────────────────────────────────────────────────
|
// ── Block data types ──────────────────────────────────────────────────
|
||||||
|
|
||||||
/** How a Shop block orders its items (`recommended` = by each item's priority). */
|
|
||||||
export type ShopSort = 'recommended' | 'popular' | 'price_asc' | 'price_desc' | 'name';
|
|
||||||
|
|
||||||
export type ShopBlockData = {
|
export type ShopBlockData = {
|
||||||
title?: string;
|
title?: string;
|
||||||
itemTypeFilter?: 'all' | ItemType;
|
itemTypeFilter?: 'all' | ItemType;
|
||||||
itemIds?: string[];
|
itemIds?: string[];
|
||||||
layout?: 'grid' | 'list';
|
layout?: 'grid' | 'list';
|
||||||
/** Order shown first (default `recommended`). */
|
|
||||||
sort?: ShopSort;
|
|
||||||
/** Show a "Sort by" menu so visitors can reorder the items. */
|
|
||||||
showSort?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CheckoutBlockData = {
|
export type CheckoutBlockData = {
|
||||||
|
|
@ -371,23 +360,3 @@ export const defaultColors: ColorsGlobal = {
|
||||||
primary: '#8a9a7b',
|
primary: '#8a9a7b',
|
||||||
accent: '#c9825f'
|
accent: '#c9825f'
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Site design → Style. Fonts are ids from SITE_FONTS in theme.ts. */
|
|
||||||
export type StyleGlobal = {
|
|
||||||
headingFont: string;
|
|
||||||
bodyFont: string;
|
|
||||||
corners: 'sharp' | 'soft' | 'round';
|
|
||||||
textSize: 'small' | 'normal' | 'large';
|
|
||||||
shadows: 'none' | 'soft' | 'strong';
|
|
||||||
width: 'narrow' | 'normal' | 'wide';
|
|
||||||
};
|
|
||||||
|
|
||||||
// The site's look before these settings existed.
|
|
||||||
export const defaultStyle: StyleGlobal = {
|
|
||||||
headingFont: 'playfair-display',
|
|
||||||
bodyFont: 'dm-sans',
|
|
||||||
corners: 'round',
|
|
||||||
textSize: 'normal',
|
|
||||||
shadows: 'soft',
|
|
||||||
width: 'normal'
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"maxSize": 2000000
|
"options": {
|
||||||
|
"maxSize": 2000000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bool_published",
|
"id": "bool_published",
|
||||||
|
|
@ -101,7 +103,9 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"maxSize": 1000000
|
"options": {
|
||||||
|
"maxSize": 1000000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
||||||
{"id": "autodate_updated", "name": "updated", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": true}
|
{"id": "autodate_updated", "name": "updated", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": true}
|
||||||
|
|
@ -275,7 +279,9 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"presentable": false,
|
"presentable": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"maxSize": 200000
|
"options": {
|
||||||
|
"maxSize": 200000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bool_eventpub",
|
"id": "bool_eventpub",
|
||||||
|
|
@ -330,7 +336,6 @@
|
||||||
{ "id": "num_itemvalidmo1", "name": "validMonths", "type": "number", "system": false, "required": false, "presentable": false, "hidden": false, "min": 1, "max": 120, "onlyInt": true },
|
{ "id": "num_itemvalidmo1", "name": "validMonths", "type": "number", "system": false, "required": false, "presentable": false, "hidden": false, "min": 1, "max": 120, "onlyInt": true },
|
||||||
{ "id": "num_itembuffer1", "name": "bufferMinutes", "type": "number", "system": false, "required": false, "presentable": false, "min": 0, "max": null, "onlyInt": true },
|
{ "id": "num_itembuffer1", "name": "bufferMinutes", "type": "number", "system": false, "required": false, "presentable": false, "min": 0, "max": null, "onlyInt": true },
|
||||||
{ "id": "num_itemcapacity", "name": "capacity", "type": "number", "system": false, "required": false, "presentable": false, "min": 1, "max": null, "onlyInt": true },
|
{ "id": "num_itemcapacity", "name": "capacity", "type": "number", "system": false, "required": false, "presentable": false, "min": 1, "max": null, "onlyInt": true },
|
||||||
{ "id": "num_itempriority", "name": "priority", "type": "number", "system": false, "required": false, "presentable": false, "hidden": false, "min": -1000, "max": 1000, "onlyInt": true },
|
|
||||||
{ "id": "bool_itemactive", "name": "active", "type": "bool", "system": false, "required": false, "presentable": false, "unique": false, "options": {} },
|
{ "id": "bool_itemactive", "name": "active", "type": "bool", "system": false, "required": false, "presentable": false, "unique": false, "options": {} },
|
||||||
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
||||||
{"id": "autodate_updated", "name": "updated", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": true}
|
{"id": "autodate_updated", "name": "updated", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": true}
|
||||||
|
|
@ -383,7 +388,7 @@
|
||||||
{ "id": "sel_basketstat0", "name": "status", "type": "select", "system": false, "required": true, "presentable": false, "unique": false, "maxSelect": 1, "values": ["active", "completed", "abandoned"] },
|
{ "id": "sel_basketstat0", "name": "status", "type": "select", "system": false, "required": true, "presentable": false, "unique": false, "maxSelect": 1, "values": ["active", "completed", "abandoned"] },
|
||||||
{ "id": "date_basketexp0", "name": "expiresAt", "type": "date", "system": false, "required": true, "presentable": false, "unique": false, "options": { "min": "", "max": "" } },
|
{ "id": "date_basketexp0", "name": "expiresAt", "type": "date", "system": false, "required": true, "presentable": false, "unique": false, "options": { "min": "", "max": "" } },
|
||||||
{ "id": "text_basketemai", "name": "email", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 254, "pattern": "" } },
|
{ "id": "text_basketemai", "name": "email", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 254, "pattern": "" } },
|
||||||
{ "id": "json_basketcust", "name": "customerDetails", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "maxSize": 100000 },
|
{ "id": "json_basketcust", "name": "customerDetails", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "options": { "maxSize": 100000 } },
|
||||||
{ "id": "text_basketstrip", "name": "stripePaymentIntentId", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 200, "pattern": "" } },
|
{ "id": "text_basketstrip", "name": "stripePaymentIntentId", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 200, "pattern": "" } },
|
||||||
{ "id": "rel_basketpass01", "name": "pass", "type": "relation", "system": false, "required": false, "presentable": false, "hidden": false, "collectionId": "pbc_passes00001", "cascadeDelete": false, "minSelect": 0, "maxSelect": 1 },
|
{ "id": "rel_basketpass01", "name": "pass", "type": "relation", "system": false, "required": false, "presentable": false, "hidden": false, "collectionId": "pbc_passes00001", "cascadeDelete": false, "minSelect": 0, "maxSelect": 1 },
|
||||||
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
||||||
|
|
@ -444,7 +449,7 @@
|
||||||
{ "id": "text3208210256", "name": "id", "type": "text", "system": true, "required": true, "presentable": false, "hidden": false, "primaryKey": true, "autogeneratePattern": "[a-z0-9]{15}", "min": 15, "max": 15, "pattern": "^[a-z0-9]+$" },
|
{ "id": "text3208210256", "name": "id", "type": "text", "system": true, "required": true, "presentable": false, "hidden": false, "primaryKey": true, "autogeneratePattern": "[a-z0-9]{15}", "min": 15, "max": 15, "pattern": "^[a-z0-9]+$" },
|
||||||
{ "id": "rel_orderbasket0", "name": "basket", "type": "relation", "system": false, "required": true, "presentable": false, "unique": false, "collectionId": "pbc_baskets0001", "cascadeDelete": false, "minSelect": 0, "maxSelect": 1, "displayFields": null },
|
{ "id": "rel_orderbasket0", "name": "basket", "type": "relation", "system": false, "required": true, "presentable": false, "unique": false, "collectionId": "pbc_baskets0001", "cascadeDelete": false, "minSelect": 0, "maxSelect": 1, "displayFields": null },
|
||||||
{ "id": "text_orderemail0", "name": "email", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 254, "pattern": "" } },
|
{ "id": "text_orderemail0", "name": "email", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 254, "pattern": "" } },
|
||||||
{ "id": "json_ordercustde", "name": "customerDetails", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "maxSize": 100000 },
|
{ "id": "json_ordercustde", "name": "customerDetails", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "options": { "maxSize": 100000 } },
|
||||||
{ "id": "num_ordertotal01", "name": "total", "type": "number", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": 0, "max": null } },
|
{ "id": "num_ordertotal01", "name": "total", "type": "number", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": 0, "max": null } },
|
||||||
{ "id": "sel_orderstatus0", "name": "status", "type": "select", "system": false, "required": true, "presentable": false, "unique": false, "maxSelect": 1, "values": ["pending", "paid", "refunded"] },
|
{ "id": "sel_orderstatus0", "name": "status", "type": "select", "system": false, "required": true, "presentable": false, "unique": false, "maxSelect": 1, "values": ["pending", "paid", "refunded"] },
|
||||||
{ "id": "text_orderstripe0", "name": "stripePaymentIntentId", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 200, "pattern": "" } },
|
{ "id": "text_orderstripe0", "name": "stripePaymentIntentId", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 200, "pattern": "" } },
|
||||||
|
|
@ -510,7 +515,7 @@
|
||||||
{ "id": "text3208210256", "name": "id", "type": "text", "system": true, "required": true, "presentable": false, "hidden": false, "primaryKey": true, "autogeneratePattern": "[a-z0-9]{15}", "min": 15, "max": 15, "pattern": "^[a-z0-9]+$" },
|
{ "id": "text3208210256", "name": "id", "type": "text", "system": true, "required": true, "presentable": false, "hidden": false, "primaryKey": true, "autogeneratePattern": "[a-z0-9]{15}", "min": 15, "max": 15, "pattern": "^[a-z0-9]+$" },
|
||||||
{ "id": "text_etplkey0001", "name": "key", "type": "text", "system": false, "required": true, "presentable": true, "unique": true, "options": { "min": null, "max": 80, "pattern": "" } },
|
{ "id": "text_etplkey0001", "name": "key", "type": "text", "system": false, "required": true, "presentable": true, "unique": true, "options": { "min": null, "max": 80, "pattern": "" } },
|
||||||
{ "id": "text_etplsubject", "name": "subject", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 300, "pattern": "" } },
|
{ "id": "text_etplsubject", "name": "subject", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 300, "pattern": "" } },
|
||||||
{ "id": "json_etplblocks0", "name": "blocks", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "maxSize": 2000000 },
|
{ "id": "json_etplblocks0", "name": "blocks", "type": "json", "system": false, "required": false, "presentable": false, "unique": false, "options": { "maxSize": 2000000 } },
|
||||||
{ "id": "text_etplrecips0", "name": "recipients", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 500, "pattern": "" } },
|
{ "id": "text_etplrecips0", "name": "recipients", "type": "text", "system": false, "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": 500, "pattern": "" } },
|
||||||
{ "id": "bool_etplenabled", "name": "enabled", "type": "bool", "system": false, "required": false, "presentable": false, "unique": false, "options": {} },
|
{ "id": "bool_etplenabled", "name": "enabled", "type": "bool", "system": false, "required": false, "presentable": false, "unique": false, "options": {} },
|
||||||
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
{"id": "autodate_created", "name": "created", "type": "autodate", "system": false, "hidden": false, "presentable": false, "onCreate": true, "onUpdate": false},
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,6 @@ routerAdd('GET', '/api/shop/slots', (e) => {
|
||||||
return e.json(200, shop.bookableTimes($app, { item: query.get('item'), minutes: query.get('minutes'), from: query.get('from'), to: query.get('to') }));
|
return e.json(200, shop.bookableTimes($app, { item: query.get('item'), minutes: query.get('minutes'), from: query.get('from'), to: query.get('to') }));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Best sellers first (ids only), for the Shop block's "Most popular" sort.
|
|
||||||
routerAdd('GET', '/api/shop/popular', (e) => {
|
|
||||||
const shop = require(`${__hooks}/shop/lib.js`);
|
|
||||||
return e.json(200, { items: shop.popularItems($app) });
|
|
||||||
});
|
|
||||||
|
|
||||||
routerAdd('GET', '/api/shop/basket/{id}', (e) => {
|
routerAdd('GET', '/api/shop/basket/{id}', (e) => {
|
||||||
const shop = require(`${__hooks}/shop/lib.js`);
|
const shop = require(`${__hooks}/shop/lib.js`);
|
||||||
shop.sweepExpiredHolds($app);
|
shop.sweepExpiredHolds($app);
|
||||||
|
|
|
||||||
|
|
@ -1305,33 +1305,6 @@ function createOrder(app, basketId, payment) {
|
||||||
return orderId;
|
return orderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Popularity ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
/** "Most popular" in the Shop block counts what sold in this many days. */
|
|
||||||
const POPULAR_DAYS = 90;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Item ids, best-selling first, by units in paid orders over the last
|
|
||||||
* POPULAR_DAYS (refunded orders don't count). A booking paid with a code
|
|
||||||
* counts for its service; products handed over inside a bundle (price 0, no
|
|
||||||
* code) don't — the bundle's own line counts for it. Only the order is
|
|
||||||
* returned, never the numbers: this is public, and sales figures aren't.
|
|
||||||
*/
|
|
||||||
function popularItems(app) {
|
|
||||||
const rows = arrayOf(new DynamicModel({ item: '', sold: 0 }));
|
|
||||||
app
|
|
||||||
.db()
|
|
||||||
.newQuery(
|
|
||||||
`SELECT ol.item AS item, SUM(ol.quantity) AS sold
|
|
||||||
FROM order_lines ol JOIN orders o ON o.id = ol.[[order]]
|
|
||||||
WHERE o.status = 'paid' AND o.created >= {:since} AND (ol.price > 0 OR ol.pass != '')
|
|
||||||
GROUP BY ol.item HAVING sold > 0 ORDER BY sold DESC, ol.item`
|
|
||||||
)
|
|
||||||
.bind({ since: pbDate(Date.now() - POPULAR_DAYS * DAY_MS) })
|
|
||||||
.all(rows);
|
|
||||||
return rows.map((row) => row.item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Orders ──────────────────────────────────────────────────────────────
|
// ── Orders ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function globalData(app, key) {
|
function globalData(app, key) {
|
||||||
|
|
@ -1436,7 +1409,6 @@ module.exports = {
|
||||||
issuePass,
|
issuePass,
|
||||||
bookableTimes,
|
bookableTimes,
|
||||||
slotDetails,
|
slotDetails,
|
||||||
popularItems,
|
|
||||||
sweepExpiredHolds,
|
sweepExpiredHolds,
|
||||||
loadActiveBasket,
|
loadActiveBasket,
|
||||||
basketPayload,
|
basketPayload,
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
|
|
||||||
// Give every JSON field an explicit size limit.
|
|
||||||
//
|
|
||||||
// pb_schema.json used to put these limits under `options.maxSize`, which
|
|
||||||
// PocketBase has ignored since 0.23, so the fields below had no limit of
|
|
||||||
// their own and fell back to PocketBase's default. That default dropped from
|
|
||||||
// several MB to 1MB in PocketBase 0.29: a page's blocks over 1MB that saved
|
|
||||||
// on 0.23 are refused on 0.40 ("The maximum allowed JSON size is 1048576
|
|
||||||
// bytes"). Real pages are far smaller (the largest in the backups is ~17KB),
|
|
||||||
// but the limit should be the one we chose, not whatever the default is.
|
|
||||||
//
|
|
||||||
// Only the limit changes; nothing is rewritten. A limit is checked when a
|
|
||||||
// record is saved, so existing data is not affected.
|
|
||||||
|
|
||||||
const LIMITS = [
|
|
||||||
['pages', 'blocks', 2000000],
|
|
||||||
['email_templates', 'blocks', 2000000],
|
|
||||||
['globals', 'data', 1000000],
|
|
||||||
['events', 'categories', 200000],
|
|
||||||
['baskets', 'customerDetails', 100000],
|
|
||||||
['orders', 'customerDetails', 100000]
|
|
||||||
];
|
|
||||||
|
|
||||||
function setLimits(app, size) {
|
|
||||||
for (const [name, fieldName, limit] of LIMITS) {
|
|
||||||
let collection;
|
|
||||||
try {
|
|
||||||
collection = app.findCollectionByNameOrId(name);
|
|
||||||
} catch (e) {
|
|
||||||
continue; // fresh install: pb_schema.json (already with these limits) is imported later
|
|
||||||
}
|
|
||||||
const field = collection.fields.getByName(fieldName);
|
|
||||||
if (!field || field.type() !== 'json') continue;
|
|
||||||
field.maxSize = size === undefined ? limit : size;
|
|
||||||
try {
|
|
||||||
app.save(collection);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`[migration] could not set the size limit on ${name}.${fieldName}: ${e}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
migrate(
|
|
||||||
(app) => setLimits(app),
|
|
||||||
(app) => setLimits(app, 0)
|
|
||||||
);
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
|
|
||||||
// items.priority: where an item comes in Shop blocks under "Recommended"
|
|
||||||
// (the default order). Higher comes first; equal priorities go by name.
|
|
||||||
// Empty reads back as 0, so every existing item starts at 0 and the shop
|
|
||||||
// keeps its old alphabetical order until priorities are set.
|
|
||||||
|
|
||||||
function find(app, name) {
|
|
||||||
try {
|
|
||||||
return app.findCollectionByNameOrId(name);
|
|
||||||
} catch (e) {
|
|
||||||
return null; // fresh install: pb_schema.json (already with the field) is imported later
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
migrate(
|
|
||||||
(app) => {
|
|
||||||
const items = find(app, 'items');
|
|
||||||
if (!items || items.fields.getByName('priority')) return;
|
|
||||||
items.fields.add(new NumberField({ id: 'num_itempriority', name: 'priority', min: -1000, max: 1000, onlyInt: true }));
|
|
||||||
app.save(items);
|
|
||||||
},
|
|
||||||
(app) => {
|
|
||||||
const items = find(app, 'items');
|
|
||||||
if (!items || !items.fields.getByName('priority')) return;
|
|
||||||
items.fields.removeByName('priority');
|
|
||||||
app.save(items);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue