Admin navigation: grouped sidebar, plainer labels, Backup page
Agreed with the site owner: - Grouped sidebar (Website / Bookings / Settings) instead of a flat top bar that overflowed on phones; a drawer with a hamburger below lg. Signed-in email and Log out at the bottom. - Labels: Globals → Site design, Items → Services & products, Calendar → Events, Export/Import → Backup (URLs unchanged); page headings and cross-references updated to match. - Export/import moved from a navbar dropdown to a /backup page that says what is and isn't included. - Admin event calendar starts weeks on Monday (createCalendarMonth gains an optional weekStartsOn; the public block is unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
This commit is contained in:
parent
9264289813
commit
fbcc71672b
11 changed files with 485 additions and 417 deletions
|
|
@ -5,7 +5,7 @@
|
|||
}
|
||||
|
||||
/* Admin UI theme: DaisyUI light with a fixed sage primary. Deliberately NOT
|
||||
tied to the site's Globals → Colors (those only apply inside /preview), so
|
||||
tied to the site's colours (Site design → Colors) (those only apply inside /preview), so
|
||||
a light brand colour can't make admin buttons unreadable. #647556 on white
|
||||
text is ~5:1 contrast (WCAG AA). */
|
||||
@plugin 'daisyui/theme' {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@
|
|||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="text-sm text-base-content/60">No event categories exist yet. Add categories to events in Calendar first.</p>
|
||||
<p class="text-sm text-base-content/60">No event categories exist yet. Add categories to events under Events first.</p>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if block.type === 'shop'}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
const autoFilled: Record<string, string> = {
|
||||
booking_details: 'Filled in automatically with the booked services, date and time, prices and the total paid.',
|
||||
customer_details: "Filled in automatically with the customer's name, email, phone and checkout notes.",
|
||||
contact_info: 'Filled in automatically from the business name, address, phone and email in Globals → Footer.'
|
||||
contact_info: 'Filled in automatically from the business name, address, phone and email in Site design → Footer.'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="text-sm text-base-content/60">No items yet — create some under Items in the admin.</p>
|
||||
<p class="text-sm text-base-content/60">Nothing to sell yet — add some under Services & products.</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,95 +1,55 @@
|
|||
<script lang="ts">
|
||||
import '../app.css';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
|
||||
|
||||
let { children } = $props();
|
||||
let importStatus = $state<{ ok: boolean; message: string; errors?: string[] } | null>(null);
|
||||
let importing = $state(false);
|
||||
let { children, data } = $props();
|
||||
|
||||
// Routes rendered without the admin shell: the login screen, and the
|
||||
// preview iframe (which must look like the public site, not the admin).
|
||||
const BARE_ROUTES = ['/login', '/preview'];
|
||||
let bare = $derived(BARE_ROUTES.includes(page.url.pathname));
|
||||
|
||||
const navLinks = [
|
||||
// Sidebar navigation, grouped by what the studio is doing. Labels are
|
||||
// user-facing names; hrefs keep the original route names.
|
||||
const navGroups = [
|
||||
{
|
||||
title: 'Website',
|
||||
links: [
|
||||
{ href: '/pages', label: 'Pages' },
|
||||
{ href: '/calendar', label: 'Calendar' },
|
||||
{ href: '/items', label: 'Items' },
|
||||
{ href: '/slots', label: 'Slots' },
|
||||
{ href: '/globals', label: 'Site design' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Bookings',
|
||||
links: [
|
||||
{ href: '/orders', label: 'Orders' },
|
||||
{ href: '/slots', label: 'Slots' },
|
||||
{ href: '/items', label: 'Services & products' },
|
||||
{ href: '/calendar', label: 'Events' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Settings',
|
||||
links: [
|
||||
{ href: '/emails', label: 'Emails' },
|
||||
{ href: '/globals', label: 'Globals' }
|
||||
{ href: '/backup', label: 'Backup' }
|
||||
]
|
||||
}
|
||||
];
|
||||
const isActive = (href: string) => page.url.pathname === href || page.url.pathname.startsWith(`${href}/`);
|
||||
|
||||
// Mobile: the drawer is open while this is true; close it after navigating.
|
||||
let navOpen = $state(false);
|
||||
afterNavigate(() => (navOpen = false));
|
||||
|
||||
// One basket store per layout instance — provided to all children
|
||||
// (preview iframe block renderers). Never module-level state.
|
||||
// Admin doesn't have a real basket; pass null so the store starts empty.
|
||||
const basketStore = createBasketStore(null);
|
||||
setBasketContext(basketStore);
|
||||
|
||||
async function handleExport() {
|
||||
try {
|
||||
const res = await fetch('/api/export');
|
||||
if (!res.ok) throw new Error(`Export failed (${res.status})`);
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `cms-export-${new Date().toISOString().slice(0, 10)}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (e) {
|
||||
importStatus = { ok: false, message: `Export error: ${e instanceof Error ? e.message : String(e)}` };
|
||||
}
|
||||
}
|
||||
|
||||
async function handleImport(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (!file) return;
|
||||
if (!confirm(`Import "${file.name}"? Pages, globals and events with the same slug/key/name will be overwritten.`)) {
|
||||
input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
importing = true;
|
||||
importStatus = null;
|
||||
try {
|
||||
const text = await file.text();
|
||||
let json: unknown;
|
||||
try {
|
||||
json = JSON.parse(text);
|
||||
} catch {
|
||||
throw new Error('The file is not valid JSON.');
|
||||
}
|
||||
const res = await fetch('/api/import', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(json)
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
throw new Error(err?.message || `Import failed (${res.status})`);
|
||||
}
|
||||
const result = await res.json();
|
||||
const msg = `Imported ${result.pagesImported} page(s), ${result.globalsImported} global(s), ${result.eventsImported || 0} event(s), ${result.imagesUploaded} image(s).`;
|
||||
if (result.errors?.length) {
|
||||
// Keep the message up so the errors can be read; no auto-reload.
|
||||
importStatus = { ok: false, message: `${msg} ${result.errors.length} error(s) — reload to see the imported content.`, errors: result.errors };
|
||||
} else {
|
||||
importStatus = { ok: true, message: msg };
|
||||
setTimeout(() => location.reload(), 1500);
|
||||
}
|
||||
} catch (e) {
|
||||
importStatus = { ok: false, message: `Import error: ${e instanceof Error ? e.message : String(e)}` };
|
||||
} finally {
|
||||
importing = false;
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
|
@ -100,52 +60,47 @@
|
|||
{#if bare}
|
||||
{@render children()}
|
||||
{:else}
|
||||
<div class="admin-shell min-h-screen bg-base-200">
|
||||
<header class="navbar sticky top-0 z-30 gap-2 bg-base-100 px-4 shadow-sm">
|
||||
<div class="flex-1">
|
||||
<a class="text-lg font-bold tracking-tight" href="/pages">Massage CMS</a>
|
||||
</div>
|
||||
<nav class="flex flex-none flex-wrap items-center gap-1">
|
||||
{#each navLinks as link (link.href)}
|
||||
<a class="btn btn-ghost btn-sm" class:btn-active={isActive(link.href)} aria-current={isActive(link.href) ? 'page' : undefined} href={link.href}>{link.label}</a>
|
||||
{/each}
|
||||
<div class="dropdown dropdown-end">
|
||||
<button class="btn btn-ghost btn-sm" type="button" tabindex="0">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="size-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2M7 11l5 5 5-5M12 4v12" /></svg>
|
||||
Export/Import
|
||||
</button>
|
||||
<ul class="menu dropdown-content z-40 mt-2 w-48 rounded-box bg-base-100 p-2 shadow">
|
||||
<li><button type="button" onclick={handleExport}>Export all</button></li>
|
||||
<li>
|
||||
<button type="button" onclick={() => (document.getElementById('admin-import-file') as HTMLInputElement)?.click()} disabled={importing}>
|
||||
{importing ? 'Importing…' : 'Import'}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<input id="admin-import-file" type="file" accept=".json" class="hidden" onchange={handleImport} />
|
||||
<form method="POST" action="/login?/logout">
|
||||
<button class="btn btn-outline btn-sm" type="submit">Logout</button>
|
||||
</form>
|
||||
</nav>
|
||||
<div class="drawer lg:drawer-open">
|
||||
<input id="admin-nav" type="checkbox" class="drawer-toggle" bind:checked={navOpen} />
|
||||
|
||||
<div class="drawer-content flex min-h-screen flex-col bg-base-200">
|
||||
<!-- Top bar only on small screens; the sidebar is always visible from lg up. -->
|
||||
<header class="navbar sticky top-0 z-30 bg-base-100 px-2 shadow-sm lg:hidden">
|
||||
<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>
|
||||
</label>
|
||||
<a class="ml-1 text-lg font-bold tracking-tight" href="/pages">Massage CMS</a>
|
||||
</header>
|
||||
{#if importStatus}
|
||||
<div class="mx-auto max-w-7xl px-4 pt-4 md:px-8">
|
||||
<div class="alert items-start" class:alert-success={importStatus.ok} class:alert-error={!importStatus.ok}>
|
||||
<div class="flex-1">
|
||||
<p>{importStatus.message}</p>
|
||||
{#if importStatus.errors?.length}
|
||||
<ul class="mt-2 list-disc pl-5 text-sm">
|
||||
{#each importStatus.errors as err}<li>{err}</li>{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
<button class="btn btn-ghost btn-xs" type="button" aria-label="Dismiss" onclick={() => (importStatus = null)}>✕</button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<main class="mx-auto max-w-7xl p-4 md:p-8">
|
||||
<main class="mx-auto w-full max-w-7xl flex-1 p-4 md:p-8">
|
||||
{@render children()}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div class="drawer-side z-40">
|
||||
<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">
|
||||
<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">
|
||||
<ul class="menu w-full gap-0.5 px-3">
|
||||
{#each navGroups as group (group.title)}
|
||||
<li class="menu-title mt-3 first:mt-0">{group.title}</li>
|
||||
{#each group.links as link (link.href)}
|
||||
<li>
|
||||
<a href={link.href} class={isActive(link.href) ? 'bg-primary/10 font-semibold text-primary' : ''} aria-current={isActive(link.href) ? 'page' : undefined}>{link.label}</a>
|
||||
</li>
|
||||
{/each}
|
||||
{/each}
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="border-t border-base-300 p-4">
|
||||
{#if data.user?.email}
|
||||
<p class="mb-2 truncate text-sm text-base-content/60" title={data.user.email}>{data.user.email}</p>
|
||||
{/if}
|
||||
<form method="POST" action="/login?/logout">
|
||||
<button class="btn btn-outline btn-sm w-full" type="submit">Log out</button>
|
||||
</form>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
112
app-admin/src/routes/backup/+page.svelte
Normal file
112
app-admin/src/routes/backup/+page.svelte
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<script lang="ts">
|
||||
let importStatus = $state<{ ok: boolean; message: string; errors?: string[] } | null>(null);
|
||||
let importing = $state(false);
|
||||
let exporting = $state(false);
|
||||
let fileInput: HTMLInputElement | undefined = $state();
|
||||
|
||||
async function handleExport() {
|
||||
exporting = true;
|
||||
importStatus = null;
|
||||
try {
|
||||
const res = await fetch('/api/export');
|
||||
if (!res.ok) throw new Error(`Export failed (${res.status})`);
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `cms-export-${new Date().toISOString().slice(0, 10)}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (e) {
|
||||
importStatus = { ok: false, message: `Export error: ${e instanceof Error ? e.message : String(e)}` };
|
||||
} finally {
|
||||
exporting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleImport(event: Event) {
|
||||
const input = event.currentTarget as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (!file) return;
|
||||
if (!confirm(`Import "${file.name}"? Pages, site design and events with the same slug/key/name will be overwritten.`)) {
|
||||
input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
importing = true;
|
||||
importStatus = null;
|
||||
try {
|
||||
let json: unknown;
|
||||
try {
|
||||
json = JSON.parse(await file.text());
|
||||
} catch {
|
||||
throw new Error('The file is not valid JSON.');
|
||||
}
|
||||
const res = await fetch('/api/import', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(json)
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
throw new Error(err?.message || `Import failed (${res.status})`);
|
||||
}
|
||||
const result = await res.json();
|
||||
const message = `Imported ${result.pagesImported} page(s), ${result.globalsImported} site design section(s), ${result.eventsImported || 0} event(s), ${result.imagesUploaded} image(s).`;
|
||||
importStatus = result.errors?.length
|
||||
? { ok: false, message: `${message} ${result.errors.length} item(s) failed:`, errors: result.errors }
|
||||
: { ok: true, message };
|
||||
} catch (e) {
|
||||
importStatus = { ok: false, message: `Import error: ${e instanceof Error ? e.message : String(e)}` };
|
||||
} finally {
|
||||
importing = false;
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Backup | CMS</title></svelte:head>
|
||||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold">Backup</h1>
|
||||
<p class="text-base-content/60">Download the website content as a single file, or restore it from one.</p>
|
||||
</div>
|
||||
|
||||
{#if importStatus}
|
||||
<div class="alert mb-6 items-start" class:alert-success={importStatus.ok} class:alert-error={!importStatus.ok} role="status">
|
||||
<div>
|
||||
<p>{importStatus.message}</p>
|
||||
{#if importStatus.errors?.length}
|
||||
<ul class="mt-2 list-disc pl-5 text-sm">
|
||||
{#each importStatus.errors as err}<li>{err}</li>{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<div class="flex flex-col rounded-box bg-base-100 p-5 shadow">
|
||||
<h2 class="mb-2 text-2xl font-bold">Export</h2>
|
||||
<p class="text-sm text-base-content/60">
|
||||
Pages, site design, colors and events, with their images embedded. Services, slots, orders and email templates are not included.
|
||||
</p>
|
||||
<div class="flex-grow"></div>
|
||||
<button class="btn btn-primary mt-6 w-full" type="button" disabled={exporting} onclick={handleExport}>
|
||||
{#if exporting}<span class="loading loading-spinner loading-sm"></span>{/if}
|
||||
Download export
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col rounded-box bg-base-100 p-5 shadow">
|
||||
<h2 class="mb-2 text-2xl font-bold">Import</h2>
|
||||
<p class="text-sm text-base-content/60">
|
||||
Restores an export file. Pages with the same slug, site design sections and matching events are overwritten; everything else is kept.
|
||||
</p>
|
||||
<div class="flex-grow"></div>
|
||||
<input class="hidden" type="file" accept=".json,application/json" bind:this={fileInput} onchange={handleImport} />
|
||||
<button class="btn btn-outline mt-6 w-full" type="button" disabled={importing} onclick={() => fileInput?.click()}>
|
||||
{#if importing}<span class="loading loading-spinner loading-sm"></span> Importing…{:else}Choose export file…{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
});
|
||||
let categoryText = $state('');
|
||||
|
||||
const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
let month = $derived(createCalendarMonth(viewDate));
|
||||
const weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
let month = $derived(createCalendarMonth(viewDate, new Date(), 1));
|
||||
let action = $derived(draft.id ? '?/update' : '?/create');
|
||||
let dateInputType = $derived(draft.allDay ? 'date' : 'datetime-local');
|
||||
let startValue = $derived(draft.allDay ? toDateInput(draft.start) : toZonedDatetimeInput(draft.start, data.timezone));
|
||||
|
|
@ -86,13 +86,13 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Calendar | CMS</title></svelte:head>
|
||||
<svelte:head><title>Events | CMS</title></svelte:head>
|
||||
|
||||
<div class="space-y-6">
|
||||
<div class="flex flex-col justify-between gap-4 md:flex-row md:items-end">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold">Calendar</h1>
|
||||
<p class="text-base-content/60">Create and manage events used by Upcoming Calendar blocks.</p>
|
||||
<h1 class="text-3xl font-bold">Events</h1>
|
||||
<p class="text-base-content/60">Workshops and events shown in Upcoming Calendar blocks.</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="button" onclick={() => createEvent()}>Create event</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
};
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Globals | CMS</title></svelte:head>
|
||||
<svelte:head><title>Site design | CMS</title></svelte:head>
|
||||
|
||||
{#snippet status(section: string)}
|
||||
{#if form?.section === section && form.message}
|
||||
|
|
@ -61,8 +61,8 @@
|
|||
{/snippet}
|
||||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold">Global sections</h1>
|
||||
<p class="text-base-content/60">Edit the site header, footer, and global color settings.</p>
|
||||
<h1 class="text-3xl font-bold">Site design</h1>
|
||||
<p class="text-base-content/60">The header, footer and colors shared by every page of the site.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 xl:grid-cols-3">
|
||||
|
|
|
|||
|
|
@ -74,15 +74,15 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Items | CMS</title></svelte:head>
|
||||
<svelte:head><title>Services & products | CMS</title></svelte:head>
|
||||
|
||||
<div class="space-y-6">
|
||||
<div class="flex flex-col justify-between gap-4 md:flex-row md:items-end">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold">Items</h1>
|
||||
<p class="text-base-content/60">Manage services and products shown in Shop blocks.</p>
|
||||
<h1 class="text-3xl font-bold">Services & products</h1>
|
||||
<p class="text-base-content/60">Bookable services and products, shown in Shop blocks.</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="button" onclick={() => createItem()}>Create item</button>
|
||||
<button class="btn btn-primary" type="button" onclick={() => createItem()}>Add service or product</button>
|
||||
</div>
|
||||
|
||||
{#if form?.message}<div class="alert alert-error" role="alert">{form.message}</div>{/if}
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<Modal bind:open={showEditor} title={draft.id ? 'Edit item' : 'Create item'} wide>
|
||||
<Modal bind:open={showEditor} title={draft.id ? `Edit “${draft.name}”` : 'New service or product'} wide>
|
||||
<form method="POST" action={action} class="space-y-1">
|
||||
<input type="hidden" name="id" value={draft.id} />
|
||||
<input type="hidden" name="active" value={draft.active ? 'true' : 'false'} />
|
||||
|
|
@ -196,7 +196,7 @@
|
|||
{/if}
|
||||
<div class="flex gap-2">
|
||||
<button class="btn" type="button" onclick={() => (showEditor = false)}>Cancel</button>
|
||||
<button class="btn btn-primary" type="submit" disabled={uploading}>Save item</button>
|
||||
<button class="btn btn-primary" type="submit" disabled={uploading}>Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
{:else}
|
||||
<tr><td colspan="5" class="py-10 text-center text-base-content/60">{items.length ? 'No slots yet — create one so customers can book.' : 'Create a bookable service under Items first.'}</td></tr>
|
||||
<tr><td colspan="5" class="py-10 text-center text-base-content/60">{items.length ? 'No slots yet — create one so customers can book.' : 'Add a bookable service under Services & products first.'}</td></tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -163,11 +163,12 @@ export function getUpcomingCalendarRange(reference = new Date()) {
|
|||
return { start, end };
|
||||
}
|
||||
|
||||
export function createCalendarMonth(monthDate: Date, reference = new Date()): CalendarMonth {
|
||||
/** `weekStartsOn`: 0 = Sunday (default), 1 = Monday. */
|
||||
export function createCalendarMonth(monthDate: Date, reference = new Date(), weekStartsOn: 0 | 1 = 0): CalendarMonth {
|
||||
const first = startOfMonth(monthDate);
|
||||
const monthEnd = endOfMonth(monthDate);
|
||||
const gridStart = addDays(first, -first.getDay());
|
||||
const gridEnd = addDays(monthEnd, 6 - monthEnd.getDay());
|
||||
const gridStart = addDays(first, -((first.getDay() - weekStartsOn + 7) % 7));
|
||||
const gridEnd = addDays(monthEnd, 6 - ((monthEnd.getDay() - weekStartsOn + 7) % 7));
|
||||
const todayKey = dateKey(reference);
|
||||
const days: CalendarDay[] = [];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue