domaino/app-admin/src/lib/admin/slots/BulkActions.svelte
agent 636b59c706 Admin: lengths and prices per service; windows and group sessions on /slots
Services get rows of length + price. /slots creates windows (date, hours,
services, start-times mode) and group sessions (service, length, start,
places); the day view shows free time and bookings. Generate/copy/clear
handle both kinds; windows may not overlap and can't shrink past a booking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 20:12:46 +00:00

54 lines
2.4 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts">
// Footer of a bulk slot form: the server's preview, then Preview / confirm
// buttons. See bulkForm.svelte.ts for the two-step submit.
import { formatDateTime } from '$lib/calendar';
import { confirmSubmit } from '$lib/admin/confirm';
import type { BulkForm } from './bulkForm.svelte';
let { bulk, timezone, onCancel }: { bulk: BulkForm; timezone: string; onCancel: () => void } = $props();
let preview = $derived(bulk.preview);
let deleting = $derived(preview?.action === 'clear');
let plural = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`;
</script>
{#if bulk.error}<div class="alert alert-error mt-3 text-sm" role="alert">{bulk.error}</div>{/if}
{#if preview}
<div class="mt-3 rounded-box bg-base-200 p-4 text-sm">
{#if preview.count}
<p class="font-semibold">
{plural(preview.count, 'slot')} will be {deleting ? 'deleted' : 'created'}{preview.count > 1
? `, from ${formatDateTime(preview.firstStart, timezone)} to ${formatDateTime(preview.lastStart, timezone)}`
: `, at ${formatDateTime(preview.firstStart, timezone)}`}.
</p>
{:else}
<p class="font-semibold">Nothing to {deleting ? 'delete' : 'create'}.</p>
{/if}
<ul class="mt-1 list-inside list-disc text-base-content/70 empty:hidden">
{#if preview.skippedOverlap}<li>{plural(preview.skippedOverlap, 'slot')} skipped — it would overlap another window, or a session of the same service.</li>{/if}
{#if preview.skippedPast}<li>{plural(preview.skippedPast, 'slot')} skipped — in the past.</li>{/if}
{#if preview.kept}<li>{plural(preview.kept, 'slot')} kept — something in it is booked, or in a customer’s basket right now.</li>{/if}
</ul>
</div>
{/if}
<div class="modal-action">
<button class="btn" type="button" onclick={onCancel}>Cancel</button>
<button class={['btn', !preview?.count && 'btn-primary']} type="submit" name="intent" value="preview" disabled={bulk.busy}>
{#if bulk.busy}<span class="loading loading-spinner loading-xs"></span>{/if}
{preview ? 'Preview again' : 'Preview'}
</button>
{#if preview?.count}
<button
class={['btn', deleting ? 'btn-error' : 'btn-primary']}
type="submit"
name="intent"
value="create"
disabled={bulk.busy}
onclick={deleting ? confirmSubmit(`Delete ${plural(preview.count, 'slot')}?`) : undefined}
>
{deleting ? 'Delete' : 'Create'} {plural(preview.count, 'slot')}
</button>
{/if}
</div>