Compare commits
6 commits
76b297153e
...
95a3c6d6b3
| Author | SHA1 | Date | |
|---|---|---|---|
| 95a3c6d6b3 | |||
| 29bbdf267c | |||
| 68c67d7e96 | |||
| f20d6777ab | |||
| ec1156b1fa | |||
| c3c10229b0 |
13 changed files with 131 additions and 33 deletions
|
|
@ -154,6 +154,8 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
|||
### Routing
|
||||
- **Admin app** (`app-admin`): All routes except `/login` are auth-guarded in `hooks.server.ts` (which also refreshes the token per request and sets the cookie's `Secure` flag from the real scheme). The root layout renders the admin shell (grouped sidebar) except on `/login` and `/preview`. The `/preview` route reads `sessionStorage` set by the page editor (same-origin, so it works).
|
||||
- **Public app** (`app-public`): No auth guard. The root layout always renders Header/Footer. `+layout.server.ts` fetches header/footer/colors globals + basket/items/slots for every page.
|
||||
- **Booking and basket links**: booking = the header CTA's address, basket = the optional basket page slug typed in Site design (`header.basketPage`; '' = the CTA's address), both from `shopLinks(header)` in `packages/shared/src/types.ts` (blocks read `page.data.header`) — never hard-code `/book`.
|
||||
- **Class names in components are written out whole** (`'btn-primary'`, not `` `btn-${variant}` ``): Tailwind only generates classes it finds in the source, so a built-up name silently gets no style.
|
||||
- `+page.server.ts` for home fetches `slug = "home" && published = true`
|
||||
- `[slug]/+page.server.ts` fetches by dynamic slug
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ Setup:
|
|||
```
|
||||
Copy the printed `whsec_…` signing secret into `STRIPE_WEBHOOK_SECRET`.
|
||||
4. Import the updated `pb_schema.json` (adds `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`). Two visitors can't take the same place: holds are checked and written in one PocketBase transaction (see *Slot availability*).
|
||||
5. Create a published page (e.g. slug `book`) with a `shop` block and a `checkout` block, and point the header CTA at it.
|
||||
5. Create a published page (e.g. slug `book`) with a `shop` block and point the header CTA at it (*Site design → Header*); hero buttons without an address and *Book another* after paying lead there too. Put a `checkout` block on the same page, or on a page of its own whose slug you type as the optional *Basket page*: the basket in the header and *view basket* in the shop lead there (empty = the CTA's address). Site design warns when the basket's page isn't published or has no `checkout` block.
|
||||
|
||||
## Bundles and codes
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export function createBlock(type: BlockType): ContentBlock {
|
|||
heading: 'Holistic and Experiential Learning about Happiness',
|
||||
subheading: 'Individual sessions, workshops and events in Oslo',
|
||||
buttonLabel: 'BOOK NOW',
|
||||
buttonUrl: '/book'
|
||||
buttonUrl: ''
|
||||
};
|
||||
break;
|
||||
case 'button':
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
{@render field('Subheading', block.data.subheading || '', (subheading) => updateData({ subheading }))}
|
||||
<div class="grid gap-x-4 md:grid-cols-2">
|
||||
{@render field('Button label', block.data.buttonLabel || '', (buttonLabel) => updateData({ buttonLabel }))}
|
||||
{@render field('Button URL', block.data.buttonUrl || '', (buttonUrl) => updateData({ buttonUrl }), '/page or https://…')}
|
||||
{@render field('Button URL', block.data.buttonUrl || '', (buttonUrl) => updateData({ buttonUrl }), 'Empty = the CTA button’s address')}
|
||||
</div>
|
||||
{:else if block.type === 'button'}
|
||||
<div class="grid gap-x-4 md:grid-cols-2">
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ export const load: PageServerLoad = async ({ locals }) => {
|
|||
getGlobal(locals.pb, 'colors', defaultColors)
|
||||
]);
|
||||
|
||||
// Fetch all pages for the home page selector
|
||||
const pages = await locals.pb.collection('pages').getFullList({ sort: 'slug', fields: 'id,slug,title' });
|
||||
// All pages for the page selectors, with what the basket setting warns
|
||||
// about (unpublished, no Checkout block).
|
||||
const records = await locals.pb.collection('pages').getFullList({ sort: 'slug', fields: 'id,slug,title,published,blocks' });
|
||||
const pages = records.map((page) => {
|
||||
const types = new Set(((page.blocks as { type?: string }[]) || []).map((block) => block.type));
|
||||
return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasCheckout: types.has('checkout') };
|
||||
});
|
||||
|
||||
return { header, footer, colors, pages };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { enhance } from '$app/forms';
|
||||
import { fly, slide } from 'svelte/transition';
|
||||
import ImageUploader from '$lib/admin/editors/ImageUploader.svelte';
|
||||
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
||||
import { shopLinks } from '$lib/types';
|
||||
import type { SubmitFunction } from '@sveltejs/kit';
|
||||
|
||||
let { data, form } = $props();
|
||||
|
|
@ -9,8 +12,9 @@
|
|||
let footer = $state(structuredClone(data.footer.data));
|
||||
let colors = $state(structuredClone(data.colors.data));
|
||||
let saving = $state('');
|
||||
// Older records may predate the CTA button; the inputs below need an object.
|
||||
// Older records may predate the CTA button and the basket page; the inputs below need values.
|
||||
header.ctaButton ??= { label: '', href: '' };
|
||||
header.basketPage ??= '';
|
||||
footer.privacyPage ??= '';
|
||||
|
||||
function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; }
|
||||
|
|
@ -34,10 +38,45 @@
|
|||
{ key: 'accent', label: 'Accent', hint: 'Highlights' }
|
||||
];
|
||||
|
||||
const pageBySlug = (slug: string) => data.pages.find((page) => page.slug === slug);
|
||||
|
||||
// Only addresses like "/book" are checked: the CTA may also point to "/" or another site.
|
||||
function ctaProblem() {
|
||||
const slug = header.ctaButton.href?.trim().match(/^\/([^/?#]+)\/?$/)?.[1];
|
||||
if (!slug) return '';
|
||||
const page = pageBySlug(slug);
|
||||
if (!page) return `There is no page with the slug “${slug}”.`;
|
||||
if (!page.published) return `“${page.title}” isn’t published yet.`;
|
||||
return '';
|
||||
}
|
||||
|
||||
// The page the basket links lead to: the basket page, else the CTA's address when that is a page here.
|
||||
function basketProblem() {
|
||||
const slug = shopLinks(header).basket.replace(/^\/|\/$/g, '');
|
||||
const page = pageBySlug(slug);
|
||||
// The CTA may point anywhere (even another site); a typed basket slug must be a page here.
|
||||
if (!page) return header.basketPage?.trim() ? `There is no page with the slug “${slug}”.` : '';
|
||||
if (!page.published) return `“${page.title}” isn’t published yet.`;
|
||||
if (!page.hasCheckout) return `“${page.title}” has no Checkout block, so people can’t pay from it.`;
|
||||
return '';
|
||||
}
|
||||
|
||||
const isHex = (value: unknown) => typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value);
|
||||
|
||||
// "Saved." goes away by itself after a moment; an error stays until the next save.
|
||||
let statusShown = $state('');
|
||||
$effect(() => {
|
||||
if (!form?.section || !form.message) return;
|
||||
statusShown = form.section;
|
||||
if (!form.ok) return;
|
||||
const timer = setTimeout(() => (statusShown = ''), 2500);
|
||||
return () => clearTimeout(timer);
|
||||
});
|
||||
const motion = (ms: number) => (browser && matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : ms);
|
||||
|
||||
const submit: SubmitFunction = ({ formData }) => {
|
||||
saving = String(formData.get('section'));
|
||||
statusShown = '';
|
||||
return async ({ update }) => {
|
||||
// Re-run loads so the admin theme picks up saved colours immediately.
|
||||
await update({ reset: false });
|
||||
|
|
@ -49,11 +88,23 @@
|
|||
<svelte:head><title>Site design | CMS</title></svelte:head>
|
||||
|
||||
{#snippet status(section: string)}
|
||||
{#if form?.section === section && form.message}
|
||||
<div class="alert mt-4 py-2 text-sm" class:alert-success={form.ok} class:alert-error={!form.ok} role="status">{form.message}</div>
|
||||
{#if statusShown === section && form?.section === section && form.message}
|
||||
<div class="alert mt-4 py-2 text-sm" class:alert-success={form.ok} class:alert-error={!form.ok} role="status" in:fly={{ y: 8, duration: motion(200) }} out:slide={{ duration: motion(350) }}>
|
||||
{form.message}
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet info(text: string)}
|
||||
<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}>
|
||||
<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" />
|
||||
</svg>
|
||||
</button>
|
||||
</span>
|
||||
{/snippet}
|
||||
|
||||
{#snippet saveButton(section: string, label: string)}
|
||||
<div class="flex-grow"></div>
|
||||
{@render status(section)}
|
||||
|
|
@ -76,6 +127,14 @@
|
|||
<h2 class="mb-4 text-2xl font-bold">Header</h2>
|
||||
<h3 class="mb-2 font-bold">Logo</h3>
|
||||
<ImageUploader url={header.logo?.url} alt={header.logo?.alt} onChange={(image) => (header.logo = image)} />
|
||||
<h3 class="mt-6 mb-2 font-bold">Home page</h3>
|
||||
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
|
||||
<option value="">— Select a page —</option>
|
||||
{#each data.pages as page (page.id)}
|
||||
<option value={page.slug}>{page.title} [{page.slug}]</option>
|
||||
{/each}
|
||||
</select>
|
||||
<p class="mt-1 text-sm text-base-content/60">The page that "/" will redirect to.</p>
|
||||
<h3 class="mt-6 font-bold">Navigation</h3>
|
||||
{#each header.navLinks || [] as link, i}
|
||||
<div class="my-2 grid grid-cols-[1fr_1fr_auto] gap-2">
|
||||
|
|
@ -85,19 +144,18 @@
|
|||
</div>
|
||||
{/each}
|
||||
<button class="btn btn-sm mt-1" type="button" onclick={addHeaderLink}>Add link</button>
|
||||
<h3 class="mt-6 mb-2 font-bold">CTA button</h3>
|
||||
<h3 class="mt-6 mb-2 flex items-center gap-1 font-bold">CTA button {@render info('Hero buttons without a link and “Book another” after paying go here too.')}</h3>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<input class="input w-full" aria-label="Button label" bind:value={header.ctaButton.label} placeholder="Label" />
|
||||
<input class="input w-full" aria-label="Button address" bind:value={header.ctaButton.href} placeholder="/book" />
|
||||
</div>
|
||||
<h3 class="mt-6 mb-2 font-bold">Home page</h3>
|
||||
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
|
||||
<option value="">— Select a page —</option>
|
||||
{#each data.pages as page (page.id)}
|
||||
<option value={page.slug}>{page.title} [{page.slug}]</option>
|
||||
{/each}
|
||||
</select>
|
||||
<p class="mt-1 text-sm text-base-content/60">The page that "/" will redirect to.</p>
|
||||
{#if ctaProblem()}<p class="mt-1 text-sm font-semibold">⚠ {ctaProblem()}</p>{/if}
|
||||
<h3 class="mt-6 mb-2 flex items-center gap-1 font-bold">
|
||||
Basket page <span class="font-normal text-base-content/50">(optional)</span>
|
||||
{@render info('Slug of the page with the Checkout block. Empty = the CTA button’s page.')}
|
||||
</h3>
|
||||
<input class="input w-full" aria-label="Basket page" bind:value={header.basketPage} placeholder="e.g. basket" />
|
||||
{#if basketProblem()}<p class="mt-1 text-sm font-semibold">⚠ {basketProblem()}</p>{/if}
|
||||
{@render saveButton('header', 'Save header')}
|
||||
</form>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import type { HeaderGlobal } from '$lib/types';
|
||||
import { shopLinks, type HeaderGlobal } from '$lib/types';
|
||||
import { getBasketContext } from '$lib/basket.svelte';
|
||||
import { DEFAULT_CURRENCY, formatPrice } from '$shared/calendar';
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
const basket = getBasketContext();
|
||||
let hasItems = $derived(basket.count > 0);
|
||||
let links = $derived(shopLinks(header));
|
||||
|
||||
// Phone menu: a native modal <dialog> sliding in from the right, so focus
|
||||
// trapping, Escape and the inert page behind come from the browser.
|
||||
|
|
@ -64,7 +65,7 @@
|
|||
{#if hasItems}
|
||||
<a
|
||||
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="/book"
|
||||
href={links.basket}
|
||||
aria-label="View your basket ({basket.count})"
|
||||
>
|
||||
{@render basketIcon()}
|
||||
|
|
@ -73,7 +74,7 @@
|
|||
</a>
|
||||
{/if}
|
||||
{#if header.ctaButton?.label}
|
||||
<a class="cta btn hidden rounded-full border-0 px-6 hover:opacity-90 md:inline-flex" href={header.ctaButton.href}>{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}
|
||||
<button
|
||||
class="grid h-10 w-10 place-items-center rounded-full text-charcoal/80 transition hover:bg-charcoal/5 md:hidden"
|
||||
|
|
@ -118,7 +119,7 @@
|
|||
</ul>
|
||||
|
||||
{#if hasItems}
|
||||
<a class="mx-1 mt-6 flex items-center gap-3 rounded-xl border border-charcoal/10 px-4 py-3 font-semibold text-charcoal/80 transition hover:border-sage" href="/book">
|
||||
<a class="mx-1 mt-6 flex items-center gap-3 rounded-xl border border-charcoal/10 px-4 py-3 font-semibold text-charcoal/80 transition hover:border-sage" href={links.basket}>
|
||||
{@render basketIcon()}
|
||||
<span class="flex-1">Basket ({basket.count})</span>
|
||||
<span class="text-charcoal/60">{formatTotal(basket.total)}</span>
|
||||
|
|
@ -128,7 +129,7 @@
|
|||
|
||||
{#if header.ctaButton?.label}
|
||||
<div class="border-t border-charcoal/10 p-6">
|
||||
<a class="cta btn btn-block rounded-full border-0 hover:opacity-90" href={header.ctaButton.href}>{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>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
import { onMount } from 'svelte';
|
||||
import { formatInstant, formatPrice } from '$shared/calendar';
|
||||
import { formatDuration } from '$shared/items';
|
||||
import { shopLinks } from '$lib/types';
|
||||
|
||||
let { data } = $props();
|
||||
let links = $derived(shopLinks(data.header));
|
||||
|
||||
// "Friday 15 January, 10:00" in the studio's timezone.
|
||||
function formatSlotDate(iso?: string | null) {
|
||||
|
|
@ -68,7 +70,7 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">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'}
|
||||
<h1 class="font-serif text-4xl">Processing your payment…</h1>
|
||||
<p class="mt-3 text-charcoal/70">
|
||||
|
|
@ -80,10 +82,10 @@
|
|||
{:else if data.state === 'canceled' || data.state === 'failed'}
|
||||
<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>
|
||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">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.basket}>Back to your basket</a>
|
||||
{:else}
|
||||
<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>
|
||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">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}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@
|
|||
right: 'justify-end'
|
||||
};
|
||||
|
||||
// Whole class names, not `btn-${variant}`: Tailwind only generates classes
|
||||
// it finds written out, so a built-up name rendered as a plain grey button.
|
||||
const variantClasses: Record<string, string> = {
|
||||
primary: 'btn-primary',
|
||||
secondary: 'btn-secondary'
|
||||
};
|
||||
|
||||
const sizeClasses: Record<string, string> = {
|
||||
xs: 'btn-xs',
|
||||
sm: 'btn-sm',
|
||||
|
|
@ -18,7 +25,7 @@
|
|||
<div class="flex {alignmentClasses[data.alignment] || 'justify-center'}">
|
||||
<a
|
||||
href={data.href || '#'}
|
||||
class="btn btn-{data.variant || '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};` : ''}
|
||||
>
|
||||
{data.label || 'Button'}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, type BasketLine, type CheckoutBlockData } from '$shared/types';
|
||||
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, shopLinks, type BasketLine, type CheckoutBlockData } from '$shared/types';
|
||||
import { getBasketContext } from '$shared/basket.svelte';
|
||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
|
||||
import { formatDuration } from '$shared/items';
|
||||
|
|
@ -15,6 +15,9 @@
|
|||
const basket = getBasketContext();
|
||||
// Not set in the admin preview, which has no footer data.
|
||||
const privacyPage = $derived(page.data.footer?.privacyPage || '');
|
||||
// On its own basket page there is no shop above, so point to the booking page.
|
||||
const bookingHref = $derived(shopLinks(page.data.header).booking);
|
||||
const shopAbove = $derived(page.url.pathname === bookingHref);
|
||||
|
||||
const customer = $state({ name: '', email: '', phone: '', notes: '' });
|
||||
let payState = $state<'idle' | 'creating' | 'ready' | 'confirming' | 'error'>('idle');
|
||||
|
|
@ -352,7 +355,11 @@
|
|||
{#if basket.lines.length === 0}
|
||||
<div class="mt-12 rounded-2xl border border-charcoal/10 bg-white/60 px-6 py-16 text-center">
|
||||
<p class="font-serif text-xl">Your basket is empty</p>
|
||||
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
|
||||
{#if shopAbove}
|
||||
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
|
||||
{:else}
|
||||
<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}
|
||||
</div>
|
||||
{:else}
|
||||
{#if holdLeftMs !== null && slotLineCount}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { shopLinks } from '$shared/types';
|
||||
|
||||
let { data } = $props<{
|
||||
data: {
|
||||
heading?: string;
|
||||
|
|
@ -21,7 +24,7 @@
|
|||
{/if}
|
||||
{#if data.buttonLabel}
|
||||
<div class="animate-fade-in mt-10" style="animation-delay: 0.3s;">
|
||||
<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 || '/book'}>
|
||||
<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}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import type { BasketLine, BookableTime, ShopBlockData, ItemRecord } from '$shared/types';
|
||||
import { shopLinks, type BasketLine, type BookableTime, type ShopBlockData, type ItemRecord } from '$shared/types';
|
||||
import { getBasketContext } from '$shared/basket.svelte';
|
||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
|
||||
import { bundleListPrice, formatDuration, lowestPrice } from '$shared/items';
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
||||
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
||||
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
|
||||
const basketHref = $derived(shopLinks(page.data.header).basket);
|
||||
|
||||
let visibleItems: ItemRecord[] = $derived.by(() => {
|
||||
let result: ItemRecord[] = items;
|
||||
|
|
@ -408,7 +409,7 @@
|
|||
</button>
|
||||
{#if itemInBasket}
|
||||
<a
|
||||
href="/book"
|
||||
href={basketHref}
|
||||
class="inline-flex items-center gap-1 text-sm font-medium text-sage-dark underline-offset-2 hover:underline"
|
||||
>✓ In basket</a
|
||||
>
|
||||
|
|
@ -597,7 +598,7 @@
|
|||
|
||||
{#if ui.justAdded}
|
||||
<p class="mt-3 text-sm font-medium text-sage-dark">
|
||||
Added ✓ — <a href="/book" class="underline underline-offset-2 hover:no-underline">view basket</a>
|
||||
Added ✓ — <a href={basketHref} class="underline underline-offset-2 hover:no-underline">view basket</a>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -61,8 +61,11 @@ export type UpcomingCalendarBlockData = {
|
|||
export type HeaderGlobal = {
|
||||
logo: { url: string; alt: string };
|
||||
navLinks: { label: string; href: string }[];
|
||||
/** The header button. Its address is also where hero buttons without one and "Book another" lead. */
|
||||
ctaButton: { label: string; href: string };
|
||||
homePage: string;
|
||||
/** Slug of the page with the Checkout block, typed in Site design: the basket in the header and "view basket" lead here ('' = the CTA button's address). */
|
||||
basketPage?: string;
|
||||
};
|
||||
|
||||
export type FooterGlobal = {
|
||||
|
|
@ -85,9 +88,18 @@ export const defaultHeader: HeaderGlobal = {
|
|||
{ label: 'Services', href: '/services' }
|
||||
],
|
||||
ctaButton: { label: 'Book Now', href: '/book' },
|
||||
homePage: 'home'
|
||||
homePage: 'home',
|
||||
basketPage: ''
|
||||
};
|
||||
|
||||
/** Where booking (the CTA button's address) and the basket (the basket page, else the same address) are. */
|
||||
export function shopLinks(header?: Partial<HeaderGlobal> | null) {
|
||||
const booking = header?.ctaButton?.href || '/book';
|
||||
// Typed by hand, so tolerate "/basket", "basket/" and spaces.
|
||||
const basketSlug = header?.basketPage?.trim().replace(/^\/+|\/+$/g, '');
|
||||
return { booking, basket: basketSlug ? `/${basketSlug}` : booking };
|
||||
}
|
||||
|
||||
export const defaultFooter: FooterGlobal = {
|
||||
businessName: 'Eva Shafik Massage',
|
||||
tagline: 'Warm, restorative massage therapy for everyday wellbeing.',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue