Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,318 @@
import { useMemo, useState } from "react";
import { Form, useNavigation } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherCalendarClock, FeatherGlobe, FeatherPlus, FeatherTrash2 } from "@subframe/core";
import {
AVAILABILITY_WEEKDAYS,
availabilityWeekdayKey,
serializeAvailabilityPayload,
type AvailabilityExceptionKindVM,
type AvailabilityVM,
type AvailabilityWeekday,
} from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { Button } from "~/ui/components/Button";
import { IconButton } from "~/ui/components/IconButton";
import { DropdownMenuMultiSelect } from "~/ui/components/DropdownMenuMultiSelect";
import { FilterBar } from "~/ui/components/FilterBar";
import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
import { FULL_BLEED_BAR_CLASS } from "../shared/FacetFilterBar";
import { PageHeader } from "../automation/automationUi";
/**
* AK-P16b · interim availability editor (AD-28, archetype A6+A4): weekly rules
* (multiple windows per day), date exceptions (unavailable / custom window)
* and one shared timezone. The whole draft is serialized into a single
* `payload` field and replaced atomically by the route action
* (AvailabilityService deep-validates). Final Subframe optics follow David's
* D-P16 delta (design-nachzug).
*/
export interface AvailabilityPageProps {
vm: AvailabilityVM;
csrf: string | null;
actionData: { ok: true } | { ok: false; errorKey: string } | null;
}
interface DraftWindow {
key: number;
dayOfWeek: AvailabilityWeekday;
startTime: string;
endTime: string;
}
interface DraftException {
key: number;
date: string;
kind: AvailabilityExceptionKindVM;
startTime: string;
endTime: string;
reason: string;
}
const TIMEZONES = ["Europe/Berlin", "Europe/Vienna", "Europe/Zurich", "Europe/Amsterdam", "Europe/Paris", "Europe/London", "Europe/Madrid", "Europe/Rome", "Europe/Warsaw", "UTC"];
const TIME_OPTIONS: readonly string[] = Array.from({ length: 24 * 4 }, (_, index) => {
const hours = String(Math.floor(index / 4)).padStart(2, "0");
const minutes = String((index % 4) * 15).padStart(2, "0");
return `${hours}:${minutes}`;
});
let draftKeyCounter = 1;
function nextKey(): number {
draftKeyCounter += 1;
return draftKeyCounter;
}
function TimeSelect({ value, onChange, label }: { value: string; onChange: (value: string) => void; label: string }): React.JSX.Element {
return (
<Select className="w-28" value={value} onValueChange={onChange} aria-label={label}>
{TIME_OPTIONS.map((time) => (
<Select.Item key={time} value={time}>
{time}
</Select.Item>
))}
</Select>
);
}
export function AvailabilityPage({ vm, csrf, actionData }: AvailabilityPageProps): React.JSX.Element {
const { t } = useTranslation();
const navigation = useNavigation();
const initial = vm.status === "ready" && vm.data ? vm.data : null;
const [timezone, setTimezone] = useState<string>(initial?.defaultTimezone ?? "Europe/Berlin");
const [windows, setWindows] = useState<readonly DraftWindow[]>(
() =>
initial?.rulesByWeekday.flatMap((group) =>
group.windows.map((rule) => ({ key: nextKey(), dayOfWeek: group.day, startTime: rule.startTime, endTime: rule.endTime })),
) ?? [],
);
const [exceptions, setExceptions] = useState<readonly DraftException[]>(
() =>
initial?.exceptions.map((exception) => ({
key: nextKey(),
date: exception.date,
kind: exception.kind,
startTime: exception.startTime ?? "09:00",
endTime: exception.endTime ?? "17:00",
reason: exception.reason ?? "",
})) ?? [],
);
const payload = useMemo(
() =>
serializeAvailabilityPayload({
rules: windows.map((window) => ({ dayOfWeek: window.dayOfWeek, startTime: window.startTime, endTime: window.endTime, timezone })),
exceptions: exceptions
.filter((exception) => exception.date)
.map((exception) => ({
date: exception.date,
kind: exception.kind,
startTime: exception.kind === "custom_window" ? exception.startTime : null,
endTime: exception.kind === "custom_window" ? exception.endTime : null,
reason: exception.reason.trim() || null,
timezone,
})),
}),
[windows, exceptions, timezone],
);
if (!initial) {
return <div className="flex w-full flex-col" data-ui-id="ui.booking.availability" />;
}
const saving = navigation.state === "submitting";
const updateWindow = (key: number, patch: Partial<DraftWindow>) => {
setWindows((current) => current.map((window) => (window.key === key ? { ...window, ...patch } : window)));
};
const updateException = (key: number, patch: Partial<DraftException>) => {
setExceptions((current) => current.map((exception) => (exception.key === key ? { ...exception, ...patch } : exception)));
};
return (
<div className="flex w-full flex-col" data-ui-id="ui.booking.availability">
<Form method="post" className="contents">
{csrf ? <input type="hidden" name="csrf" value={csrf} /> : null}
<input type="hidden" name="payload" value={payload} />
<PageHeader
icon={<FeatherCalendarClock className="text-heading-3 font-heading-3 text-icon-neutral-secondary" />}
title={t("bookings.availability.title")}
subtitle={t("bookings.availability.subtitle")}
actions={
<Button type="submit" loading={saving} data-ui-id="ui.booking.availability.save">
{t("bookings.availability.save")}
</Button>
}
/>
{/* Timezone rides the full-bleed strip under the header, as a dropdown
pill in the same shape the list screens use for their filter items.
It is not a filter and never gets a removable chip: a booking
calendar always has exactly one timezone, so the pill carries the
current value in its own label and the strip stays chip-free. */}
<FilterBar
className={FULL_BLEED_BAR_CLASS}
hideSearch
showActiveFilters={false}
data-ui-id="ui.booking.availability.toolbar"
>
<FilterBar.StatusFilterButton
icon={<FeatherGlobe />}
label={`${t("bookings.availability.timezone")}: ${timezone}`}
data-ui-id="ui.booking.availability.timezone"
dropdown={
<DropdownMenuMultiSelect>
{(TIMEZONES.includes(timezone) ? TIMEZONES : [timezone, ...TIMEZONES]).map((zone) => (
<DropdownMenuMultiSelect.DropdownItem
key={zone}
showCheckbox
selected={zone === timezone}
onClick={() => setTimezone(zone)}
data-ui-id={`ui.booking.availability.timezone.${zone}`}
>
{zone}
</DropdownMenuMultiSelect.DropdownItem>
))}
</DropdownMenuMultiSelect>
}
/>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("bookings.availability.timezoneHelp")}
</span>
</FilterBar>
<div className="flex w-full flex-col gap-6 p-6 mobile:p-4">
{actionData && !actionData.ok ? (
<div data-ui-id="ui.booking.availability.error">
<Alert variant="error" title={t(actionData.errorKey)} />
</div>
) : null}
{actionData?.ok ? (
<div data-ui-id="ui.booking.availability.saved">
<Alert variant="success" title={t("bookings.availability.saved")} />
</div>
) : null}
<div className="flex w-full flex-col gap-2" data-ui-id="ui.booking.availability.rules">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.availability.weekly")}</span>
{/* No empty state here: the weekday rows below are the only way to add
a window, so they must stay visible. Each day already reads
"unavailable" on its own — an extra "no availability yet" panel on
top of the full week contradicted itself. */}
<div className="flex w-full flex-col overflow-hidden rounded-lg border border-solid border-border-default bg-surface-neutral-primary">
{AVAILABILITY_WEEKDAYS.map((day) => {
const dayWindows = windows.filter((window) => window.dayOfWeek === day);
return (
<div key={day} className="flex w-full items-start gap-4 border-b border-solid border-border-default p-4 last:border-b-0" data-day={day}>
<span className="w-32 flex-none pt-2 text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
{t(availabilityWeekdayKey(day))}
</span>
<div className="flex min-w-0 grow flex-col gap-2">
{dayWindows.length === 0 ? (
<span className="pt-2 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t("bookings.availability.dayUnavailable")}
</span>
) : (
dayWindows.map((window) => (
<div key={window.key} className="flex flex-wrap items-center gap-2">
<TimeSelect value={window.startTime} onChange={(value) => updateWindow(window.key, { startTime: value })} label={t("bookings.availability.from")} />
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">–</span>
<TimeSelect value={window.endTime} onChange={(value) => updateWindow(window.key, { endTime: value })} label={t("bookings.availability.to")} />
<IconButton
type="button"
variant="ghost"
size="small"
icon={<FeatherTrash2 />}
aria-label={t("bookings.availability.removeWindow")}
onClick={() => setWindows((current) => current.filter((existing) => existing.key !== window.key))}
/>
</div>
))
)}
</div>
<Button
type="button"
variant="tertiary"
size="small"
icon={<FeatherPlus />}
onClick={() => setWindows((current) => [...current, { key: nextKey(), dayOfWeek: day, startTime: "09:00", endTime: "17:00" }])}
>
{t("bookings.availability.addWindow")}
</Button>
</div>
);
})}
</div>
</div>
<div className="flex w-full flex-col gap-2" data-ui-id="ui.booking.availability.exceptions">
<div className="flex w-full items-center justify-between gap-4">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.availability.exceptions")}</span>
<Button
type="button"
variant="tertiary"
size="small"
icon={<FeatherPlus />}
onClick={() => setExceptions((current) => [...current, { key: nextKey(), date: "", kind: "unavailable", startTime: "09:00", endTime: "17:00", reason: "" }])}
>
{t("bookings.availability.addException")}
</Button>
</div>
{exceptions.length === 0 ? (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("bookings.availability.noExceptions")}</span>
) : (
<div className="flex w-full flex-col gap-3 rounded-lg border border-solid border-border-default bg-surface-neutral-primary p-4">
{exceptions.map((exception) => (
<div key={exception.key} className="flex flex-wrap items-end gap-3">
<TextInput className="w-44" label={t("bookings.availability.exceptionDate")} showLabel>
{/* The synced kit's type union lacks "date"; the prop is passed through to the native input. */}
<TextInput.Input
type={"date" as unknown as "text"}
value={exception.date}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => updateException(exception.key, { date: event.target.value })}
/>
</TextInput>
<Select
className="w-52"
label={t("bookings.availability.exceptionKind")}
showLabel
value={exception.kind}
onValueChange={(value: string) => updateException(exception.key, { kind: value as AvailabilityExceptionKindVM })}
>
<Select.Item value="unavailable">{t("bookings.availability.kind.unavailable")}</Select.Item>
<Select.Item value="custom_window">{t("bookings.availability.kind.custom_window")}</Select.Item>
</Select>
{exception.kind === "custom_window" ? (
<div className="flex items-center gap-2">
<TimeSelect value={exception.startTime} onChange={(value) => updateException(exception.key, { startTime: value })} label={t("bookings.availability.from")} />
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">–</span>
<TimeSelect value={exception.endTime} onChange={(value) => updateException(exception.key, { endTime: value })} label={t("bookings.availability.to")} />
</div>
) : null}
<TextInput className="w-56" label={t("bookings.availability.exceptionReason")} showLabel>
<TextInput.Input
value={exception.reason}
placeholder={t("bookings.availability.exceptionReasonPlaceholder")}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => updateException(exception.key, { reason: event.target.value })}
/>
</TextInput>
<IconButton
type="button"
variant="ghost"
size="small"
icon={<FeatherTrash2 />}
aria-label={t("bookings.availability.removeException")}
onClick={() => setExceptions((current) => current.filter((existing) => existing.key !== exception.key))}
/>
</div>
))}
</div>
)}
</div>
</div>
</Form>
</div>
);
}
@@ -0,0 +1,286 @@
import { useState } from "react";
import { Form, useNavigate, useNavigation } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherCalendarClock, FeatherCheck, FeatherUserX } from "@subframe/core";
import type { BookingDetailVM, RescheduleSlotOption } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Calendar } from "~/ui/components/Calendar";
import { Card } from "~/ui/components/Card";
import { Dialog } from "~/ui/components/Dialog";
import { Loader } from "~/ui/components/Loader";
import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
import { bookingStatusTone } from "./BookingListPage";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
/**
* AK-P16b · interim booking detail (AD-28, archetype A3): appointment data,
* intake answers and the full M129 lifecycle — held/no-show inline, cancel
* (reason) / reschedule (slot picker) / re-assign (provider select) as real
* Dialogs (S 560) posting the route's existing intents. Date selection
* GET-navigates `?slotsDate=` so the loader recomputes engine slots; the
* component stays mounted, so the dialog survives the navigation. Final
* Subframe optics follow David's D-P16 delta (design-nachzug).
*
* Page chrome matches the boards/pipelines and task/lead detail screens: the
* full-bleed PageHeader bar carries icon, title, status badge and the lifecycle
* actions, content sits in PageBody Cards. Navigation back to the list is the
* app breadcrumb's job, so the screen renders no back link of its own.
*/
export interface BookingDetailPageProps {
vm: BookingDetailVM;
csrf: string | null;
rescheduleSlots: readonly RescheduleSlotOption[] | null;
slotsDate: string | null;
}
type OpenDialog = "cancel" | "reschedule" | "reassign" | null;
/** Card section heading — same weight the task/lead detail cards use. */
const SECTION_HEADING_CLASS = "text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary";
function isoToLocalDate(dateIso: string): Date {
const [year, month, day] = dateIso.split("-").map(Number);
return new Date(year ?? 1970, (month ?? 1) - 1, day ?? 1);
}
function localDateToIso(date: Date): string {
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${date.getFullYear()}-${month}-${day}`;
}
function CsrfField({ csrf }: { csrf: string | null }): React.JSX.Element | null {
return csrf ? <input type="hidden" name="csrf" value={csrf} /> : null;
}
export function BookingDetailPage({ vm, csrf, rescheduleSlots, slotsDate }: BookingDetailPageProps): React.JSX.Element {
const { t } = useTranslation();
const navigate = useNavigate();
const navigation = useNavigation();
const [openDialog, setOpenDialog] = useState<OpenDialog>(null);
const [selectedSlot, setSelectedSlot] = useState<string | null>(null);
const [selectedProvider, setSelectedProvider] = useState<string>("");
if (vm.status !== "ready" || !vm.data) {
return <PageShell uiId="ui.booking.detail" />;
}
const data = vm.data;
const canAct = data.canWrite && data.status === "scheduled";
const loadingSlots = navigation.state === "loading" && navigation.location?.search.includes("slotsDate=");
const closeDialogProps = (dialog: OpenDialog) => ({
open: openDialog === dialog,
onOpenChange: (open: boolean) => {
if (!open) setOpenDialog(null);
},
});
return (
<PageShell uiId="ui.booking.detail" className="bg-surface-neutral-primary">
<PageHeader
uiId="ui.booking.detail.header"
icon={<FeatherCalendarClock className={PAGE_HEADER_ICON_CLASS} />}
title={
<span className="inline-flex flex-wrap items-center gap-2">
{data.pageTitle}
<span data-status={data.status}>
<BadgeFeedback farbe={bookingStatusTone(data.status)} size="small">
{t(data.statusKey)}
</BadgeFeedback>
</span>
</span>
}
subtitle={data.whenLabel}
subtitleTone="secondary"
actions={
canAct ? (
<span className="flex flex-wrap items-center gap-2" data-ui-id="ui.booking.detail.actions">
<Form method="post">
<CsrfField csrf={csrf} />
<input type="hidden" name="intent" value="held" />
<Button type="submit" variant="secondary" icon={<FeatherCheck />}>
{t("bookings.actions.markHeld")}
</Button>
</Form>
<Form method="post">
<CsrfField csrf={csrf} />
<input type="hidden" name="intent" value="no_show" />
<Button type="submit" variant="secondary" icon={<FeatherUserX />}>
{t("bookings.actions.markNoShow")}
</Button>
</Form>
<Button variant="secondary" icon={<FeatherCalendarClock />} onClick={() => setOpenDialog("reschedule")} data-ui-id="ui.booking.detail.reschedule">
{t("bookings.actions.reschedule")}
</Button>
{data.canAdmin ? (
<Button variant="secondary" onClick={() => setOpenDialog("reassign")} data-ui-id="ui.booking.detail.reassign">
{t("bookings.actions.reassign")}
</Button>
) : null}
<Button variant="destructive" onClick={() => setOpenDialog("cancel")} data-ui-id="ui.booking.detail.cancel">
{t("bookings.actions.cancel")}
</Button>
</span>
) : undefined
}
/>
<PageBody>
{data.cancellationReason ? <Alert variant="error" title={t("bookings.detail.cancelledBanner")} description={data.cancellationReason} /> : null}
<Card data-ui-id="ui.booking.detail.customer">
<span className={SECTION_HEADING_CLASS}>{t("bookings.detail.customer")}</span>
<div className="flex flex-col gap-1">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{data.customerName || "—"}</span>
{data.customerEmail ? (
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{data.customerEmail}</span>
) : null}
</div>
</Card>
{data.intake.length > 0 ? (
<Card data-ui-id="ui.booking.detail.intake">
<span className={SECTION_HEADING_CLASS}>{t("bookings.detail.intake")}</span>
<dl className="grid w-full grid-cols-1 gap-4 sm:grid-cols-2">
{data.intake.map((entry) => (
<div key={entry.key} className="flex min-w-0 flex-col gap-1">
<dt className="break-words text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{entry.key}</dt>
<dd className="break-words text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{entry.value || "—"}</dd>
</div>
))}
</dl>
</Card>
) : null}
</PageBody>
{/* Cancel (S 560): reason + destructive confirm, auto-mail server-side. */}
<Dialog {...closeDialogProps("cancel")}>
<Dialog.Content className="w-[560px] max-w-[90vw] p-4">
<Form method="post" className="flex w-full flex-col gap-6" data-ui-id="ui.booking.detail.cancelDialog">
<CsrfField csrf={csrf} />
<input type="hidden" name="intent" value="cancel" />
<div className="flex flex-col gap-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.cancelDialog.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("bookings.cancelDialog.body")}</span>
</div>
<TextInput className="w-full" label={t("bookings.actions.cancelReason")} showLabel>
<TextInput.Input name="reason" placeholder={t("bookings.cancelDialog.reasonPlaceholder")} />
</TextInput>
<div className="flex w-full items-center justify-end gap-2">
<Button type="button" variant="tertiary" onClick={() => setOpenDialog(null)}>
{t("shared.cancel")}
</Button>
<Button type="submit" variant="destructive">
{t("bookings.cancelDialog.confirm")}
</Button>
</div>
</Form>
</Dialog.Content>
</Dialog>
{/* Reschedule (S 560): pick a date -> loader recomputes slots -> pick a slot. */}
<Dialog {...closeDialogProps("reschedule")}>
<Dialog.Content className="w-[560px] max-w-[90vw] p-4">
<div className="flex w-full flex-col gap-6" data-ui-id="ui.booking.detail.rescheduleDialog">
<div className="flex flex-col gap-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.reschedule.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("bookings.reschedule.body")}</span>
</div>
<div className="flex w-full justify-center">
<Calendar
mode="single"
selected={slotsDate ? isoToLocalDate(slotsDate) : undefined}
disabled={{ before: isoToLocalDate(data.minRescheduleDateIso), after: isoToLocalDate(data.maxRescheduleDateIso) }}
onSelect={(date: Date | undefined) => {
if (!date) return;
setSelectedSlot(null);
navigate(`?slotsDate=${localDateToIso(date)}`, { preventScrollReset: true, replace: true });
}}
/>
</div>
{loadingSlots ? (
<div className="flex w-full justify-center py-2">
<Loader />
</div>
) : slotsDate && rescheduleSlots ? (
rescheduleSlots.length === 0 ? (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("bookings.reschedule.noSlots")}</span>
) : (
<div className="flex w-full flex-wrap gap-2" data-ui-id="ui.booking.detail.rescheduleSlots">
{rescheduleSlots.map((slot) => (
<button
key={slot.startAtIso}
type="button"
onClick={() => setSelectedSlot(slot.startAtIso)}
className={
selectedSlot === slot.startAtIso
? "flex items-center rounded-md border border-solid border-brand-brand-border-solid-default bg-brand-brand-secondary-surface-subtle px-3 py-1.5 text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary"
: "flex items-center rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-3 py-1.5 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary hover:bg-surface-neutral-tertiary"
}
>
{slot.label}
</button>
))}
</div>
)
) : (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("bookings.reschedule.pickDateHint")}</span>
)}
<Form method="post" className="flex w-full items-center justify-end gap-2">
<CsrfField csrf={csrf} />
<input type="hidden" name="intent" value="reschedule" />
{selectedSlot ? <input type="hidden" name="newStartAt" value={selectedSlot} /> : null}
<Button type="button" variant="tertiary" onClick={() => setOpenDialog(null)}>
{t("shared.cancel")}
</Button>
<Button type="submit" disabled={!selectedSlot} data-ui-id="ui.booking.detail.rescheduleSubmit">
{t("bookings.reschedule.confirm")}
</Button>
</Form>
</div>
</Dialog.Content>
</Dialog>
{/* Re-assign (S 560, admin): pick another provider. */}
<Dialog {...closeDialogProps("reassign")}>
<Dialog.Content className="w-[560px] max-w-[90vw] p-4">
<Form method="post" className="flex w-full flex-col gap-6" data-ui-id="ui.booking.detail.reassignDialog">
<CsrfField csrf={csrf} />
<input type="hidden" name="intent" value="reassign" />
<div className="flex flex-col gap-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.reassign.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("bookings.reassign.body")}</span>
</div>
<Select
className="w-full"
label={t("bookings.reassign.providerLabel")}
showLabel
placeholder={t("bookings.reassign.providerPlaceholder")}
value={selectedProvider || undefined}
onValueChange={(value: string) => setSelectedProvider(value)}
>
{data.providerOptions.map((option) => (
<Select.Item key={option.id} value={option.id}>
{option.label}
</Select.Item>
))}
</Select>
{selectedProvider ? <input type="hidden" name="newProviderUserId" value={selectedProvider} /> : null}
<div className="flex w-full items-center justify-end gap-2">
<Button type="button" variant="tertiary" onClick={() => setOpenDialog(null)}>
{t("shared.cancel")}
</Button>
<Button type="submit" disabled={!selectedProvider} data-ui-id="ui.booking.detail.reassignSubmit">
{t("bookings.reassign.confirm")}
</Button>
</div>
</Form>
</Dialog.Content>
</Dialog>
</PageShell>
);
}
@@ -0,0 +1,94 @@
// AK-P16b interim-UI — BookingListPage unit test. Fixture VM built via the real
// buildBookingListVM, rendered, interactions asserted on what the table shows.
// i18n is mocked so `t` echoes the key.
import { fireEvent, render, waitFor } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { buildBookingListVM, bookingStatusKey, type BookingListRow } from "@hivegrid/view-models";
import { BookingListPage } from "./BookingListPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de" } }),
}));
const NOW_ISO = "2026-07-15T12:00:00.000Z";
function row(id: string, over: Partial<BookingListRow> = {}): BookingListRow {
return {
id,
startAtIso: "2026-07-20T09:00:00.000Z",
endAtIso: "2026-07-20T10:00:00.000Z",
status: "scheduled",
statusKey: bookingStatusKey("scheduled"),
customerName: "Anna Muster",
customerEmail: "anna@example.com",
pageTitle: "Erstberatung",
providerUserId: "u1",
detailHref: `/acme/bookings/${id}`,
...over,
};
}
/** Upcoming + a cancelled one, so the buckets are actually distinguishable. */
function renderPage(rows: BookingListRow[]) {
return render(
<MemoryRouter>
<BookingListPage vm={buildBookingListVM({ rows })} nowIso={NOW_ISO} pagesHref={null} />
</MemoryRouter>
);
}
function byUiId(id: string): HTMLElement {
const element = document.querySelector(`[data-ui-id='${id}']`);
if (!(element instanceof HTMLElement)) throw new Error(`Missing element ${id}`);
return element;
}
describe("BookingListPage", () => {
it("wears the shared filter bar instead of its own tab strip", () => {
renderPage([row("b1")]);
expect(byUiId("ui.booking.list.filter")).toBeTruthy();
expect(document.querySelector("[data-ui-id='ui.booking.list.filter.search']")).not.toBeNull();
expect(document.querySelector("[data-ui-id='ui.booking.list.filter.tab']")).not.toBeNull();
});
it("opens on the upcoming bucket and reads it back off the facet button", () => {
renderPage([row("b1"), row("b2", { status: "cancelled", statusKey: bookingStatusKey("cancelled") })]);
// The button states the active bucket without being opened.
expect(byUiId("ui.booking.list.filter.tab").textContent).toContain("bookings.list.tabs.upcoming");
// Only the upcoming row is on screen; the cancelled one sits in its own bucket.
expect(document.querySelectorAll("tbody tr")).toHaveLength(1);
});
it("switches buckets and returns to all when the active one is picked again", async () => {
renderPage([row("b1"), row("b2", { status: "cancelled", statusKey: bookingStatusKey("cancelled") })]);
// Radix opens on keyboard/pointerdown, not on a plain click in jsdom.
const openFacet = async () => {
fireEvent.keyDown(byUiId("ui.booking.list.filter.tab"), { key: "Enter" });
await waitFor(() => byUiId("ui.booking.list.filter.tab.cancelled"));
};
await openFacet();
fireEvent.click(byUiId("ui.booking.list.filter.tab.cancelled"));
expect(document.querySelectorAll("tbody tr")).toHaveLength(1);
expect(byUiId("ui.booking.list.filter.tab").textContent).toContain("bookings.list.tabs.cancelled");
// Picking the active bucket again clears it, which is "Alle" — both rows.
fireEvent.click(byUiId("ui.booking.list.filter.tab.cancelled"));
expect(document.querySelectorAll("tbody tr")).toHaveLength(2);
});
it("narrows the visible rows by the searched customer or page", () => {
renderPage([row("b1"), row("b2", { customerName: "Bea Beispiel", customerEmail: "bea@example.com" })]);
fireEvent.change(byUiId("ui.booking.list.filter.search"), { target: { value: "bea" } });
expect(document.querySelectorAll("tbody tr")).toHaveLength(1);
// A search that matches nothing says so instead of looking like an empty list.
fireEvent.change(byUiId("ui.booking.list.filter.search"), { target: { value: "kabelkanal" } });
expect(byUiId("ui.booking.list.noMatches")).toBeTruthy();
});
});
@@ -0,0 +1,202 @@
import { useMemo, useState } from "react";
import { Link, useNavigate } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherCalendarClock, FeatherSettings } from "@subframe/core";
import { bookingListTab, type BookingListRow, type BookingListTab, type BookingListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
import { useLocaleFormatters } from "~/locale/format";
import { PageHeader } from "../automation/automationUi";
import { FacetFilterBar } from "../shared/FacetFilterBar";
/**
* AK-P16b · interim bookings list (AD-28, archetype A2): tab buckets
* (upcoming/past/cancelled/all) + client-side search over the server-built,
* owner-filtered BookingListVM. Bulk-cancel and CSV export from the designer
* brief are outside the ticket DoD and deferred to the D-P16 nachzug. Final
* Subframe optics follow David's D-P16 delta (design-nachzug).
*/
export interface BookingListPageProps {
vm: BookingListVM;
/** Loader-resolved "now" so the tab bucketing matches SSR (hydration rule). */
nowIso: string;
/** Inline link to the booking-pages admin list; null when the user may not view it. */
pagesHref?: string | null;
}
type TabFilter = BookingListTab | "all";
const TABS: readonly TabFilter[] = ["upcoming", "past", "cancelled", "all"];
export function bookingStatusTone(status: BookingListRow["status"]): React.ComponentProps<typeof BadgeFeedback>["farbe"] {
if (status === "scheduled") return "subtle-information";
if (status === "held") return "subtle-positive";
if (status === "cancelled") return "subtle-negative";
if (status === "no_show") return "subtle-warning";
return "subtle-neutral";
}
export function BookingListPage({ vm, nowIso, pagesHref }: BookingListPageProps): React.JSX.Element {
const { t } = useTranslation();
const formatters = useLocaleFormatters();
const navigate = useNavigate();
const [tab, setTab] = useState<TabFilter>("upcoming");
const [query, setQuery] = useState("");
const rows = vm.status === "ready" && vm.data ? vm.data.rows : [];
const counts = useMemo(() => {
const byTab: Record<TabFilter, number> = { upcoming: 0, past: 0, cancelled: 0, all: rows.length };
for (const row of rows) {
byTab[bookingListTab(row, nowIso)] += 1;
}
return byTab;
}, [rows, nowIso]);
const visibleRows = useMemo(() => {
const needle = query.trim().toLowerCase();
return rows.filter((row) => {
if (tab !== "all" && bookingListTab(row, nowIso) !== tab) return false;
if (!needle) return true;
return `${row.customerName} ${row.customerEmail} ${row.pageTitle}`.toLowerCase().includes(needle);
});
}, [rows, tab, query, nowIso]);
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col" data-ui-id="ui.booking.list" />;
}
const { emptyHeadlineKey, emptyBodyKey } = vm.data;
return (
<div className="flex w-full flex-col" data-ui-id="ui.booking.list">
<PageHeader
icon={<FeatherCalendarClock className="text-heading-3 font-heading-3 text-icon-neutral-secondary" />}
title={t("bookings.list.title")}
subtitle={t("bookings.list.subtitle")}
actions={
pagesHref ? (
<Link to={pagesHref} className="no-underline" data-ui-id="ui.booking.list.managePages">
<Button variant="secondary" icon={<FeatherSettings />}>
{t("bookings.list.managePages")}
</Button>
</Link>
) : undefined
}
/>
{/* --- Filter bar: the shared facet strip the other lists wear. The tab
buckets became one facet, keeping their counts in the option labels;
"Alle" is the state with nothing picked, so the chip's X leads back to
it. --- */}
<FacetFilterBar
uiId="ui.booking.list.filter"
facets={[
{
key: "tab",
label: t(`bookings.list.tabs.${tab}`),
icon: <FeatherCalendarClock />,
tone: "blue-subtle",
options: TABS.filter((tabKey) => tabKey !== "all").map((tabKey) => ({
value: tabKey,
label: `${t(`bookings.list.tabs.${tabKey}`)} (${formatters.number(counts[tabKey])})`,
})),
selected: new Set(tab === "all" ? [] : [tab]),
},
]}
onToggle={(_facetKey, value) => setTab(tab === value ? "all" : (value as TabFilter))}
search={query}
onSearchChange={setQuery}
searchPlaceholder={t("bookings.list.searchPlaceholder")}
onReset={() => {
setTab("all");
setQuery("");
}}
labels={{ reset: t("bookings.list.filter.reset"), removeChip: t("bookings.list.filter.removeChip") }}
/>
<div className="flex w-full flex-col gap-4 p-6 mobile:p-4">
{rows.length === 0 ? (
<div data-ui-id="ui.booking.list.empty">
<EmptyState
outlined
fillContainer
title={t(emptyHeadlineKey)}
body={t(emptyBodyKey)}
action={
pagesHref ? (
<Link to={pagesHref} className="no-underline">
<Button variant="secondary">{t("bookings.list.managePages")}</Button>
</Link>
) : undefined
}
/>
</div>
) : visibleRows.length === 0 ? (
<div className="flex w-full flex-col items-center gap-3 rounded-lg border border-dashed border-border-default px-6 py-10" data-ui-id="ui.booking.list.noMatches">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("bookings.list.noMatches.headline")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("bookings.list.noMatches.body")}</span>
<Button
variant="secondary"
size="small"
onClick={() => {
setTab("all");
setQuery("");
}}
>
{t("bookings.list.noMatches.reset")}
</Button>
</div>
) : (
<div className="w-full overflow-x-auto rounded-lg border border-solid border-border-default bg-surface-neutral-primary shadow-sm" data-ui-id="ui.booking.list.table">
<Table
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("bookings.list.columns.when")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.list.columns.customer")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.list.columns.page")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.list.columns.status")}</Table.HeaderCell>
</Table.HeaderRow>
}
>
{/* Double-click anywhere in a row opens the booking — same affordance
the Plantafel table has. The date cell keeps its link so single
click, middle click and keyboard navigation still work. */}
{visibleRows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id} clickable onDoubleClick={() => navigate(row.detailHref)}>
<Table.Cell>
<Link
to={row.detailHref}
className="whitespace-nowrap text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-primary no-underline hover:text-text-feedback-link-default"
>
{formatters.dateTime(row.startAtIso)}
</Link>
</Table.Cell>
<Table.Cell>
<div className="flex flex-col">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{row.customerName}</span>
{row.customerEmail ? (
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">{row.customerEmail}</span>
) : null}
</div>
</Table.Cell>
<Table.Cell>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{row.pageTitle}</span>
</Table.Cell>
<Table.Cell>
<span data-status={row.status}>
<BadgeFeedback farbe={bookingStatusTone(row.status)} size="small">
{t(row.statusKey)}
</BadgeFeedback>
</span>
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
</div>
);
}
@@ -0,0 +1,181 @@
import { useState } from "react";
import { Form } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherCalendarClock, FeatherSave } from "@subframe/core";
import { Alert } from "~/ui/components/Alert";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Checkbox } from "~/ui/components/Checkbox";
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
import { NumberInput } from "~/ui/components/NumberInput";
import { Select } from "~/ui/components/Select";
import { Switch } from "~/ui/components/Switch";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
import type { BookingPageEditorLoaderData } from "~/modules/booking/routes/BookingPageEditor.server";
import { PAGE_HEADER_ICON_CLASS, PageBackLink, PageBody, PageHeader, PageShell } from "../shared/PageShell";
/**
* AK-P16b · interim booking-page editor (AD-28, archetype A6+A4): basics,
* duration, provider checkboxes (serialized into the action's `providers`
* field), intake-form select (AK-P16c link), confirmation-mail template,
* publish switch, plus the public-URL/embed-code copy section in edit mode.
* Final Subframe optics follow David's D-P16 delta (design-nachzug).
*/
const NO_INTAKE_FORM = "__none__";
export interface BookingPageEditorPageProps {
vm: BookingPageEditorLoaderData;
actionErrorKey: string | null;
csrf: string | null;
}
export function BookingPageEditorPage({ vm, actionErrorKey, csrf }: BookingPageEditorPageProps): React.JSX.Element {
const { t } = useTranslation();
const page = vm.page;
const [selectedProviders, setSelectedProviders] = useState<readonly string[]>(page?.providerUserIds ?? []);
const [intakeFormId, setIntakeFormId] = useState<string>(page?.intakeFormId ?? NO_INTAKE_FORM);
const [isPublished, setIsPublished] = useState<boolean>(page?.isPublished ?? false);
const toggleProvider = (id: string, checked: boolean) => {
setSelectedProviders((current) => (checked ? [...current, id] : current.filter((existing) => existing !== id)));
};
return (
<PageShell uiId="ui.booking.pages.editor">
<PageHeader
icon={<FeatherCalendarClock className={PAGE_HEADER_ICON_CLASS} />}
title={vm.mode === "new" ? t("bookings.pages.new") : t("bookings.pages.editor.title")}
subtitle={t("bookings.pages.editor.subtitle")}
/>
<PageBody>
<PageBackLink to={vm.listHref} label={t("bookings.pages.editor.back")} uiId="ui.booking.pages.editor.back" />
{actionErrorKey ? (
<div data-ui-id="ui.booking.pages.editor.error">
<Alert variant="error" title={t(actionErrorKey)} />
</div>
) : null}
<Form method="post" className="flex w-full flex-col gap-6">
{csrf ? <input type="hidden" name="csrf" value={csrf} /> : null}
<input type="hidden" name="providers" value={selectedProviders.join(",")} />
<input type="hidden" name="intakeFormId" value={intakeFormId === NO_INTAKE_FORM ? "" : intakeFormId} />
{isPublished ? <input type="hidden" name="isPublished" value="on" /> : null}
{/* The sections tile across the available width: on wide screens the
primary "Grunddaten" card spans the full row, with providers and the
confirmation mail sharing the row below. */}
<div className="grid w-full grid-cols-1 gap-6 lg:grid-cols-2 lg:items-start">
<Card className="lg:col-span-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.pages.editor.sectionBasics")}</span>
<div className="grid w-full gap-4 sm:grid-cols-2">
<TextInput className="w-full" label={t("bookings.pages.editor.pageTitle")} showLabel>
<TextInput.Input name="title" defaultValue={page?.title ?? ""} required />
</TextInput>
<TextInput className="w-full" label={t("bookings.pages.editor.slug")} showLabel helpText={t("bookings.pages.editor.slugHelp")}>
<TextInput.Input name="slug" defaultValue={page?.slug ?? ""} required />
</TextInput>
<TextArea className="w-full sm:col-span-2" label={t("bookings.pages.editor.description")} showLabel>
<TextArea.Input name="description" defaultValue={page?.description ?? ""} />
</TextArea>
<NumberInput className="w-40" label={t("bookings.pages.editor.duration")} showLabel>
<NumberInput.Input name="durationMinutes" defaultValue={page?.durationMinutes ?? 30} min={5} step={5} />
</NumberInput>
</div>
</Card>
<Card data-ui-id="ui.booking.pages.editor.providers">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.pages.editor.providers")}</span>
{vm.providerOptions.length === 0 ? (
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("bookings.pages.editor.noProviders")}
</span>
) : (
<div className="flex w-full flex-col gap-2">
{vm.providerOptions.map((option) => (
<Checkbox
key={option.id}
label={option.label}
checked={selectedProviders.includes(option.id)}
onCheckedChange={(checked: boolean) => toggleProvider(option.id, checked)}
/>
))}
</div>
)}
<Select
className="w-full"
label={t("bookings.pages.editor.intakeForm")}
showLabel
helpText={t("bookings.pages.editor.intakeFormHelp")}
value={intakeFormId}
onValueChange={(value: string) => setIntakeFormId(value)}
>
<Select.Item value={NO_INTAKE_FORM}>{t("bookings.pages.editor.intakeFormNone")}</Select.Item>
{vm.intakeFormOptions.map((option) => (
<Select.Item key={option.id} value={option.id}>
{option.name}
</Select.Item>
))}
</Select>
</Card>
<Card>
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.pages.editor.sectionConfirmation")}</span>
<TextInput className="w-full" label={t("bookings.pages.editor.confirmationSubject")} showLabel>
<TextInput.Input name="confirmationEmailSubject" defaultValue={page?.confirmationEmailSubject ?? ""} />
</TextInput>
<TextArea className="w-full" label={t("bookings.pages.editor.confirmationBody")} showLabel>
<TextArea.Input name="confirmationEmailBody" defaultValue={page?.confirmationEmailBody ?? ""} />
</TextArea>
</Card>
</div>
<div className="border-border-default flex w-full items-center justify-between gap-4 border-t border-solid pt-4">
<div className="flex items-center gap-3">
<Switch checked={isPublished} onCheckedChange={(checked: boolean) => setIsPublished(checked)} />
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">
{t("bookings.pages.editor.publishToggle")}
</span>
</div>
<Button type="submit" icon={<FeatherSave />} data-ui-id="ui.booking.pages.editor.save">
{t("bookings.pages.editor.save")}
</Button>
</div>
</Form>
{vm.publicUrl && vm.embedCode ? (
<Card data-ui-id="ui.booking.pages.embed">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("bookings.pages.editor.sectionShare")}</span>
<div className="flex w-full flex-col gap-1">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary">{t("bookings.pages.publicUrl")}</span>
<div className="flex w-full items-center gap-2">
<span
className="border-border-default bg-surface-neutral-primary text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary min-w-0 grow truncate rounded-md border border-solid px-3 py-1.5"
data-ui-id="ui.booking.pages.embed.value"
>
{vm.publicUrl}
</span>
<CopyToClipboardButton
clipboardText={vm.publicUrl}
tooltipText={t("bookings.pages.copyUrl")}
successKey="bookings.pages.toast.publicUrlCopied"
/>
</div>
</div>
<div className="flex w-full flex-col gap-1">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary">{t("bookings.pages.embedCode")}</span>
<div className="flex w-full items-center gap-2">
<pre className="border-border-default bg-surface-neutral-primary text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-secondary min-w-0 grow overflow-x-auto rounded-md border border-solid px-3 py-1.5">
{vm.embedCode}
</pre>
<CopyToClipboardButton clipboardText={vm.embedCode} tooltipText={t("bookings.pages.copyEmbed")} successKey="bookings.pages.toast.embedCopied" />
</div>
</div>
</Card>
) : null}
</PageBody>
</PageShell>
);
}
@@ -0,0 +1,42 @@
// AK-P16b interim-UI (AD-28) — BookingPagesPage unit test. The "Neue
// Booking-Seite" CTA links to the standalone editor route; it is hidden without
// the admin permission. i18n is mocked so `t` echoes the key. Empty-rows fixture
// keeps the list free of row Links; the CTA Link needs a Router context.
import { render } from "@testing-library/react";
import "@testing-library/jest-dom/vitest";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { buildBookingPagesListVM } from "@hivegrid/view-models";
import { BookingPagesPage } from "./BookingPagesPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (s: string) => s, i18n: { language: "de" } }),
}));
function renderPage(canCreate = true) {
const vm = buildBookingPagesListVM({
rows: [],
canCreate,
newHref: "/acme/bookings/pages/new",
});
render(
<MemoryRouter>
<BookingPagesPage vm={vm} />
</MemoryRouter>,
);
}
describe("BookingPagesPage", () => {
it("links the create CTA to the standalone editor route", () => {
renderPage();
const cta = document.querySelector("[data-ui-id='ui.booking.pages.new']");
expect(cta).not.toBeNull();
expect(cta?.getAttribute("href")).toBe("/acme/bookings/pages/new");
});
it("hides the create CTA without the admin permission", () => {
renderPage(false);
expect(document.querySelector("[data-ui-id='ui.booking.pages.new']")).toBeNull();
});
});
@@ -0,0 +1,112 @@
import { Link } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherCalendarClock, FeatherPlus } from "@subframe/core";
import type { BookingPagesListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
import { useLocaleFormatters } from "~/locale/format";
import { PageHeader } from "../automation/automationUi";
/**
* AK-P16b · interim booking-pages list (AD-28, archetype A2): title/slug/
* duration/providers/publish state + copyable public URL per page. Final
* Subframe optics follow David's D-P16 delta (design-nachzug).
*/
export interface BookingPagesPageProps {
vm: BookingPagesListVM;
}
export function BookingPagesPage({ vm }: BookingPagesPageProps): React.JSX.Element {
const { t } = useTranslation();
const formatters = useLocaleFormatters();
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col" data-ui-id="ui.booking.pages.list" />;
}
const { rows, canCreate, newHref, emptyHeadlineKey, emptyBodyKey } = vm.data;
return (
<div className="flex w-full flex-col" data-ui-id="ui.booking.pages.list">
<PageHeader
icon={<FeatherCalendarClock className="text-heading-3 font-heading-3 text-icon-neutral-secondary" />}
title={t("bookings.pages.title")}
subtitle={t("bookings.pages.subtitle")}
actions={
canCreate ? (
<Link to={newHref} className="no-underline" data-ui-id="ui.booking.pages.new">
<Button icon={<FeatherPlus />}>{t("bookings.pages.new")}</Button>
</Link>
) : undefined
}
/>
<div className="mobile:p-4 flex w-full flex-col gap-4 p-6">
{rows.length === 0 ? (
<div data-ui-id="ui.booking.pages.empty">
<EmptyState outlined fillContainer title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div
className="border-border-default bg-surface-neutral-primary w-full overflow-x-auto rounded-lg border border-solid shadow-sm"
data-ui-id="ui.booking.pages.items"
>
<Table
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("bookings.pages.columns.title")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.pages.columns.slug")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.pages.columns.duration")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.pages.columns.providers")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.pages.columns.status")}</Table.HeaderCell>
<Table.HeaderCell>{t("bookings.pages.columns.publicUrl")}</Table.HeaderCell>
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id} clickable>
<Table.Cell>
<Link
to={row.editHref}
className="text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-primary hover:text-text-feedback-link-default whitespace-nowrap no-underline"
>
{row.title}
</Link>
</Table.Cell>
<Table.Cell>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">/{row.slug}</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
{t("bookings.pages.durationMinutes", { count: row.durationMinutes, value: formatters.number(row.durationMinutes) })}
</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
{formatters.number(row.providerCount)}
</span>
</Table.Cell>
<Table.Cell>
<BadgeFeedback farbe={row.isPublished ? "subtle-positive" : "subtle-neutral"} size="small">
{row.isPublished ? t("bookings.pages.published") : t("bookings.pages.unpublished")}
</BadgeFeedback>
</Table.Cell>
<Table.Cell>
<CopyToClipboardButton
clipboardText={row.publicUrl}
tooltipText={t("bookings.pages.copyUrl")}
successKey="bookings.pages.toast.publicUrlCopied"
/>
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
</div>
);
}