@cimplify/sdk 0.45.0 → 0.45.2
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/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/{chunk-W72W6M6M.mjs → chunk-EMEUSFSR.mjs} +32 -12
- package/dist/{chunk-GCSZYC5C.js → chunk-F4CGIOIJ.js} +32 -12
- package/dist/{chunk-T4E4R4YG.js → chunk-JNXCY43J.js} +2 -2
- package/dist/{chunk-D3TVW7JP.mjs → chunk-YVIIBCJR.mjs} +1 -1
- package/dist/{client-5B9IPDmf.d.ts → client-Bsd4Vi_y.d.ts} +1 -0
- package/dist/{client-CpVMRI8V.d.mts → client-C5LcbNxL.d.mts} +1 -0
- package/dist/{client-DMhRxuzm.d.ts → client-DjzIoewX.d.ts} +1 -1
- package/dist/{client-Cwb1sMr3.d.mts → client-EM8xKCPO.d.mts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mock/cli.mjs +32 -12
- package/dist/mock/library.js +32 -12
- package/dist/mock/library.mjs +32 -12
- package/dist/mock/msw.js +32 -12
- package/dist/mock/msw.mjs +32 -12
- package/dist/react.d.mts +120 -45
- package/dist/react.d.ts +120 -45
- package/dist/react.js +453 -97
- package/dist/react.mjs +452 -98
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/styles.css +2 -2
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +21 -21
- package/dist/testing/suite.mjs +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +77 -77
- package/dist/testing.mjs +3 -3
- package/package.json +1 -1
- package/registry/booking-page.json +19 -0
- package/registry/bookings-page.json +17 -0
- package/registry/index.json +24 -0
package/dist/react.js
CHANGED
|
@@ -9480,6 +9480,457 @@ function BookingList({
|
|
|
9480
9480
|
booking.order_id
|
|
9481
9481
|
)) });
|
|
9482
9482
|
}
|
|
9483
|
+
var ANY_VALUE2 = "__any__";
|
|
9484
|
+
function roomToResource(room) {
|
|
9485
|
+
return {
|
|
9486
|
+
id: room.id,
|
|
9487
|
+
name: room.name,
|
|
9488
|
+
capacity: room.capacity,
|
|
9489
|
+
floor: room.floor,
|
|
9490
|
+
is_available: room.status === "available"
|
|
9491
|
+
};
|
|
9492
|
+
}
|
|
9493
|
+
function ResourcePicker({
|
|
9494
|
+
resources,
|
|
9495
|
+
selectedResourceId,
|
|
9496
|
+
onResourceSelect,
|
|
9497
|
+
showAnyOption = true,
|
|
9498
|
+
anyLabel = "Any available",
|
|
9499
|
+
renderImage,
|
|
9500
|
+
className,
|
|
9501
|
+
classNames
|
|
9502
|
+
}) {
|
|
9503
|
+
const groupValue = selectedResourceId === null ? ANY_VALUE2 : selectedResourceId ?? "";
|
|
9504
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9505
|
+
radioGroup.RadioGroup,
|
|
9506
|
+
{
|
|
9507
|
+
"data-cimplify-resource-picker": true,
|
|
9508
|
+
className: cn("flex flex-col gap-2", className, classNames?.root),
|
|
9509
|
+
value: groupValue,
|
|
9510
|
+
onValueChange: (value) => {
|
|
9511
|
+
onResourceSelect?.(value === ANY_VALUE2 ? null : value);
|
|
9512
|
+
},
|
|
9513
|
+
children: [
|
|
9514
|
+
showAnyOption && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9515
|
+
radio.Radio.Root,
|
|
9516
|
+
{
|
|
9517
|
+
value: ANY_VALUE2,
|
|
9518
|
+
"data-cimplify-resource-option": true,
|
|
9519
|
+
"data-selected": selectedResourceId === null || void 0,
|
|
9520
|
+
"data-any": true,
|
|
9521
|
+
className: cn(
|
|
9522
|
+
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
9523
|
+
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
9524
|
+
classNames?.option
|
|
9525
|
+
),
|
|
9526
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: anyLabel })
|
|
9527
|
+
}
|
|
9528
|
+
),
|
|
9529
|
+
resources.map((resource) => {
|
|
9530
|
+
const unavailable = resource.is_available === false;
|
|
9531
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9532
|
+
radio.Radio.Root,
|
|
9533
|
+
{
|
|
9534
|
+
value: resource.id,
|
|
9535
|
+
disabled: unavailable,
|
|
9536
|
+
"data-cimplify-resource-option": true,
|
|
9537
|
+
"data-selected": selectedResourceId === resource.id || void 0,
|
|
9538
|
+
"data-unavailable": unavailable || void 0,
|
|
9539
|
+
className: cn(
|
|
9540
|
+
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
9541
|
+
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
9542
|
+
unavailable && "opacity-50 cursor-not-allowed",
|
|
9543
|
+
classNames?.option,
|
|
9544
|
+
unavailable ? classNames?.unavailable : void 0
|
|
9545
|
+
),
|
|
9546
|
+
children: [
|
|
9547
|
+
resource.image_url && (renderImage ? renderImage({
|
|
9548
|
+
src: resource.image_url,
|
|
9549
|
+
alt: resource.name,
|
|
9550
|
+
className: classNames?.image
|
|
9551
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
9552
|
+
"img",
|
|
9553
|
+
{
|
|
9554
|
+
src: resource.image_url,
|
|
9555
|
+
alt: resource.name,
|
|
9556
|
+
"data-cimplify-resource-image": true,
|
|
9557
|
+
className: cn("w-10 h-10 rounded-lg object-cover", classNames?.image)
|
|
9558
|
+
}
|
|
9559
|
+
)),
|
|
9560
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [
|
|
9561
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: resource.name }),
|
|
9562
|
+
resource.description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-description": true, className: cn("text-sm text-muted-foreground truncate", classNames?.description), children: resource.description }),
|
|
9563
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-resource-meta": true, className: cn("flex items-center gap-2 text-xs text-muted-foreground", classNames?.meta), children: [
|
|
9564
|
+
resource.capacity !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-resource-capacity": true, className: classNames?.capacity, children: [
|
|
9565
|
+
"Up to ",
|
|
9566
|
+
resource.capacity
|
|
9567
|
+
] }),
|
|
9568
|
+
resource.floor && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-floor": true, className: classNames?.floor, children: resource.floor })
|
|
9569
|
+
] })
|
|
9570
|
+
] })
|
|
9571
|
+
]
|
|
9572
|
+
},
|
|
9573
|
+
resource.id
|
|
9574
|
+
);
|
|
9575
|
+
})
|
|
9576
|
+
]
|
|
9577
|
+
}
|
|
9578
|
+
);
|
|
9579
|
+
}
|
|
9580
|
+
var STEP = {
|
|
9581
|
+
SELECT_SLOT: "select-slot",
|
|
9582
|
+
SELECT_RESOURCE: "select-resource",
|
|
9583
|
+
SELECT_STAFF: "select-staff",
|
|
9584
|
+
CONFIRM: "confirm"
|
|
9585
|
+
};
|
|
9586
|
+
function BookingPage({
|
|
9587
|
+
service,
|
|
9588
|
+
product,
|
|
9589
|
+
staff,
|
|
9590
|
+
resources,
|
|
9591
|
+
participantCount,
|
|
9592
|
+
title,
|
|
9593
|
+
onBooked,
|
|
9594
|
+
onBack,
|
|
9595
|
+
existingBooking,
|
|
9596
|
+
onRescheduled,
|
|
9597
|
+
showPrice = true,
|
|
9598
|
+
className,
|
|
9599
|
+
classNames
|
|
9600
|
+
}) {
|
|
9601
|
+
const { addItem } = useCart();
|
|
9602
|
+
const { client } = useCimplifyClient();
|
|
9603
|
+
const isReschedule = existingBooking !== void 0;
|
|
9604
|
+
const [step, setStep] = React10.useState(STEP.SELECT_SLOT);
|
|
9605
|
+
const [selectedSlot, setSelectedSlot] = React10.useState(null);
|
|
9606
|
+
const [selectedDate, setSelectedDate] = React10.useState(null);
|
|
9607
|
+
const [selectedStaffId, setSelectedStaffId] = React10.useState(null);
|
|
9608
|
+
const [selectedResourceId, setSelectedResourceId] = React10.useState(null);
|
|
9609
|
+
const [isSubmitting, setIsSubmitting] = React10.useState(false);
|
|
9610
|
+
const [error, setError] = React10.useState(null);
|
|
9611
|
+
const hasResourceStep = resources && resources.length > 0;
|
|
9612
|
+
const hasStaffStep = staff && staff.length > 0;
|
|
9613
|
+
const depositType = product?.deposit_type;
|
|
9614
|
+
const depositAmount = product?.deposit_amount;
|
|
9615
|
+
const hasDeposit = depositType !== void 0 && depositType !== "none" && depositAmount !== void 0 && chunkBN2CXGMO_js.parsePrice(depositAmount) !== 0;
|
|
9616
|
+
const cancellationMinutes = product?.cancellation_window_minutes;
|
|
9617
|
+
const noShowFee = product?.no_show_fee;
|
|
9618
|
+
const handleSlotSelect = React10.useCallback(
|
|
9619
|
+
(slot, date) => {
|
|
9620
|
+
setSelectedSlot(slot);
|
|
9621
|
+
setSelectedDate(date);
|
|
9622
|
+
setError(null);
|
|
9623
|
+
if (hasResourceStep) {
|
|
9624
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9625
|
+
} else if (hasStaffStep) {
|
|
9626
|
+
setStep(STEP.SELECT_STAFF);
|
|
9627
|
+
} else {
|
|
9628
|
+
setStep(STEP.CONFIRM);
|
|
9629
|
+
}
|
|
9630
|
+
},
|
|
9631
|
+
[hasResourceStep, hasStaffStep]
|
|
9632
|
+
);
|
|
9633
|
+
const handleResourceSelect = React10.useCallback(
|
|
9634
|
+
(resourceId) => {
|
|
9635
|
+
setSelectedResourceId(resourceId);
|
|
9636
|
+
if (hasStaffStep) {
|
|
9637
|
+
setStep(STEP.SELECT_STAFF);
|
|
9638
|
+
} else {
|
|
9639
|
+
setStep(STEP.CONFIRM);
|
|
9640
|
+
}
|
|
9641
|
+
},
|
|
9642
|
+
[hasStaffStep]
|
|
9643
|
+
);
|
|
9644
|
+
const handleStaffSelect = React10.useCallback((staffId) => {
|
|
9645
|
+
setSelectedStaffId(staffId);
|
|
9646
|
+
setStep(STEP.CONFIRM);
|
|
9647
|
+
}, []);
|
|
9648
|
+
const handleBack = React10.useCallback(() => {
|
|
9649
|
+
setError(null);
|
|
9650
|
+
if (step === STEP.CONFIRM && hasStaffStep) {
|
|
9651
|
+
setStep(STEP.SELECT_STAFF);
|
|
9652
|
+
} else if (step === STEP.CONFIRM && hasResourceStep) {
|
|
9653
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9654
|
+
} else if (step === STEP.SELECT_STAFF && hasResourceStep) {
|
|
9655
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9656
|
+
} else if (step === STEP.CONFIRM || step === STEP.SELECT_STAFF || step === STEP.SELECT_RESOURCE) {
|
|
9657
|
+
setStep(STEP.SELECT_SLOT);
|
|
9658
|
+
} else {
|
|
9659
|
+
onBack?.();
|
|
9660
|
+
}
|
|
9661
|
+
}, [step, hasStaffStep, hasResourceStep, onBack]);
|
|
9662
|
+
const handleConfirm = React10.useCallback(async () => {
|
|
9663
|
+
if (!selectedSlot || !selectedDate) return;
|
|
9664
|
+
setIsSubmitting(true);
|
|
9665
|
+
setError(null);
|
|
9666
|
+
try {
|
|
9667
|
+
if (isReschedule && existingBooking) {
|
|
9668
|
+
const serviceItem = existingBooking.service_items[0];
|
|
9669
|
+
const result = await client.scheduling.rescheduleBooking({
|
|
9670
|
+
order_id: existingBooking.order_id,
|
|
9671
|
+
line_item_id: serviceItem?.service_id ?? existingBooking.order_id,
|
|
9672
|
+
new_start_time: selectedSlot.start_time,
|
|
9673
|
+
new_end_time: selectedSlot.end_time,
|
|
9674
|
+
new_staff_id: selectedStaffId || void 0,
|
|
9675
|
+
reschedule_type: "customer"
|
|
9676
|
+
});
|
|
9677
|
+
if (!result.ok) {
|
|
9678
|
+
throw result.error;
|
|
9679
|
+
}
|
|
9680
|
+
onRescheduled?.(existingBooking, selectedSlot);
|
|
9681
|
+
} else {
|
|
9682
|
+
const serviceProduct = {
|
|
9683
|
+
id: service.product_id || service.id,
|
|
9684
|
+
business_id: service.business_id || "",
|
|
9685
|
+
category_id: service.category_id || void 0,
|
|
9686
|
+
name: service.name,
|
|
9687
|
+
slug: service.id,
|
|
9688
|
+
description: service.description || void 0,
|
|
9689
|
+
image_url: service.image_url || void 0,
|
|
9690
|
+
default_price: service.price || "0",
|
|
9691
|
+
type: "service",
|
|
9692
|
+
inventory_type: "none",
|
|
9693
|
+
variant_strategy: "fetch_all",
|
|
9694
|
+
is_active: service.is_available,
|
|
9695
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9696
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
9697
|
+
};
|
|
9698
|
+
await addItem(serviceProduct, 1, {
|
|
9699
|
+
scheduledStart: selectedSlot.start_time,
|
|
9700
|
+
scheduledEnd: selectedSlot.end_time,
|
|
9701
|
+
staffId: selectedStaffId || void 0,
|
|
9702
|
+
resourceId: selectedResourceId || void 0
|
|
9703
|
+
});
|
|
9704
|
+
onBooked?.(selectedSlot, selectedStaffId);
|
|
9705
|
+
}
|
|
9706
|
+
} catch (err) {
|
|
9707
|
+
const fallbackMessage = isReschedule ? "Failed to reschedule booking" : "Failed to add booking to cart";
|
|
9708
|
+
setError(err instanceof Error ? err.message : fallbackMessage);
|
|
9709
|
+
} finally {
|
|
9710
|
+
setIsSubmitting(false);
|
|
9711
|
+
}
|
|
9712
|
+
}, [selectedSlot, selectedDate, selectedStaffId, service, addItem, onBooked, isReschedule, existingBooking, client, onRescheduled]);
|
|
9713
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-page": true, className: cn(className, classNames?.root), children: [
|
|
9714
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-page-header": true, className: classNames?.header, children: [
|
|
9715
|
+
onBack && step === STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9716
|
+
"button",
|
|
9717
|
+
{
|
|
9718
|
+
type: "button",
|
|
9719
|
+
onClick: onBack,
|
|
9720
|
+
"data-cimplify-booking-page-back": true,
|
|
9721
|
+
className: classNames?.backButton,
|
|
9722
|
+
children: "Back"
|
|
9723
|
+
}
|
|
9724
|
+
),
|
|
9725
|
+
step !== STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9726
|
+
"button",
|
|
9727
|
+
{
|
|
9728
|
+
type: "button",
|
|
9729
|
+
onClick: handleBack,
|
|
9730
|
+
"data-cimplify-booking-page-back": true,
|
|
9731
|
+
className: classNames?.backButton,
|
|
9732
|
+
children: "Back"
|
|
9733
|
+
}
|
|
9734
|
+
),
|
|
9735
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { "data-cimplify-booking-page-title": true, className: classNames?.title, children: title || (isReschedule ? "Reschedule Booking" : `Book ${service.name}`) })
|
|
9736
|
+
] }),
|
|
9737
|
+
isReschedule && existingBooking && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-booking-reschedule-info": true, className: classNames?.rescheduleInfo, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
9738
|
+
"Rescheduling booking from ",
|
|
9739
|
+
new Date(existingBooking.service_items[0]?.scheduled_start ?? existingBooking.created_at).toLocaleDateString()
|
|
9740
|
+
] }) }),
|
|
9741
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-service-info": true, className: classNames?.serviceInfo, children: [
|
|
9742
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-service-name": true, children: service.name }),
|
|
9743
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-service-duration": true, children: formatDuration2(service.duration_minutes, service.duration_unit) }),
|
|
9744
|
+
service.price && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-service-price": true, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: service.price }) }),
|
|
9745
|
+
hasDeposit && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-deposit-info": true, className: classNames?.depositInfo, children: [
|
|
9746
|
+
"Deposit: ",
|
|
9747
|
+
depositType === "percentage" ? `${chunkBN2CXGMO_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount })
|
|
9748
|
+
] }),
|
|
9749
|
+
cancellationMinutes !== void 0 && cancellationMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-cancellation-policy": true, className: classNames?.cancellationPolicy, children: [
|
|
9750
|
+
"Free cancellation up to ",
|
|
9751
|
+
cancellationMinutes >= 60 ? `${Math.floor(cancellationMinutes / 60)} hour${Math.floor(cancellationMinutes / 60) !== 1 ? "s" : ""}` : `${cancellationMinutes} minute${cancellationMinutes !== 1 ? "s" : ""}`,
|
|
9752
|
+
" before"
|
|
9753
|
+
] }),
|
|
9754
|
+
noShowFee !== void 0 && chunkBN2CXGMO_js.parsePrice(noShowFee) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-no-show-fee": true, className: classNames?.cancellationPolicy, children: [
|
|
9755
|
+
"No-show fee: ",
|
|
9756
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: noShowFee })
|
|
9757
|
+
] })
|
|
9758
|
+
] }),
|
|
9759
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-booking-error": true, className: classNames?.error, children: error }),
|
|
9760
|
+
step === STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-slot", className: classNames?.step, children: [
|
|
9761
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Select a date & time" }),
|
|
9762
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9763
|
+
DateSlotPicker,
|
|
9764
|
+
{
|
|
9765
|
+
serviceId: service.id,
|
|
9766
|
+
participantCount,
|
|
9767
|
+
selectedSlot,
|
|
9768
|
+
onSlotSelect: handleSlotSelect,
|
|
9769
|
+
showPrice
|
|
9770
|
+
}
|
|
9771
|
+
)
|
|
9772
|
+
] }),
|
|
9773
|
+
step === STEP.SELECT_RESOURCE && resources && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-resource", className: cn(classNames?.step, classNames?.resourceStep), children: [
|
|
9774
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Choose a room" }),
|
|
9775
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9776
|
+
ResourcePicker,
|
|
9777
|
+
{
|
|
9778
|
+
resources,
|
|
9779
|
+
selectedResourceId,
|
|
9780
|
+
onResourceSelect: handleResourceSelect
|
|
9781
|
+
}
|
|
9782
|
+
)
|
|
9783
|
+
] }),
|
|
9784
|
+
step === STEP.SELECT_STAFF && staff && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-staff", className: classNames?.step, children: [
|
|
9785
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Choose a provider" }),
|
|
9786
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9787
|
+
StaffPicker,
|
|
9788
|
+
{
|
|
9789
|
+
staff,
|
|
9790
|
+
selectedStaffId,
|
|
9791
|
+
onStaffSelect: handleStaffSelect
|
|
9792
|
+
}
|
|
9793
|
+
)
|
|
9794
|
+
] }),
|
|
9795
|
+
step === STEP.CONFIRM && selectedSlot && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "confirm", className: classNames?.step, children: [
|
|
9796
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Confirm your booking" }),
|
|
9797
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary": true, className: classNames?.summary, children: [
|
|
9798
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9799
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service" }),
|
|
9800
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: service.name })
|
|
9801
|
+
] }),
|
|
9802
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9803
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Date" }),
|
|
9804
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedDate })
|
|
9805
|
+
] }),
|
|
9806
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9807
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Time" }),
|
|
9808
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: new Date(selectedSlot.start_time).toLocaleTimeString(void 0, {
|
|
9809
|
+
hour: "numeric",
|
|
9810
|
+
minute: "2-digit"
|
|
9811
|
+
}) })
|
|
9812
|
+
] }),
|
|
9813
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9814
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Duration" }),
|
|
9815
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDuration2(service.duration_minutes, service.duration_unit) })
|
|
9816
|
+
] }),
|
|
9817
|
+
selectedResourceId && resources && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9818
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Room" }),
|
|
9819
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: resources.find((r) => r.id === selectedResourceId)?.name ?? "Selected" })
|
|
9820
|
+
] }),
|
|
9821
|
+
selectedStaffId && staff && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9822
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Provider" }),
|
|
9823
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: staff.find((s) => s.id === selectedStaffId)?.name ?? "Selected" })
|
|
9824
|
+
] }),
|
|
9825
|
+
(selectedSlot.price || service.price) && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9826
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Price" }),
|
|
9827
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: selectedSlot.price || service.price }) })
|
|
9828
|
+
] }),
|
|
9829
|
+
hasDeposit && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: cn(classNames?.summaryRow, classNames?.depositInfo), children: [
|
|
9830
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Deposit" }),
|
|
9831
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: depositType === "percentage" ? `${chunkBN2CXGMO_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount }) })
|
|
9832
|
+
] })
|
|
9833
|
+
] }),
|
|
9834
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9835
|
+
"button",
|
|
9836
|
+
{
|
|
9837
|
+
type: "button",
|
|
9838
|
+
onClick: handleConfirm,
|
|
9839
|
+
disabled: isSubmitting,
|
|
9840
|
+
"data-cimplify-booking-confirm": true,
|
|
9841
|
+
className: classNames?.confirmButton,
|
|
9842
|
+
children: isSubmitting ? isReschedule ? "Rescheduling\u2026" : "Adding to cart\u2026" : isReschedule ? "Reschedule" : "Confirm Booking"
|
|
9843
|
+
}
|
|
9844
|
+
)
|
|
9845
|
+
] })
|
|
9846
|
+
] });
|
|
9847
|
+
}
|
|
9848
|
+
var BOOKING_FILTERS = [
|
|
9849
|
+
{ label: "All", value: "all" },
|
|
9850
|
+
{ label: "Upcoming", value: "upcoming" },
|
|
9851
|
+
{ label: "Past", value: "past" }
|
|
9852
|
+
];
|
|
9853
|
+
function BookingsPage({
|
|
9854
|
+
title = "My Bookings",
|
|
9855
|
+
bookings: bookingsProp,
|
|
9856
|
+
onBookingNavigate,
|
|
9857
|
+
onCancel,
|
|
9858
|
+
onReschedule,
|
|
9859
|
+
showFilters = true,
|
|
9860
|
+
renderBooking,
|
|
9861
|
+
className,
|
|
9862
|
+
classNames
|
|
9863
|
+
}) {
|
|
9864
|
+
const [filter, setFilter] = React10.useState("all");
|
|
9865
|
+
const [selectedBooking, setSelectedBooking] = React10.useState(null);
|
|
9866
|
+
const handleBookingClick = React10.useCallback(
|
|
9867
|
+
(booking) => {
|
|
9868
|
+
if (onBookingNavigate) {
|
|
9869
|
+
onBookingNavigate(booking);
|
|
9870
|
+
} else {
|
|
9871
|
+
setSelectedBooking(booking);
|
|
9872
|
+
}
|
|
9873
|
+
},
|
|
9874
|
+
[onBookingNavigate]
|
|
9875
|
+
);
|
|
9876
|
+
const handleBack = React10.useCallback(() => {
|
|
9877
|
+
setSelectedBooking(null);
|
|
9878
|
+
}, []);
|
|
9879
|
+
if (selectedBooking && !onBookingNavigate) {
|
|
9880
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bookings-page": true, className: cn(className, classNames?.root), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bookings-detail": true, className: classNames?.detail, children: [
|
|
9881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9882
|
+
"button",
|
|
9883
|
+
{
|
|
9884
|
+
type: "button",
|
|
9885
|
+
onClick: handleBack,
|
|
9886
|
+
"data-cimplify-bookings-back": true,
|
|
9887
|
+
className: classNames?.backButton,
|
|
9888
|
+
children: "Back to bookings"
|
|
9889
|
+
}
|
|
9890
|
+
),
|
|
9891
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9892
|
+
BookingCard,
|
|
9893
|
+
{
|
|
9894
|
+
booking: selectedBooking,
|
|
9895
|
+
onCancel,
|
|
9896
|
+
onReschedule
|
|
9897
|
+
}
|
|
9898
|
+
)
|
|
9899
|
+
] }) });
|
|
9900
|
+
}
|
|
9901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bookings-page": true, className: cn(className, classNames?.root), children: [
|
|
9902
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bookings-header": true, className: classNames?.header, children: /* @__PURE__ */ jsxRuntime.jsx("h1", { "data-cimplify-bookings-title": true, className: classNames?.title, children: title }) }),
|
|
9903
|
+
showFilters && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9904
|
+
tabs.Tabs.Root,
|
|
9905
|
+
{
|
|
9906
|
+
value: filter,
|
|
9907
|
+
onValueChange: (value) => setFilter(value),
|
|
9908
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(tabs.Tabs.List, { "data-cimplify-bookings-filters": true, className: classNames?.filters, children: BOOKING_FILTERS.map((f) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9909
|
+
tabs.Tabs.Tab,
|
|
9910
|
+
{
|
|
9911
|
+
value: f.value,
|
|
9912
|
+
"data-cimplify-booking-filter": true,
|
|
9913
|
+
"data-selected": filter === f.value || void 0,
|
|
9914
|
+
className: classNames?.filterButton,
|
|
9915
|
+
children: f.label
|
|
9916
|
+
},
|
|
9917
|
+
f.value
|
|
9918
|
+
)) })
|
|
9919
|
+
}
|
|
9920
|
+
),
|
|
9921
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bookings-list": true, className: classNames?.list, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9922
|
+
BookingList,
|
|
9923
|
+
{
|
|
9924
|
+
bookings: bookingsProp,
|
|
9925
|
+
filter,
|
|
9926
|
+
onCancel,
|
|
9927
|
+
onReschedule,
|
|
9928
|
+
onBookingClick: handleBookingClick,
|
|
9929
|
+
renderBooking
|
|
9930
|
+
}
|
|
9931
|
+
) })
|
|
9932
|
+
] });
|
|
9933
|
+
}
|
|
9483
9934
|
function DefaultCatalogueLayout({
|
|
9484
9935
|
products,
|
|
9485
9936
|
categories,
|
|
@@ -12429,103 +12880,6 @@ function CurrencySelector({
|
|
|
12429
12880
|
);
|
|
12430
12881
|
}) });
|
|
12431
12882
|
}
|
|
12432
|
-
var ANY_VALUE2 = "__any__";
|
|
12433
|
-
function roomToResource(room) {
|
|
12434
|
-
return {
|
|
12435
|
-
id: room.id,
|
|
12436
|
-
name: room.name,
|
|
12437
|
-
capacity: room.capacity,
|
|
12438
|
-
floor: room.floor,
|
|
12439
|
-
is_available: room.status === "available"
|
|
12440
|
-
};
|
|
12441
|
-
}
|
|
12442
|
-
function ResourcePicker({
|
|
12443
|
-
resources,
|
|
12444
|
-
selectedResourceId,
|
|
12445
|
-
onResourceSelect,
|
|
12446
|
-
showAnyOption = true,
|
|
12447
|
-
anyLabel = "Any available",
|
|
12448
|
-
renderImage,
|
|
12449
|
-
className,
|
|
12450
|
-
classNames
|
|
12451
|
-
}) {
|
|
12452
|
-
const groupValue = selectedResourceId === null ? ANY_VALUE2 : selectedResourceId ?? "";
|
|
12453
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12454
|
-
radioGroup.RadioGroup,
|
|
12455
|
-
{
|
|
12456
|
-
"data-cimplify-resource-picker": true,
|
|
12457
|
-
className: cn("flex flex-col gap-2", className, classNames?.root),
|
|
12458
|
-
value: groupValue,
|
|
12459
|
-
onValueChange: (value) => {
|
|
12460
|
-
onResourceSelect?.(value === ANY_VALUE2 ? null : value);
|
|
12461
|
-
},
|
|
12462
|
-
children: [
|
|
12463
|
-
showAnyOption && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12464
|
-
radio.Radio.Root,
|
|
12465
|
-
{
|
|
12466
|
-
value: ANY_VALUE2,
|
|
12467
|
-
"data-cimplify-resource-option": true,
|
|
12468
|
-
"data-selected": selectedResourceId === null || void 0,
|
|
12469
|
-
"data-any": true,
|
|
12470
|
-
className: cn(
|
|
12471
|
-
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
12472
|
-
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
12473
|
-
classNames?.option
|
|
12474
|
-
),
|
|
12475
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: anyLabel })
|
|
12476
|
-
}
|
|
12477
|
-
),
|
|
12478
|
-
resources.map((resource) => {
|
|
12479
|
-
const unavailable = resource.is_available === false;
|
|
12480
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12481
|
-
radio.Radio.Root,
|
|
12482
|
-
{
|
|
12483
|
-
value: resource.id,
|
|
12484
|
-
disabled: unavailable,
|
|
12485
|
-
"data-cimplify-resource-option": true,
|
|
12486
|
-
"data-selected": selectedResourceId === resource.id || void 0,
|
|
12487
|
-
"data-unavailable": unavailable || void 0,
|
|
12488
|
-
className: cn(
|
|
12489
|
-
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
12490
|
-
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
12491
|
-
unavailable && "opacity-50 cursor-not-allowed",
|
|
12492
|
-
classNames?.option,
|
|
12493
|
-
unavailable ? classNames?.unavailable : void 0
|
|
12494
|
-
),
|
|
12495
|
-
children: [
|
|
12496
|
-
resource.image_url && (renderImage ? renderImage({
|
|
12497
|
-
src: resource.image_url,
|
|
12498
|
-
alt: resource.name,
|
|
12499
|
-
className: classNames?.image
|
|
12500
|
-
}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12501
|
-
"img",
|
|
12502
|
-
{
|
|
12503
|
-
src: resource.image_url,
|
|
12504
|
-
alt: resource.name,
|
|
12505
|
-
"data-cimplify-resource-image": true,
|
|
12506
|
-
className: cn("w-10 h-10 rounded-lg object-cover", classNames?.image)
|
|
12507
|
-
}
|
|
12508
|
-
)),
|
|
12509
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [
|
|
12510
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: resource.name }),
|
|
12511
|
-
resource.description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-description": true, className: cn("text-sm text-muted-foreground truncate", classNames?.description), children: resource.description }),
|
|
12512
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-resource-meta": true, className: cn("flex items-center gap-2 text-xs text-muted-foreground", classNames?.meta), children: [
|
|
12513
|
-
resource.capacity !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-resource-capacity": true, className: classNames?.capacity, children: [
|
|
12514
|
-
"Up to ",
|
|
12515
|
-
resource.capacity
|
|
12516
|
-
] }),
|
|
12517
|
-
resource.floor && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-floor": true, className: classNames?.floor, children: resource.floor })
|
|
12518
|
-
] })
|
|
12519
|
-
] })
|
|
12520
|
-
]
|
|
12521
|
-
},
|
|
12522
|
-
resource.id
|
|
12523
|
-
);
|
|
12524
|
-
})
|
|
12525
|
-
]
|
|
12526
|
-
}
|
|
12527
|
-
);
|
|
12528
|
-
}
|
|
12529
12883
|
function ChatWidget({
|
|
12530
12884
|
client: clientProp,
|
|
12531
12885
|
businessName = "Support",
|
|
@@ -13027,6 +13381,8 @@ exports.AvailabilityBadge = AvailabilityBadge;
|
|
|
13027
13381
|
exports.BillingPlanSelector = BillingPlanSelector;
|
|
13028
13382
|
exports.BookingCard = BookingCard;
|
|
13029
13383
|
exports.BookingList = BookingList;
|
|
13384
|
+
exports.BookingPage = BookingPage;
|
|
13385
|
+
exports.BookingsPage = BookingsPage;
|
|
13030
13386
|
exports.BundleProductCard = BundleProductCard;
|
|
13031
13387
|
exports.BundleProductLayout = BundleProductLayout;
|
|
13032
13388
|
exports.BundleSelector = BundleSelector;
|