domaino/app-admin/src/lib/admin/slots/BulkActions.svelte
agent 9c1179ab93 Slots: no two slots may overlap, windows and group sessions alike
A group session could be put on top of a window (and sessions of
different services on top of each other); whichever was booked first
then blocked the other. One practitioner works every slot, so creating,
editing, generating or copying a slot now refuses any overlap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-26 17:30:08 +00:00

54 lines
2.3 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 slot.</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>