@aglyn/plugins-bookings 1.0.0-beta.244 → 1.0.0-beta.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-bookings",
3
- "version": "1.0.0-beta.244",
3
+ "version": "1.0.0-beta.247",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,16 +25,16 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.244",
29
- "@aglyn/shared-data-mdi": "1.0.0-beta.244",
30
- "@aglyn/shared-ui-jsx": "1.0.0-beta.244",
31
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.244",
32
- "@aglyn/shared-util-email": "1.0.0-beta.244",
33
- "@aglyn/shared-util-http": "1.0.0-beta.244",
34
- "@aglyn/shared-util-timestamp": "1.0.0-beta.244",
35
- "@aglyn/tenant-data-admin": "1.0.0-beta.244",
36
- "@aglyn/tenant-feature-instance": "1.0.0-beta.244",
37
- "@aglyn/tenant-runtime": "1.0.0-beta.244",
28
+ "@aglyn/aglyn": "1.0.0-beta.247",
29
+ "@aglyn/shared-data-mdi": "1.0.0-beta.247",
30
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.247",
31
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.247",
32
+ "@aglyn/shared-util-email": "1.0.0-beta.247",
33
+ "@aglyn/shared-util-http": "1.0.0-beta.247",
34
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.247",
35
+ "@aglyn/tenant-data-admin": "1.0.0-beta.247",
36
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.247",
37
+ "@aglyn/tenant-runtime": "1.0.0-beta.247",
38
38
  "@swc/helpers": "0.5.23"
39
39
  },
40
40
  "peerDependencies": {
@@ -24,7 +24,8 @@ import { BOOKINGS_TRANSFER_RESOURCE, bookerBookingsFilterValue, upcomingBookings
24
24
  import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn/app-utils/platform-brand";
25
25
  import { describePaymentRisk } from "@aglyn/aglyn/app-utils/payment-risk";
26
26
  import { isBookingReminderDue } from "../model/index.js";
27
- import { BOOKING_WEEKDAYS, bookingServiceDraftFrom, bookingServiceFields, newBookingServiceDraft } from "../model/booking-service-form.js";
27
+ import { bookingServiceDraftFrom, bookingServiceFields, formatBookingWindows, newBookingServiceDraft, parseBookingWindows } from "../model/booking-service-form.js";
28
+ import { WeeklyHoursPicker } from "@aglyn/shared-ui-jsx/components/weekly-hours-picker.component";
28
29
  import { bookingServiceStatus } from "../model/bookings.js";
29
30
  import { BOOKING_FIELD_ASKS } from "../model/booking-contact-fields.js";
30
31
  import { BOOKING_PRICE_DISPLAYS, BOOKING_PRICE_LABELS, bookingPriceDisplay, bookingPriceText } from "../model/booking-price.js";
@@ -38,7 +39,6 @@ import { useParams, useSearchParams } from "next/navigation";
38
39
  import { useCallback, useState } from "react";
39
40
  import { useFirestore, useFirestoreCollection, useHostResourceApi, useUser, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
40
41
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
41
- const WEEKDAYS = BOOKING_WEEKDAYS;
42
42
  /** How each way of stating the price reads in the service dialog's picker. */ const PRICE_DISPLAY_LABELS = _extends({
43
43
  fixed: 'The price'
44
44
  }, BOOKING_PRICE_LABELS);
@@ -65,7 +65,7 @@ const WEEKDAYS = BOOKING_WEEKDAYS;
65
65
  * the org /api/bookings endpoints; confirmations email through the
66
66
  * env-gated Resend path. Plan-gated (`bookings` flag + `servicesPerHost`).
67
67
  */ export function BookingsConsolePage(props) {
68
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
68
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
69
69
  const { hostId, entitled, org } = props;
70
70
  const firestore = useFirestore();
71
71
  const createHostResource = useHostResourceApi();
@@ -776,22 +776,14 @@ const WEEKDAYS = BOOKING_WEEKDAYS;
776
776
  multiline: true,
777
777
  minRows: 2
778
778
  }),
779
- /*#__PURE__*/ _jsx(Typography, {
780
- variant: "overline",
781
- color: "text.secondary",
782
- children: 'Weekly availability'
783
- }),
784
- WEEKDAYS.map((day, index)=>{
785
- var _ref;
786
- return /*#__PURE__*/ _jsx(TextField, {
787
- label: day,
788
- placeholder: "09:00-12:00, 13:00-17:00 (empty = closed)",
789
- value: (_ref = draft == null ? void 0 : draft.windowText[index]) != null ? _ref : '',
790
- onChange: (event)=>setDraft((prev)=>prev ? _extends({}, prev, {
791
- windowText: prev.windowText.map((text, i)=>i === index ? event.target.value : text)
792
- }) : prev),
793
- size: "small"
794
- }, day);
779
+ /*#__PURE__*/ _jsx(WeeklyHoursPicker, {
780
+ label: "Weekly availability",
781
+ value: ((_ref6 = draft == null ? void 0 : draft.windowText) != null ? _ref6 : []).map((text)=>parseBookingWindows(text)),
782
+ onChange: (hours)=>setDraft((prev)=>prev ? _extends({}, prev, {
783
+ windowText: hours.map((day)=>formatBookingWindows(day))
784
+ }) : prev),
785
+ sameDay: true,
786
+ helperText: "Switch on each day the service is offered, then pick the hours slots are offered in."
795
787
  }),
796
788
  /*#__PURE__*/ _jsx(Typography, {
797
789
  variant: "overline",
@@ -838,7 +830,7 @@ const WEEKDAYS = BOOKING_WEEKDAYS;
838
830
  }),
839
831
  /*#__PURE__*/ _jsx(FormControlLabel, {
840
832
  control: /*#__PURE__*/ _jsx(Switch, {
841
- checked: (_ref6 = draft == null ? void 0 : draft.crmMeetingActivity) != null ? _ref6 : true,
833
+ checked: (_ref7 = draft == null ? void 0 : draft.crmMeetingActivity) != null ? _ref7 : true,
842
834
  onChange: (event)=>setDraft((prev)=>prev ? _extends({}, prev, {
843
835
  crmMeetingActivity: event.target.checked
844
836
  }) : prev),
@@ -848,7 +840,7 @@ const WEEKDAYS = BOOKING_WEEKDAYS;
848
840
  }),
849
841
  /*#__PURE__*/ _jsx(FormControlLabel, {
850
842
  control: /*#__PURE__*/ _jsx(Switch, {
851
- checked: (_ref7 = draft == null ? void 0 : draft.crmFollowUpTask) != null ? _ref7 : false,
843
+ checked: (_ref8 = draft == null ? void 0 : draft.crmFollowUpTask) != null ? _ref8 : false,
852
844
  onChange: (event)=>setDraft((prev)=>prev ? _extends({}, prev, {
853
845
  crmFollowUpTask: event.target.checked
854
846
  }) : prev),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/components/bookings-console-page.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { checkQuota, pluginDocsHelp, useTransferLauncher } from '@aglyn/aglyn'\nimport { normalizeContactEmail } from '@aglyn/aglyn'\nimport { pluginRecordByEmailHref } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { BOOKINGS_BOOKER_PARAM } from '../model/bookings-record-routes'\nimport {\n BOOKINGS_TRANSFER_RESOURCE,\n bookerBookingsFilterValue,\n upcomingBookingsFilterValue,\n} from '../transfer/bookings-transfer-common'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { describePaymentRisk, type PaymentRisk } from '@aglyn/aglyn/app-utils/payment-risk'\nimport { type ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { isBookingReminderDue } from '../model'\nimport {\n BOOKING_WEEKDAYS,\n type BookingServiceDraft,\n bookingServiceDraftFrom,\n bookingServiceFields,\n newBookingServiceDraft,\n} from '../model/booking-service-form'\nimport { type BookingServiceStatus, bookingServiceStatus } from '../model/bookings'\nimport {\n BOOKING_FIELD_ASKS,\n type BookingFieldAsk,\n} from '../model/booking-contact-fields'\nimport {\n BOOKING_PRICE_DISPLAYS,\n BOOKING_PRICE_LABELS,\n type BookingPriceDisplay,\n bookingPriceDisplay,\n bookingPriceText,\n} from '../model/booking-price'\nimport { AppLink, CardDisplay, HelpTip, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport QuotaReadoutComponent from '@aglyn/shared-ui-jsx/components/quota-readout.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n limit,\n orderBy,\n query,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useParams, useSearchParams } from 'next/navigation'\nimport { useCallback, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n useHostResourceApi,\n useUser,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\nconst WEEKDAYS = BOOKING_WEEKDAYS\n\n/** The dialog's fields, and the service it edits (`null` for a new one). */\ninterface ServiceDraft extends BookingServiceDraft {\n id: string | null\n}\n\n/** How each way of stating the price reads in the service dialog's picker. */\nconst PRICE_DISPLAY_LABELS: Record<BookingPriceDisplay, string> = {\n fixed: 'The price',\n ...BOOKING_PRICE_LABELS,\n}\n\n/** How each answer reads in the service dialog's two pickers. */\nconst FIELD_ASK_LABELS: Record<BookingFieldAsk, string> = {\n off: \"Don't ask\",\n optional: 'Optional',\n required: 'Required',\n}\n\n/** A fraud warning, review or chargeback on the booking's payment (AGL-3360). */\nfunction PaymentRiskChip({ risk }: { risk: PaymentRisk | undefined }) {\n const described = describePaymentRisk(risk)\n if (!described) return null\n return (\n <Tooltip title={described.detail}>\n <Chip label={described.label} size=\"small\" color=\"warning\" />\n </Tooltip>\n )\n}\n\n/**\n * Bookings manager (AGL-159): bookable services with weekly availability\n * windows, and the upcoming-bookings list with cancel. Visitors book via\n * the org /api/bookings endpoints; confirmations email through the\n * env-gated Resend path. Plan-gated (`bookings` flag + `servicesPerHost`).\n */\nexport function BookingsConsolePage(props: ConsolePluginPageProps) {\n const { hostId, entitled, org } = props\n const firestore = useFirestore()\n const createHostResource = useHostResourceApi()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n // The id token the refund route authenticates with (AGL-2315).\n const { data: user } = useUser()\n /*\n * Where a booker's CONTACT is (AGL-2622). A booking updated a person in\n * the CRM by the address it carried, and the row links there by that\n * address — the Contacts list holds the id nothing here does and opens\n * the record on one match. The address is the one the plugin that keeps\n * contacts publishes, asked of the record-route registry the way the\n * commerce dialog asks: a plugin importing a sibling is a cycle waiting\n * for its third edge. `null` until the route params settle, and where no\n * plugin keeps contacts, so no row renders a link to nowhere.\n */\n const params = useParams<{ orgSlug?: string; host?: string }>()\n const siteContext =\n params?.orgSlug && params?.host\n ? { orgSlug: String(params.orgSlug), host: String(params.host) }\n : null\n const contactHrefOf = (email: unknown): string | null =>\n siteContext && email ? pluginRecordByEmailHref('contact', siteContext, String(email)) : null\n /*\n * The list narrowed to one booker (AGL-2660): a contact's record links\n * here with `?email=`, and the page answers with every booking that\n * address holds — past ones too, because that link asks about a\n * person's history rather than the week ahead. The same match rule as\n * the row's own \"View in CRM\": the address, normalized, equal. `null`\n * outside a router, where there is no query to read.\n */\n const searchParams = useSearchParams()\n const bookerFilter = normalizeContactEmail(searchParams?.get(BOOKINGS_BOOKER_PARAM))\n const { basePath } = props\n /*\n * Export, opened on the list as it stands: one booker's bookings when the\n * page is narrowed to them, otherwise the upcoming ones from this moment.\n * `null` outside the console shell, where there is nothing to export into.\n * No Import: a booking is only ever made on the booking page.\n */\n const transferLauncher = useTransferLauncher()\n const handleExport = useCallback(() => {\n transferLauncher?.openExport({\n resource: BOOKINGS_TRANSFER_RESOURCE,\n scope: 'host',\n hostId,\n filter: bookerFilter\n ? { label: `Bookings for ${bookerFilter}`, value: bookerBookingsFilterValue(bookerFilter) }\n : { label: 'Upcoming bookings', value: upcomingBookingsFilterValue(Date.now()) },\n })\n }, [transferLauncher, hostId, bookerFilter])\n\n const {\n data: serviceDocs,\n status: servicesStatus,\n /**\n * The rows this editor is seeded from are unconfirmed by the server\n * (AGL-1358). Editing copies a whole stored service into `draft` and\n * writes all of it back, so `merge: true` protects nothing. `windows` is\n * the weekly availability map, rebuilt in full on every save: a cached\n * seed re-opens slots that were closed and closes ones customers can\n * already book, and `priceUsd` goes back to whatever that snapshot\n * charged.\n */\n fromCache: servicesFromCache,\n } = useFirestoreCollection<any>(\n () =>\n query(collection(firestore, 'hosts', hostId, 'services'), limit(100)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { data: bookingDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'bookings'),\n orderBy('startsAtMs', 'desc'),\n limit(100),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const services = [...(serviceDocs ?? [])]\n .filter((service: any) => !service.deletedAt)\n .sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n const upcoming = [...(bookingDocs ?? [])]\n .filter((booking: any) => booking.endsAtMs >= Date.now())\n .sort((a: any, b: any) => a.startsAtMs - b.startsAtMs)\n // Newest first when narrowed to a booker — the listener already orders\n // by start, descending — so the history reads down from the latest.\n const shown = bookerFilter\n ? (bookingDocs ?? []).filter(\n (booking: any) => normalizeContactEmail(booking.email) === bookerFilter,\n )\n : upcoming\n\n /**\n * The 24-hour reminder queue (AGL-2431).\n *\n * Reminders are sent by the `booking-reminders` beat, not by anything on\n * this page, and until that beat existed they were never sent at all — the\n * feature had a designed email template, white-label branding and an\n * `x-cron-secret` door, and no scheduler pointed at it. So the merchant had\n * no way to tell working from broken, and still would not if this card\n * merely asserted that reminders happen.\n *\n * READ-ONLY, and deliberately no \"send now\" button: the beat runs hourly\n * and stamps `reminderSentAt`, so a manual sender would race it for a\n * reminder nobody can un-send. Same call AGL-2227 made for the recovery\n * queue.\n *\n * `isBookingReminderDue` is the sender's own predicate, against one instant\n * shared by both counts, so this is the queue the next pass will drain\n * rather than an approximation of it.\n */\n const reminderNowMs = Date.now()\n const reminderQueue = (bookingDocs ?? []).filter((booking: any) =>\n isBookingReminderDue(booking, reminderNowMs),\n ).length\n const remindersSent = (bookingDocs ?? []).filter(\n (booking: any) => booking.reminderSentAt,\n ).length\n\n const [draft, setDraft] = useState<ServiceDraft | null>(null)\n\n const handleAdd = useCallback(() => {\n if (!entitled) {\n return void enqueueSnackbar(\n 'Bookings require a Starter plan — see Billing to upgrade',\n { variant: 'warning', persist: false },\n )\n }\n const quota = checkQuota(org, 'servicesPerHost', services.length)\n if (!quota.allowed) {\n return void enqueueSnackbar(\n `Service limit reached (${quota.limit}) — upgrade in Billing`,\n { variant: 'warning', persist: false },\n )\n }\n setDraft({\n id: null,\n ...newBookingServiceDraft(\n Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',\n ),\n })\n }, [entitled, org, services.length, enqueueSnackbar])\n\n const handleSave = useCallback(async () => {\n if (!draft || !draft.name.trim()) return\n // The one rule for what a save stores, which the native editors share.\n const fields = bookingServiceFields(draft)\n try {\n if (draft.id) {\n /**\n * Edit stays client-direct (no quota consumed) — and is refused when\n * its seed was never confirmed by the server (AGL-1358). `fields` is\n * every editable key of the stored service, `windows` included, so\n * `merge: true` has nothing left to protect.\n *\n * The guard WRAPS the write. An early return is a shape you can keep\n * while losing the protection; here the write is only reachable\n * through the verdict.\n */\n const verdict = await writeGuardedBySeed(\n {\n subject: 'service',\n unreadable: servicesStatus === 'error',\n fromCache: servicesFromCache,\n },\n async () => {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'services', draft.id),\n { ...fields, updatedAt: Timestamp.now() },\n { merge: true },\n )\n },\n )\n // Before `setDraft(null)`, so a refusal keeps the dialog open with\n // every window that was typed. A save that silently does nothing\n // sends the user back to retype a form that will be refused again\n // just as quietly.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n } else {\n // New service rides the quota-enforcing resources API (AGL-473) —\n // it also re-checks the `bookings` entitlement server-side.\n await createHostResource({ hostId, resource: 'service', data: fields })\n }\n setDraft(null)\n enqueueSnackbar('Service saved', { variant: 'success', persist: false })\n } catch (error: any) {\n console.error(error)\n enqueueSnackbar(error?.message ?? 'An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n }, [\n draft,\n firestore,\n hostId,\n createHostResource,\n enqueueSnackbar,\n servicesStatus,\n servicesFromCache,\n ])\n\n /**\n * A draft is activated here, and only here (AGL-3616): a service a draft\n * writer made is set up and offered nowhere until a person looks at it and\n * says it takes bookings. Deactivating sends a live one back to draft,\n * which takes it off the site without deleting it; bookings it already\n * holds stand. One field, so the seed guard the dialog's whole-document\n * save needs has nothing to protect here.\n */\n const handleServiceStatus = useCallback(\n (service: any, status: BookingServiceStatus) => async () => {\n try {\n await updateDoc(doc(firestore, 'hosts', hostId, 'services', service.$id), {\n status,\n updatedAt: Timestamp.now(),\n })\n enqueueSnackbar(\n status === 'active'\n ? `${service.name} now takes bookings`\n : `${service.name} is a draft — it takes no bookings until activated`,\n { variant: 'success', persist: false },\n )\n } catch (error: any) {\n console.error(error)\n enqueueSnackbar(error?.message ?? 'An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n },\n [firestore, hostId, enqueueSnackbar],\n )\n\n const handleDeleteService = useCallback(\n (service: any) => async () => {\n const confirmed = await confirm({\n title: 'Delete this service?',\n description: `\"${service.name}\" stops accepting bookings.`,\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await updateDoc(doc(firestore, 'hosts', hostId, 'services', service.$id), {\n deletedAt: Timestamp.now(),\n })\n },\n [confirm, firestore, hostId],\n )\n\n /**\n * Cancelling a PAID booking refunds the guest (AGL-2315).\n *\n * This used to be one `updateDoc` writing `status: 'canceled'`, for a paid\n * booking exactly as for a free one. The slot reopened, the appointment was\n * gone, and the guest had paid for it — the money moved nowhere and nothing\n * in the console said so. That was survivable only while the charge settled\n * in Aglyn's own balance and could be given back by hand; a paid booking is\n * a destination charge now, so the funds are at the MERCHANT and there is no\n * later opportunity to notice.\n *\n * So a paid booking cancels through the refund route, which reverses the\n * merchant's share and Aglyn's fee, and which sets `canceled` itself once\n * the money is actually back. A FAILED refund deliberately leaves the\n * booking standing: a cancelled-and-unrefunded appointment is the worst of\n * the three outcomes, and an admin who sees the row still there knows the\n * cancel did not happen.\n */\n const handleCancelBooking = useCallback(\n (booking: any) => async () => {\n const paidCents = Math.max(0, Number(booking.paidAmountCents ?? 0))\n const refundedCents = Math.max(0, Number(booking.refundedCents ?? 0))\n const outstandingCents = Math.max(0, paidCents - refundedCents)\n const refundable = outstandingCents > 0\n const confirmed = await confirm({\n title: 'Cancel this booking?',\n description:\n `${booking.name} (${booking.email}) — the slot reopens.` +\n (refundable\n ? ` $${(outstandingCents / 100).toFixed(2)} is refunded to them` +\n ' through Stripe.'\n : ''),\n confirmationText: refundable ? 'Cancel and refund' : 'Cancel booking',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n\n if (refundable) {\n // `randomUUID` needs a secure context, which the console always is,\n // but fall back rather than throw on a refund.\n const attemptKey =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n try {\n const response = await authorizedFetch(user, '/api/bookings/refund', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Idempotency-Key': attemptKey,\n },\n body: JSON.stringify({ hostId, bookingId: booking.$id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n // A 409 is a guard REFUSING with a body that says what to do\n // instead — a booking paid before the PaymentIntent was recorded\n // names the Stripe dashboard — not the refund machinery failing.\n // It surfaces verbatim, the AGL-1818 rule.\n enqueueSnackbar(payload?.error ?? 'Refund failed', {\n variant: response.status === 409 ? 'warning' : 'error',\n allowDuplicate: true,\n })\n // The booking stays. See the note above: cancelled-and-unrefunded\n // is worse than not cancelled.\n return\n }\n // The route wrote `canceled` itself once the money was back.\n enqueueSnackbar('Booking canceled and refunded', {\n variant: 'success',\n persist: false,\n })\n return\n } catch {\n enqueueSnackbar('Refund failed — the booking was not canceled', {\n variant: 'error',\n allowDuplicate: true,\n })\n return\n }\n }\n\n // Through the cancel route (AGL-3643), not a direct write: the route\n // holds the rule that a paid booking cancels through its refund, and\n // tells the plugins listening for `booking.canceled`.\n try {\n const response = await authorizedFetch(user, '/api/bookings/cancel', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, bookingId: booking.$id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n enqueueSnackbar(payload?.error ?? 'The booking was not canceled', {\n variant: response.status === 409 ? 'warning' : 'error',\n allowDuplicate: true,\n })\n return\n }\n } catch {\n enqueueSnackbar('The booking was not canceled', {\n variant: 'error',\n allowDuplicate: true,\n })\n return\n }\n enqueueSnackbar('Booking canceled', {\n variant: 'success',\n persist: false,\n })\n },\n [confirm, hostId, enqueueSnackbar, user],\n )\n\n return (\n <Stack spacing={3}>\n <CardDisplay\n header={'Services'}\n help={pluginDocsHelp('bookings', { anchor: '#set-up-bookings' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {services.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Define a bookable service — duration, price, and weekly ' +\n 'availability — then visitors can book from your site.'}\n </Typography>\n ) : (\n services.map((service: any) => (\n <Stack\n key={service.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {service.name}\n </Typography>\n {bookingServiceStatus(service.status) === 'draft' ? (\n <Tooltip title=\"Set up, and offered nowhere until you activate it\">\n <Chip label=\"Draft\" size=\"small\" />\n </Tooltip>\n ) : null}\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`${service.durationMinutes} min · ${bookingPriceText(service).replace(/^Free$/, 'free')}` +\n ` · ${service.timezone ?? 'UTC'}`}\n </Typography>\n </Stack>\n <Button\n size=\"small\"\n onClick={() =>\n setDraft({\n id: service.$id,\n ...bookingServiceDraftFrom(service),\n })\n }\n >\n {'Edit'}\n </Button>\n {bookingServiceStatus(service.status) === 'draft' ? (\n <Button\n size=\"small\"\n color=\"primary\"\n onClick={handleServiceStatus(service, 'active')}\n >\n {'Activate'}\n </Button>\n ) : (\n <Button size=\"small\" onClick={handleServiceStatus(service, 'draft')}>\n {'Deactivate'}\n </Button>\n )}\n <Button\n size=\"small\"\n color=\"error\"\n onClick={handleDeleteService(service)}\n >\n {'Delete'}\n </Button>\n </Stack>\n ))\n )}\n <Button\n size=\"small\"\n color=\"primary\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={handleAdd}\n >\n {'Add service'}\n </Button>\n {/* The cap, standing rather than only on refusal (AGL-2113).\n `services.length` is the same count `handleAdd` hands to\n `checkQuota`, so the readout and the gate cannot disagree. */}\n <QuotaReadoutComponent\n ready={org != null}\n used={services.length}\n limit={checkQuota(org, 'servicesPerHost', services.length).limit}\n noun=\"service\"\n />\n </Stack>\n </CardDisplay>\n\n <CardDisplay\n header={bookerFilter ? `Bookings for ${bookerFilter}` : 'Upcoming bookings'}\n help={pluginDocsHelp('bookings', { anchor: '#manage' })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: transferLauncher?.can('export', { resource: BOOKINGS_TRANSFER_RESOURCE, scope: 'host', hostId }) ? (\n <Button size=\"small\" color=\"primary\" onClick={handleExport}>\n {'Export'}\n </Button>\n ) : undefined,\n }}\n >\n {bookerFilter ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mb: 1 }}\n >\n {'Every booking this address holds, newest first. '}\n {basePath ? <AppLink href={basePath}>{'Show upcoming bookings'}</AppLink> : null}\n </Typography>\n ) : null}\n {/* What the reminder beat will do next, and what it has done. Named\n \"24-hour reminders\" rather than \"emails\" because that is the only\n mail this queue governs — confirmations go out on booking. */}\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mb: 1 }}\n >\n {`24-hour reminders · ${reminderQueue} due in the next pass · ` +\n `${remindersSent} already sent`}\n {/* Its OWN heading, not the card's `#manage`: a merchant reading\n this line wants the timing and the once-only rule, and landing\n them on \"manage your bookings\" is the presence-not-correctness\n failure a help-coverage check cannot see. */}\n <HelpTip\n {...pluginDocsHelp('bookings', { anchor: '#reminders' })}\n sx={{ ml: 0.5, fontSize: '0.9em' }}\n />\n </Typography>\n {shown.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {bookerFilter ? 'No bookings for this address.' : 'No upcoming bookings.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n {shown.map((booking: any) => (\n <Stack\n key={booking.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${booking.serviceName} — ${booking.name}`}\n {booking.status === 'canceled' ? ' (canceled)' : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`${new Date(booking.startsAtMs).toLocaleString()} · ${\n booking.email\n }`}\n {typeof booking.phone === 'string' && booking.phone\n ? ` · ${booking.phone}`\n : ''}\n </Typography>\n {/* Where the job is, when the service asked (AGL-3493).\n Wrapped rather than cut: an address read to its end is\n the one a crew can drive to. */}\n {typeof booking.address === 'string' && booking.address ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ whiteSpace: 'pre-line' }}\n >\n {booking.address}\n </Typography>\n ) : null}\n </Stack>\n <PaymentRiskChip risk={booking.paymentRisk} />\n {contactHrefOf(booking.email) ? (\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={contactHrefOf(booking.email) ?? undefined}\n size=\"small\"\n >\n {'View in CRM'}\n </Button>\n ) : null}\n {booking.status !== 'canceled' ? (\n <Button\n size=\"small\"\n color=\"error\"\n onClick={handleCancelBooking(booking)}\n >\n {'Cancel'}\n </Button>\n ) : null}\n </Stack>\n ))}\n </Stack>\n )}\n </CardDisplay>\n\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{draft?.id ? 'Edit service' : 'Add service'}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n <TextField\n label=\"Name\"\n value={draft?.name ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, name: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"Duration (minutes)\"\n value={draft?.durationMinutes ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? {\n ...prev,\n durationMinutes: event.target.value.replace(\n /[^0-9]/g,\n '',\n ),\n }\n : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Price (USD, 0 = free)\"\n // WHAT THIS PRICE DOES NOT INCLUDE (AGL-2028).\n //\n // A paid booking is charged exactly this figure: the handler\n // sends no tax parameter at all, by a stated decision (AGL-2000)\n // — whether a service is taxable is jurisdiction-specific and\n // frequently the opposite answer from goods, so applying the\n // commerce plugin's GOODS sales rate would be confidently wrong\n // rather than merely absent.\n //\n // That decision was recorded in the source and in the\n // `storefrontTaxCollected` ledger, and in neither place can the\n // merchant see it. A service business is one of the three named\n // ICPs, and one who configured a rate in Commerce → Settings →\n // Taxes has every reason to assume it covers the appointments\n // they sell on the same site. Saying so here is the half of\n // AGL-2028 that holds however the rate question is answered.\n //\n // States the MECHANISM and makes no remittance determination —\n // the same line `describeOrderTaxMode` holds. Who owes which\n // authority what attaches by operation of law and is counsel's\n // call (AGL-1904/AGL-1956).\n helperText={\n draft && draft.priceDisplay !== 'fixed'\n ? `Not charged: this service shows “${BOOKING_PRICE_LABELS[draft.priceDisplay]}” and books with no charge.`\n : `${PLATFORM_BRAND_NAME} charges this price as typed — no tax is added. Your Commerce tax settings are a goods sales rate and do not apply to bookings.`\n }\n value={draft?.priceUsd ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? {\n ...prev,\n priceUsd: event.target.value.replace(/[^0-9]/g, ''),\n }\n : prev,\n )\n }\n size=\"small\"\n />\n {/*\n A contractor who quotes at the job states the price as a label\n instead (AGL-3475). Any label books with no charge, like an\n estimate appointment, and the stored price is neither shown nor\n charged.\n */}\n <TextField\n select\n label=\"Show the price as\"\n value={draft?.priceDisplay ?? 'fixed'}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, priceDisplay: bookingPriceDisplay(event.target.value) }\n : prev,\n )\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n >\n {BOOKING_PRICE_DISPLAYS.map((display) => (\n <MenuItem key={display} value={display}>\n {PRICE_DISPLAY_LABELS[display]}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n label=\"Timezone\"\n value={draft?.timezone ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, timezone: event.target.value } : prev,\n )\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n />\n </Stack>\n <TextField\n label=\"Description (optional)\"\n value={draft?.description ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, description: event.target.value } : prev,\n )\n }\n size=\"small\"\n multiline\n minRows={2}\n />\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Weekly availability'}\n </Typography>\n {WEEKDAYS.map((day, index) => (\n <TextField\n key={day}\n label={day}\n placeholder=\"09:00-12:00, 13:00-17:00 (empty = closed)\"\n value={draft?.windowText[index] ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? {\n ...prev,\n windowText: prev.windowText.map((text, i) =>\n i === index ? event.target.value : text,\n ),\n }\n : prev,\n )\n }\n size=\"small\"\n />\n ))}\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Booking form'}\n </Typography>\n {/*\n What the widget asks for beyond a name and an email (AGL-3493).\n Off by default; an on-site service asks for both, required.\n */}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n {(\n [\n ['askPhone', 'Phone number'],\n ['askAddress', 'Address'],\n ] as const\n ).map(([key, label]) => (\n <TextField\n key={key}\n select\n label={label}\n value={draft?.[key] ?? 'off'}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, [key]: event.target.value as BookingFieldAsk }\n : prev,\n )\n }\n size=\"small\"\n fullWidth\n >\n {BOOKING_FIELD_ASKS.map((ask) => (\n <MenuItem key={ask} value={ask}>\n {FIELD_ASK_LABELS[ask]}\n </MenuItem>\n ))}\n </TextField>\n ))}\n </Stack>\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'CRM'}\n </Typography>\n {/*\n What a booking of this service does to the booker's CRM record\n (AGL-2660). The meeting is on by default — a booking IS a\n meeting the record has — and the follow-up is the service's\n choice, because not every service earns a call afterwards.\n */}\n <FormControlLabel\n control={\n <Switch\n checked={draft?.crmMeetingActivity ?? true}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, crmMeetingActivity: event.target.checked }\n : prev,\n )\n }\n size=\"small\"\n />\n }\n label=\"Log a meeting on the CRM record when this service is booked\"\n />\n <FormControlLabel\n control={\n <Switch\n checked={draft?.crmFollowUpTask ?? false}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, crmFollowUpTask: event.target.checked }\n : prev,\n )\n }\n size=\"small\"\n />\n }\n label=\"Create a follow-up task on the CRM record when this service is booked\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'The follow-up is due one business day after the slot, on whoever ' +\n 'owns the record. Nothing is filed on a site whose CRM is off.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.name.trim()}\n onClick={handleSave}\n >\n {'Save service'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nBookingsConsolePage.displayName = 'BookingsConsolePage'\n\nexport default BookingsConsolePage\n"],"names":["checkQuota","pluginDocsHelp","useTransferLauncher","normalizeContactEmail","pluginRecordByEmailHref","BOOKINGS_BOOKER_PARAM","BOOKINGS_TRANSFER_RESOURCE","bookerBookingsFilterValue","upcomingBookingsFilterValue","PLATFORM_BRAND_NAME","describePaymentRisk","isBookingReminderDue","BOOKING_WEEKDAYS","bookingServiceDraftFrom","bookingServiceFields","newBookingServiceDraft","bookingServiceStatus","BOOKING_FIELD_ASKS","BOOKING_PRICE_DISPLAYS","BOOKING_PRICE_LABELS","bookingPriceDisplay","bookingPriceText","AppLink","CardDisplay","HelpTip","useConfirmationContext","QuotaReadoutComponent","useSnackbar","Timestamp","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","Switch","TextField","Tooltip","Typography","collection","doc","limit","orderBy","query","setDoc","updateDoc","useParams","useSearchParams","useCallback","useState","useFirestore","useFirestoreCollection","useHostResourceApi","useUser","writeGuardedBySeed","authorizedFetch","WEEKDAYS","PRICE_DISPLAY_LABELS","fixed","FIELD_ASK_LABELS","off","optional","required","PaymentRiskChip","risk","described","title","detail","label","size","color","BookingsConsolePage","props","hostId","entitled","org","firestore","createHostResource","enqueueSnackbar","confirm","data","user","params","siteContext","orgSlug","host","String","contactHrefOf","email","searchParams","bookerFilter","get","basePath","transferLauncher","handleExport","openExport","resource","scope","filter","value","Date","now","serviceDocs","status","servicesStatus","fromCache","servicesFromCache","idField","bookingDocs","services","service","deletedAt","sort","a","b","name","localeCompare","upcoming","booking","endsAtMs","startsAtMs","shown","reminderNowMs","reminderQueue","length","remindersSent","reminderSentAt","draft","setDraft","handleAdd","variant","persist","quota","allowed","id","Intl","DateTimeFormat","resolvedOptions","timeZone","handleSave","trim","fields","verdict","subject","unreadable","updatedAt","merge","ok","message","error","console","allowDuplicate","handleServiceStatus","$id","handleDeleteService","confirmed","description","confirmationText","confirmationButtonProps","then","catch","handleCancelBooking","paidCents","Math","max","Number","paidAmountCents","refundedCents","outstandingCents","refundable","toFixed","globalThis","attemptKey","crypto","randomUUID","random","toString","slice","response","method","headers","body","JSON","stringify","bookingId","payload","json","spacing","header","help","anchor","contentGutterX","contentGutterY","map","direction","sx","alignItems","flex","minWidth","noWrap","durationMinutes","replace","timezone","onClick","alignSelf","ready","used","noun","HeaderProps","action","can","undefined","component","mb","href","ml","fontSize","serviceName","toLocaleString","phone","address","whiteSpace","paymentRisk","componentVariant","nativeButton","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","pt","onChange","event","prev","target","autoFocus","mt","helperText","priceDisplay","priceUsd","select","multiline","minRows","day","index","placeholder","windowText","text","i","xs","sm","key","ask","control","checked","crmMeetingActivity","crmFollowUpTask","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,UAAU,EAAEC,cAAc,EAAEC,mBAAmB,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,qBAAqB,QAAQ,qCAAiC;AACvE,SACEC,0BAA0B,EAC1BC,yBAAyB,EACzBC,2BAA2B,QACtB,0CAAsC;AAC7C,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,mBAAmB,QAA0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B+D,SAAShE;0CAER;;;;;;;;AAMb;AACApE,oBAAoB8L,WAAW,GAAG;AAElC,eAAe9L,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/components/bookings-console-page.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { checkQuota, pluginDocsHelp, useTransferLauncher } from '@aglyn/aglyn'\nimport { normalizeContactEmail } from '@aglyn/aglyn'\nimport { pluginRecordByEmailHref } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { BOOKINGS_BOOKER_PARAM } from '../model/bookings-record-routes'\nimport {\n BOOKINGS_TRANSFER_RESOURCE,\n bookerBookingsFilterValue,\n upcomingBookingsFilterValue,\n} from '../transfer/bookings-transfer-common'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { describePaymentRisk, type PaymentRisk } from '@aglyn/aglyn/app-utils/payment-risk'\nimport { type ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { isBookingReminderDue } from '../model'\nimport {\n type BookingServiceDraft,\n bookingServiceDraftFrom,\n bookingServiceFields,\n formatBookingWindows,\n newBookingServiceDraft,\n parseBookingWindows,\n} from '../model/booking-service-form'\nimport { WeeklyHoursPicker } from '@aglyn/shared-ui-jsx/components/weekly-hours-picker.component'\nimport { type BookingServiceStatus, bookingServiceStatus } from '../model/bookings'\nimport {\n BOOKING_FIELD_ASKS,\n type BookingFieldAsk,\n} from '../model/booking-contact-fields'\nimport {\n BOOKING_PRICE_DISPLAYS,\n BOOKING_PRICE_LABELS,\n type BookingPriceDisplay,\n bookingPriceDisplay,\n bookingPriceText,\n} from '../model/booking-price'\nimport { AppLink, CardDisplay, HelpTip, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport QuotaReadoutComponent from '@aglyn/shared-ui-jsx/components/quota-readout.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n limit,\n orderBy,\n query,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useParams, useSearchParams } from 'next/navigation'\nimport { useCallback, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n useHostResourceApi,\n useUser,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\n/** The dialog's fields, and the service it edits (`null` for a new one). */\ninterface ServiceDraft extends BookingServiceDraft {\n id: string | null\n}\n\n/** How each way of stating the price reads in the service dialog's picker. */\nconst PRICE_DISPLAY_LABELS: Record<BookingPriceDisplay, string> = {\n fixed: 'The price',\n ...BOOKING_PRICE_LABELS,\n}\n\n/** How each answer reads in the service dialog's two pickers. */\nconst FIELD_ASK_LABELS: Record<BookingFieldAsk, string> = {\n off: \"Don't ask\",\n optional: 'Optional',\n required: 'Required',\n}\n\n/** A fraud warning, review or chargeback on the booking's payment (AGL-3360). */\nfunction PaymentRiskChip({ risk }: { risk: PaymentRisk | undefined }) {\n const described = describePaymentRisk(risk)\n if (!described) return null\n return (\n <Tooltip title={described.detail}>\n <Chip label={described.label} size=\"small\" color=\"warning\" />\n </Tooltip>\n )\n}\n\n/**\n * Bookings manager (AGL-159): bookable services with weekly availability\n * windows, and the upcoming-bookings list with cancel. Visitors book via\n * the org /api/bookings endpoints; confirmations email through the\n * env-gated Resend path. Plan-gated (`bookings` flag + `servicesPerHost`).\n */\nexport function BookingsConsolePage(props: ConsolePluginPageProps) {\n const { hostId, entitled, org } = props\n const firestore = useFirestore()\n const createHostResource = useHostResourceApi()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n // The id token the refund route authenticates with (AGL-2315).\n const { data: user } = useUser()\n /*\n * Where a booker's CONTACT is (AGL-2622). A booking updated a person in\n * the CRM by the address it carried, and the row links there by that\n * address — the Contacts list holds the id nothing here does and opens\n * the record on one match. The address is the one the plugin that keeps\n * contacts publishes, asked of the record-route registry the way the\n * commerce dialog asks: a plugin importing a sibling is a cycle waiting\n * for its third edge. `null` until the route params settle, and where no\n * plugin keeps contacts, so no row renders a link to nowhere.\n */\n const params = useParams<{ orgSlug?: string; host?: string }>()\n const siteContext =\n params?.orgSlug && params?.host\n ? { orgSlug: String(params.orgSlug), host: String(params.host) }\n : null\n const contactHrefOf = (email: unknown): string | null =>\n siteContext && email ? pluginRecordByEmailHref('contact', siteContext, String(email)) : null\n /*\n * The list narrowed to one booker (AGL-2660): a contact's record links\n * here with `?email=`, and the page answers with every booking that\n * address holds — past ones too, because that link asks about a\n * person's history rather than the week ahead. The same match rule as\n * the row's own \"View in CRM\": the address, normalized, equal. `null`\n * outside a router, where there is no query to read.\n */\n const searchParams = useSearchParams()\n const bookerFilter = normalizeContactEmail(searchParams?.get(BOOKINGS_BOOKER_PARAM))\n const { basePath } = props\n /*\n * Export, opened on the list as it stands: one booker's bookings when the\n * page is narrowed to them, otherwise the upcoming ones from this moment.\n * `null` outside the console shell, where there is nothing to export into.\n * No Import: a booking is only ever made on the booking page.\n */\n const transferLauncher = useTransferLauncher()\n const handleExport = useCallback(() => {\n transferLauncher?.openExport({\n resource: BOOKINGS_TRANSFER_RESOURCE,\n scope: 'host',\n hostId,\n filter: bookerFilter\n ? { label: `Bookings for ${bookerFilter}`, value: bookerBookingsFilterValue(bookerFilter) }\n : { label: 'Upcoming bookings', value: upcomingBookingsFilterValue(Date.now()) },\n })\n }, [transferLauncher, hostId, bookerFilter])\n\n const {\n data: serviceDocs,\n status: servicesStatus,\n /**\n * The rows this editor is seeded from are unconfirmed by the server\n * (AGL-1358). Editing copies a whole stored service into `draft` and\n * writes all of it back, so `merge: true` protects nothing. `windows` is\n * the weekly availability map, rebuilt in full on every save: a cached\n * seed re-opens slots that were closed and closes ones customers can\n * already book, and `priceUsd` goes back to whatever that snapshot\n * charged.\n */\n fromCache: servicesFromCache,\n } = useFirestoreCollection<any>(\n () =>\n query(collection(firestore, 'hosts', hostId, 'services'), limit(100)),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { data: bookingDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'bookings'),\n orderBy('startsAtMs', 'desc'),\n limit(100),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const services = [...(serviceDocs ?? [])]\n .filter((service: any) => !service.deletedAt)\n .sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n const upcoming = [...(bookingDocs ?? [])]\n .filter((booking: any) => booking.endsAtMs >= Date.now())\n .sort((a: any, b: any) => a.startsAtMs - b.startsAtMs)\n // Newest first when narrowed to a booker — the listener already orders\n // by start, descending — so the history reads down from the latest.\n const shown = bookerFilter\n ? (bookingDocs ?? []).filter(\n (booking: any) => normalizeContactEmail(booking.email) === bookerFilter,\n )\n : upcoming\n\n /**\n * The 24-hour reminder queue (AGL-2431).\n *\n * Reminders are sent by the `booking-reminders` beat, not by anything on\n * this page, and until that beat existed they were never sent at all — the\n * feature had a designed email template, white-label branding and an\n * `x-cron-secret` door, and no scheduler pointed at it. So the merchant had\n * no way to tell working from broken, and still would not if this card\n * merely asserted that reminders happen.\n *\n * READ-ONLY, and deliberately no \"send now\" button: the beat runs hourly\n * and stamps `reminderSentAt`, so a manual sender would race it for a\n * reminder nobody can un-send. Same call AGL-2227 made for the recovery\n * queue.\n *\n * `isBookingReminderDue` is the sender's own predicate, against one instant\n * shared by both counts, so this is the queue the next pass will drain\n * rather than an approximation of it.\n */\n const reminderNowMs = Date.now()\n const reminderQueue = (bookingDocs ?? []).filter((booking: any) =>\n isBookingReminderDue(booking, reminderNowMs),\n ).length\n const remindersSent = (bookingDocs ?? []).filter(\n (booking: any) => booking.reminderSentAt,\n ).length\n\n const [draft, setDraft] = useState<ServiceDraft | null>(null)\n\n const handleAdd = useCallback(() => {\n if (!entitled) {\n return void enqueueSnackbar(\n 'Bookings require a Starter plan — see Billing to upgrade',\n { variant: 'warning', persist: false },\n )\n }\n const quota = checkQuota(org, 'servicesPerHost', services.length)\n if (!quota.allowed) {\n return void enqueueSnackbar(\n `Service limit reached (${quota.limit}) — upgrade in Billing`,\n { variant: 'warning', persist: false },\n )\n }\n setDraft({\n id: null,\n ...newBookingServiceDraft(\n Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',\n ),\n })\n }, [entitled, org, services.length, enqueueSnackbar])\n\n const handleSave = useCallback(async () => {\n if (!draft || !draft.name.trim()) return\n // The one rule for what a save stores, which the native editors share.\n const fields = bookingServiceFields(draft)\n try {\n if (draft.id) {\n /**\n * Edit stays client-direct (no quota consumed) — and is refused when\n * its seed was never confirmed by the server (AGL-1358). `fields` is\n * every editable key of the stored service, `windows` included, so\n * `merge: true` has nothing left to protect.\n *\n * The guard WRAPS the write. An early return is a shape you can keep\n * while losing the protection; here the write is only reachable\n * through the verdict.\n */\n const verdict = await writeGuardedBySeed(\n {\n subject: 'service',\n unreadable: servicesStatus === 'error',\n fromCache: servicesFromCache,\n },\n async () => {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'services', draft.id),\n { ...fields, updatedAt: Timestamp.now() },\n { merge: true },\n )\n },\n )\n // Before `setDraft(null)`, so a refusal keeps the dialog open with\n // every window that was typed. A save that silently does nothing\n // sends the user back to retype a form that will be refused again\n // just as quietly.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n } else {\n // New service rides the quota-enforcing resources API (AGL-473) —\n // it also re-checks the `bookings` entitlement server-side.\n await createHostResource({ hostId, resource: 'service', data: fields })\n }\n setDraft(null)\n enqueueSnackbar('Service saved', { variant: 'success', persist: false })\n } catch (error: any) {\n console.error(error)\n enqueueSnackbar(error?.message ?? 'An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n }, [\n draft,\n firestore,\n hostId,\n createHostResource,\n enqueueSnackbar,\n servicesStatus,\n servicesFromCache,\n ])\n\n /**\n * A draft is activated here, and only here (AGL-3616): a service a draft\n * writer made is set up and offered nowhere until a person looks at it and\n * says it takes bookings. Deactivating sends a live one back to draft,\n * which takes it off the site without deleting it; bookings it already\n * holds stand. One field, so the seed guard the dialog's whole-document\n * save needs has nothing to protect here.\n */\n const handleServiceStatus = useCallback(\n (service: any, status: BookingServiceStatus) => async () => {\n try {\n await updateDoc(doc(firestore, 'hosts', hostId, 'services', service.$id), {\n status,\n updatedAt: Timestamp.now(),\n })\n enqueueSnackbar(\n status === 'active'\n ? `${service.name} now takes bookings`\n : `${service.name} is a draft — it takes no bookings until activated`,\n { variant: 'success', persist: false },\n )\n } catch (error: any) {\n console.error(error)\n enqueueSnackbar(error?.message ?? 'An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n },\n [firestore, hostId, enqueueSnackbar],\n )\n\n const handleDeleteService = useCallback(\n (service: any) => async () => {\n const confirmed = await confirm({\n title: 'Delete this service?',\n description: `\"${service.name}\" stops accepting bookings.`,\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await updateDoc(doc(firestore, 'hosts', hostId, 'services', service.$id), {\n deletedAt: Timestamp.now(),\n })\n },\n [confirm, firestore, hostId],\n )\n\n /**\n * Cancelling a PAID booking refunds the guest (AGL-2315).\n *\n * This used to be one `updateDoc` writing `status: 'canceled'`, for a paid\n * booking exactly as for a free one. The slot reopened, the appointment was\n * gone, and the guest had paid for it — the money moved nowhere and nothing\n * in the console said so. That was survivable only while the charge settled\n * in Aglyn's own balance and could be given back by hand; a paid booking is\n * a destination charge now, so the funds are at the MERCHANT and there is no\n * later opportunity to notice.\n *\n * So a paid booking cancels through the refund route, which reverses the\n * merchant's share and Aglyn's fee, and which sets `canceled` itself once\n * the money is actually back. A FAILED refund deliberately leaves the\n * booking standing: a cancelled-and-unrefunded appointment is the worst of\n * the three outcomes, and an admin who sees the row still there knows the\n * cancel did not happen.\n */\n const handleCancelBooking = useCallback(\n (booking: any) => async () => {\n const paidCents = Math.max(0, Number(booking.paidAmountCents ?? 0))\n const refundedCents = Math.max(0, Number(booking.refundedCents ?? 0))\n const outstandingCents = Math.max(0, paidCents - refundedCents)\n const refundable = outstandingCents > 0\n const confirmed = await confirm({\n title: 'Cancel this booking?',\n description:\n `${booking.name} (${booking.email}) — the slot reopens.` +\n (refundable\n ? ` $${(outstandingCents / 100).toFixed(2)} is refunded to them` +\n ' through Stripe.'\n : ''),\n confirmationText: refundable ? 'Cancel and refund' : 'Cancel booking',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n\n if (refundable) {\n // `randomUUID` needs a secure context, which the console always is,\n // but fall back rather than throw on a refund.\n const attemptKey =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n try {\n const response = await authorizedFetch(user, '/api/bookings/refund', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Idempotency-Key': attemptKey,\n },\n body: JSON.stringify({ hostId, bookingId: booking.$id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n // A 409 is a guard REFUSING with a body that says what to do\n // instead — a booking paid before the PaymentIntent was recorded\n // names the Stripe dashboard — not the refund machinery failing.\n // It surfaces verbatim, the AGL-1818 rule.\n enqueueSnackbar(payload?.error ?? 'Refund failed', {\n variant: response.status === 409 ? 'warning' : 'error',\n allowDuplicate: true,\n })\n // The booking stays. See the note above: cancelled-and-unrefunded\n // is worse than not cancelled.\n return\n }\n // The route wrote `canceled` itself once the money was back.\n enqueueSnackbar('Booking canceled and refunded', {\n variant: 'success',\n persist: false,\n })\n return\n } catch {\n enqueueSnackbar('Refund failed — the booking was not canceled', {\n variant: 'error',\n allowDuplicate: true,\n })\n return\n }\n }\n\n // Through the cancel route (AGL-3643), not a direct write: the route\n // holds the rule that a paid booking cancels through its refund, and\n // tells the plugins listening for `booking.canceled`.\n try {\n const response = await authorizedFetch(user, '/api/bookings/cancel', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, bookingId: booking.$id }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n enqueueSnackbar(payload?.error ?? 'The booking was not canceled', {\n variant: response.status === 409 ? 'warning' : 'error',\n allowDuplicate: true,\n })\n return\n }\n } catch {\n enqueueSnackbar('The booking was not canceled', {\n variant: 'error',\n allowDuplicate: true,\n })\n return\n }\n enqueueSnackbar('Booking canceled', {\n variant: 'success',\n persist: false,\n })\n },\n [confirm, hostId, enqueueSnackbar, user],\n )\n\n return (\n <Stack spacing={3}>\n <CardDisplay\n header={'Services'}\n help={pluginDocsHelp('bookings', { anchor: '#set-up-bookings' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n {services.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Define a bookable service — duration, price, and weekly ' +\n 'availability — then visitors can book from your site.'}\n </Typography>\n ) : (\n services.map((service: any) => (\n <Stack\n key={service.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {service.name}\n </Typography>\n {bookingServiceStatus(service.status) === 'draft' ? (\n <Tooltip title=\"Set up, and offered nowhere until you activate it\">\n <Chip label=\"Draft\" size=\"small\" />\n </Tooltip>\n ) : null}\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`${service.durationMinutes} min · ${bookingPriceText(service).replace(/^Free$/, 'free')}` +\n ` · ${service.timezone ?? 'UTC'}`}\n </Typography>\n </Stack>\n <Button\n size=\"small\"\n onClick={() =>\n setDraft({\n id: service.$id,\n ...bookingServiceDraftFrom(service),\n })\n }\n >\n {'Edit'}\n </Button>\n {bookingServiceStatus(service.status) === 'draft' ? (\n <Button\n size=\"small\"\n color=\"primary\"\n onClick={handleServiceStatus(service, 'active')}\n >\n {'Activate'}\n </Button>\n ) : (\n <Button size=\"small\" onClick={handleServiceStatus(service, 'draft')}>\n {'Deactivate'}\n </Button>\n )}\n <Button\n size=\"small\"\n color=\"error\"\n onClick={handleDeleteService(service)}\n >\n {'Delete'}\n </Button>\n </Stack>\n ))\n )}\n <Button\n size=\"small\"\n color=\"primary\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={handleAdd}\n >\n {'Add service'}\n </Button>\n {/* The cap, standing rather than only on refusal (AGL-2113).\n `services.length` is the same count `handleAdd` hands to\n `checkQuota`, so the readout and the gate cannot disagree. */}\n <QuotaReadoutComponent\n ready={org != null}\n used={services.length}\n limit={checkQuota(org, 'servicesPerHost', services.length).limit}\n noun=\"service\"\n />\n </Stack>\n </CardDisplay>\n\n <CardDisplay\n header={bookerFilter ? `Bookings for ${bookerFilter}` : 'Upcoming bookings'}\n help={pluginDocsHelp('bookings', { anchor: '#manage' })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: transferLauncher?.can('export', { resource: BOOKINGS_TRANSFER_RESOURCE, scope: 'host', hostId }) ? (\n <Button size=\"small\" color=\"primary\" onClick={handleExport}>\n {'Export'}\n </Button>\n ) : undefined,\n }}\n >\n {bookerFilter ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mb: 1 }}\n >\n {'Every booking this address holds, newest first. '}\n {basePath ? <AppLink href={basePath}>{'Show upcoming bookings'}</AppLink> : null}\n </Typography>\n ) : null}\n {/* What the reminder beat will do next, and what it has done. Named\n \"24-hour reminders\" rather than \"emails\" because that is the only\n mail this queue governs — confirmations go out on booking. */}\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mb: 1 }}\n >\n {`24-hour reminders · ${reminderQueue} due in the next pass · ` +\n `${remindersSent} already sent`}\n {/* Its OWN heading, not the card's `#manage`: a merchant reading\n this line wants the timing and the once-only rule, and landing\n them on \"manage your bookings\" is the presence-not-correctness\n failure a help-coverage check cannot see. */}\n <HelpTip\n {...pluginDocsHelp('bookings', { anchor: '#reminders' })}\n sx={{ ml: 0.5, fontSize: '0.9em' }}\n />\n </Typography>\n {shown.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {bookerFilter ? 'No bookings for this address.' : 'No upcoming bookings.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n {shown.map((booking: any) => (\n <Stack\n key={booking.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${booking.serviceName} — ${booking.name}`}\n {booking.status === 'canceled' ? ' (canceled)' : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`${new Date(booking.startsAtMs).toLocaleString()} · ${\n booking.email\n }`}\n {typeof booking.phone === 'string' && booking.phone\n ? ` · ${booking.phone}`\n : ''}\n </Typography>\n {/* Where the job is, when the service asked (AGL-3493).\n Wrapped rather than cut: an address read to its end is\n the one a crew can drive to. */}\n {typeof booking.address === 'string' && booking.address ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ whiteSpace: 'pre-line' }}\n >\n {booking.address}\n </Typography>\n ) : null}\n </Stack>\n <PaymentRiskChip risk={booking.paymentRisk} />\n {contactHrefOf(booking.email) ? (\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={contactHrefOf(booking.email) ?? undefined}\n size=\"small\"\n >\n {'View in CRM'}\n </Button>\n ) : null}\n {booking.status !== 'canceled' ? (\n <Button\n size=\"small\"\n color=\"error\"\n onClick={handleCancelBooking(booking)}\n >\n {'Cancel'}\n </Button>\n ) : null}\n </Stack>\n ))}\n </Stack>\n )}\n </CardDisplay>\n\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{draft?.id ? 'Edit service' : 'Add service'}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n <TextField\n label=\"Name\"\n value={draft?.name ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, name: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <Stack direction=\"row\" spacing={1}>\n <TextField\n label=\"Duration (minutes)\"\n value={draft?.durationMinutes ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? {\n ...prev,\n durationMinutes: event.target.value.replace(\n /[^0-9]/g,\n '',\n ),\n }\n : prev,\n )\n }\n size=\"small\"\n />\n <TextField\n label=\"Price (USD, 0 = free)\"\n // WHAT THIS PRICE DOES NOT INCLUDE (AGL-2028).\n //\n // A paid booking is charged exactly this figure: the handler\n // sends no tax parameter at all, by a stated decision (AGL-2000)\n // — whether a service is taxable is jurisdiction-specific and\n // frequently the opposite answer from goods, so applying the\n // commerce plugin's GOODS sales rate would be confidently wrong\n // rather than merely absent.\n //\n // That decision was recorded in the source and in the\n // `storefrontTaxCollected` ledger, and in neither place can the\n // merchant see it. A service business is one of the three named\n // ICPs, and one who configured a rate in Commerce → Settings →\n // Taxes has every reason to assume it covers the appointments\n // they sell on the same site. Saying so here is the half of\n // AGL-2028 that holds however the rate question is answered.\n //\n // States the MECHANISM and makes no remittance determination —\n // the same line `describeOrderTaxMode` holds. Who owes which\n // authority what attaches by operation of law and is counsel's\n // call (AGL-1904/AGL-1956).\n helperText={\n draft && draft.priceDisplay !== 'fixed'\n ? `Not charged: this service shows “${BOOKING_PRICE_LABELS[draft.priceDisplay]}” and books with no charge.`\n : `${PLATFORM_BRAND_NAME} charges this price as typed — no tax is added. Your Commerce tax settings are a goods sales rate and do not apply to bookings.`\n }\n value={draft?.priceUsd ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? {\n ...prev,\n priceUsd: event.target.value.replace(/[^0-9]/g, ''),\n }\n : prev,\n )\n }\n size=\"small\"\n />\n {/*\n A contractor who quotes at the job states the price as a label\n instead (AGL-3475). Any label books with no charge, like an\n estimate appointment, and the stored price is neither shown nor\n charged.\n */}\n <TextField\n select\n label=\"Show the price as\"\n value={draft?.priceDisplay ?? 'fixed'}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, priceDisplay: bookingPriceDisplay(event.target.value) }\n : prev,\n )\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n >\n {BOOKING_PRICE_DISPLAYS.map((display) => (\n <MenuItem key={display} value={display}>\n {PRICE_DISPLAY_LABELS[display]}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n label=\"Timezone\"\n value={draft?.timezone ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, timezone: event.target.value } : prev,\n )\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n />\n </Stack>\n <TextField\n label=\"Description (optional)\"\n value={draft?.description ?? ''}\n onChange={(event) =>\n setDraft((prev) =>\n prev ? { ...prev, description: event.target.value } : prev,\n )\n }\n size=\"small\"\n multiline\n minRows={2}\n />\n <WeeklyHoursPicker\n label=\"Weekly availability\"\n value={(draft?.windowText ?? []).map((text) => parseBookingWindows(text))}\n onChange={(hours) =>\n setDraft((prev) =>\n prev\n ? { ...prev, windowText: hours.map((day) => formatBookingWindows(day)) }\n : prev,\n )\n }\n sameDay\n helperText=\"Switch on each day the service is offered, then pick the hours slots are offered in.\"\n />\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Booking form'}\n </Typography>\n {/*\n What the widget asks for beyond a name and an email (AGL-3493).\n Off by default; an on-site service asks for both, required.\n */}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n {(\n [\n ['askPhone', 'Phone number'],\n ['askAddress', 'Address'],\n ] as const\n ).map(([key, label]) => (\n <TextField\n key={key}\n select\n label={label}\n value={draft?.[key] ?? 'off'}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, [key]: event.target.value as BookingFieldAsk }\n : prev,\n )\n }\n size=\"small\"\n fullWidth\n >\n {BOOKING_FIELD_ASKS.map((ask) => (\n <MenuItem key={ask} value={ask}>\n {FIELD_ASK_LABELS[ask]}\n </MenuItem>\n ))}\n </TextField>\n ))}\n </Stack>\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'CRM'}\n </Typography>\n {/*\n What a booking of this service does to the booker's CRM record\n (AGL-2660). The meeting is on by default — a booking IS a\n meeting the record has — and the follow-up is the service's\n choice, because not every service earns a call afterwards.\n */}\n <FormControlLabel\n control={\n <Switch\n checked={draft?.crmMeetingActivity ?? true}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, crmMeetingActivity: event.target.checked }\n : prev,\n )\n }\n size=\"small\"\n />\n }\n label=\"Log a meeting on the CRM record when this service is booked\"\n />\n <FormControlLabel\n control={\n <Switch\n checked={draft?.crmFollowUpTask ?? false}\n onChange={(event) =>\n setDraft((prev) =>\n prev\n ? { ...prev, crmFollowUpTask: event.target.checked }\n : prev,\n )\n }\n size=\"small\"\n />\n }\n label=\"Create a follow-up task on the CRM record when this service is booked\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'The follow-up is due one business day after the slot, on whoever ' +\n 'owns the record. Nothing is filed on a site whose CRM is off.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.name.trim()}\n onClick={handleSave}\n >\n {'Save service'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nBookingsConsolePage.displayName = 'BookingsConsolePage'\n\nexport default BookingsConsolePage\n"],"names":["checkQuota","pluginDocsHelp","useTransferLauncher","normalizeContactEmail","pluginRecordByEmailHref","BOOKINGS_BOOKER_PARAM","BOOKINGS_TRANSFER_RESOURCE","bookerBookingsFilterValue","upcomingBookingsFilterValue","PLATFORM_BRAND_NAME","describePaymentRisk","isBookingReminderDue","bookingServiceDraftFrom","bookingServiceFields","formatBookingWindows","newBookingServiceDraft","parseBookingWindows","WeeklyHoursPicker","bookingServiceStatus","BOOKING_FIELD_ASKS","BOOKING_PRICE_DISPLAYS","BOOKING_PRICE_LABELS","bookingPriceDisplay","bookingPriceText","AppLink","CardDisplay","HelpTip","useConfirmationContext","QuotaReadoutComponent","useSnackbar","Timestamp","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","MenuItem","Stack","Switch","TextField","Tooltip","Typography","collection","doc","limit","orderBy","query","setDoc","updateDoc","useParams","useSearchParams","useCallback","useState","useFirestore","useFirestoreCollection","useHostResourceApi","useUser","writeGuardedBySeed","authorizedFetch","PRICE_DISPLAY_LABELS","fixed","FIELD_ASK_LABELS","off","optional","required","PaymentRiskChip","risk","described","title","detail","label","size","color","BookingsConsolePage","props","hostId","entitled","org","firestore","createHostResource","enqueueSnackbar","confirm","data","user","params","siteContext","orgSlug","host","String","contactHrefOf","email","searchParams","bookerFilter","get","basePath","transferLauncher","handleExport","openExport","resource","scope","filter","value","Date","now","serviceDocs","status","servicesStatus","fromCache","servicesFromCache","idField","bookingDocs","services","service","deletedAt","sort","a","b","name","localeCompare","upcoming","booking","endsAtMs","startsAtMs","shown","reminderNowMs","reminderQueue","length","remindersSent","reminderSentAt","draft","setDraft","handleAdd","variant","persist","quota","allowed","id","Intl","DateTimeFormat","resolvedOptions","timeZone","handleSave","trim","fields","verdict","subject","unreadable","updatedAt","merge","ok","message","error","console","allowDuplicate","handleServiceStatus","$id","handleDeleteService","confirmed","description","confirmationText","confirmationButtonProps","then","catch","handleCancelBooking","paidCents","Math","max","Number","paidAmountCents","refundedCents","outstandingCents","refundable","toFixed","globalThis","attemptKey","crypto","randomUUID","random","toString","slice","response","method","headers","body","JSON","stringify","bookingId","payload","json","spacing","header","help","anchor","contentGutterX","contentGutterY","map","direction","sx","alignItems","flex","minWidth","noWrap","durationMinutes","replace","timezone","onClick","alignSelf","ready","used","noun","HeaderProps","action","can","undefined","component","mb","href","ml","fontSize","serviceName","toLocaleString","phone","address","whiteSpace","paymentRisk","componentVariant","nativeButton","open","Boolean","onClose","maxWidth","fullWidth","display","flexDirection","gap","pt","onChange","event","prev","target","autoFocus","mt","helperText","priceDisplay","priceUsd","select","multiline","minRows","windowText","text","hours","day","sameDay","xs","sm","key","ask","control","checked","crmMeetingActivity","crmFollowUpTask","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,UAAU,EAAEC,cAAc,EAAEC,mBAAmB,QAAQ,eAAc;AAC9E,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,qBAAqB,QAAQ,qCAAiC;AACvE,SACEC,0BAA0B,EAC1BC,yBAAyB,EACzBC,2BAA2B,QACtB,0CAAsC;AAC7C,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,mBAAmB,QAA0B,sCAAqC;AAE3F,SAASC,oBAAoB,QAAQ,oBAAU;AAC/C,SAEEC,uBAAuB,EACvBC,oBAAoB,EACpBC,oBAAoB,EACpBC,sBAAsB,EACtBC,mBAAmB,QACd,mCAA+B;AACtC,SAASC,iBAAiB,QAAQ,gEAA+D;AACjG,SAAoCC,oBAAoB,QAAQ,uBAAmB;AACnF,SACEC,kBAAkB,QAEb,qCAAiC;AACxC,S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