@cimplify/sdk 0.20.2 → 0.22.0
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 +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-WXFEO3LT.js → chunk-A7IQN5EK.js} +17 -17
- package/dist/{chunk-VTMRPTQ7.mjs → chunk-R4EYMPSN.mjs} +39 -0
- package/dist/{chunk-UVBJDWIV.js → chunk-VYSXEDBV.js} +39 -0
- package/dist/{chunk-X23RNZAD.mjs → chunk-W3DMONZR.mjs} +1 -1
- package/dist/{client-D4E9aJy7.d.mts → client-uvCOGdBp.d.ts} +24 -2
- package/dist/{client-VyO6Bqz2.d.ts → client-v1NFqZFG.d.mts} +24 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +58 -58
- package/dist/index.mjs +2 -2
- package/dist/{payment-CKqMU4xT.d.ts → payment-DazihbCY.d.mts} +1 -0
- package/dist/{payment-CKqMU4xT.d.mts → payment-DazihbCY.d.ts} +1 -0
- package/dist/{price-e4beObLZ.d.ts → price-5_L8WK6Q.d.ts} +1 -1
- package/dist/{price-BqV_DjjQ.d.mts → price-BcHVTqqu.d.mts} +1 -1
- package/dist/react.d.mts +73 -9
- package/dist/react.d.ts +73 -9
- package/dist/react.js +329 -114
- package/dist/react.mjs +312 -99
- package/dist/styles.css +1 -1
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
- package/registry/booking-card.json +1 -1
- package/registry/booking-page.json +1 -1
- package/registry/order-detail-page.json +1 -1
- package/registry/order-history-page.json +1 -1
- package/registry/order-history.json +1 -1
- package/registry/order-summary.json +1 -1
- package/registry/product-card.json +1 -1
- package/registry/service-card.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkA7IQN5EK_js = require('./chunk-A7IQN5EK.js');
|
|
5
|
+
var chunkVYSXEDBV_js = require('./chunk-VYSXEDBV.js');
|
|
6
6
|
var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
|
|
7
7
|
var React3 = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -444,6 +444,9 @@ function buildLineKey(productId, options) {
|
|
|
444
444
|
if (options.staffId) {
|
|
445
445
|
parts.push(`st:${options.staffId}`);
|
|
446
446
|
}
|
|
447
|
+
if (options.resourceId) {
|
|
448
|
+
parts.push(`r:${options.resourceId}`);
|
|
449
|
+
}
|
|
447
450
|
return parts.join("|");
|
|
448
451
|
}
|
|
449
452
|
function calculateLineSubtotal(item) {
|
|
@@ -761,7 +764,8 @@ function createCartStore(params) {
|
|
|
761
764
|
composite_selections: normalizedOptions.compositeSelections,
|
|
762
765
|
scheduled_start: normalizedOptions.scheduledStart,
|
|
763
766
|
scheduled_end: normalizedOptions.scheduledEnd,
|
|
764
|
-
staff_id: normalizedOptions.staffId
|
|
767
|
+
staff_id: normalizedOptions.staffId,
|
|
768
|
+
resource_id: normalizedOptions.resourceId
|
|
765
769
|
});
|
|
766
770
|
if (!result.ok) {
|
|
767
771
|
throw result.error;
|
|
@@ -892,6 +896,14 @@ function createCartStore(params) {
|
|
|
892
896
|
await initializePromise;
|
|
893
897
|
initializePromise = null;
|
|
894
898
|
}
|
|
899
|
+
async function reorder(orderId) {
|
|
900
|
+
const result = await client.cart.reorderFromOrder(orderId);
|
|
901
|
+
if (!result.ok) {
|
|
902
|
+
throw result.error;
|
|
903
|
+
}
|
|
904
|
+
await sync();
|
|
905
|
+
return result.value;
|
|
906
|
+
}
|
|
895
907
|
return {
|
|
896
908
|
subscribe(listener) {
|
|
897
909
|
listeners.add(listener);
|
|
@@ -907,7 +919,8 @@ function createCartStore(params) {
|
|
|
907
919
|
removeItem,
|
|
908
920
|
updateQuantity,
|
|
909
921
|
clearCart,
|
|
910
|
-
sync
|
|
922
|
+
sync,
|
|
923
|
+
reorder
|
|
911
924
|
};
|
|
912
925
|
}
|
|
913
926
|
function getStoreKey(client, locationId, isDemoMode) {
|
|
@@ -988,6 +1001,12 @@ function useCart(options = {}) {
|
|
|
988
1001
|
throw syncError;
|
|
989
1002
|
}
|
|
990
1003
|
}, [store]);
|
|
1004
|
+
const reorder = React3.useCallback(
|
|
1005
|
+
async (orderId) => {
|
|
1006
|
+
return store.reorder(orderId);
|
|
1007
|
+
},
|
|
1008
|
+
[store]
|
|
1009
|
+
);
|
|
991
1010
|
const itemCount = React3.useMemo(
|
|
992
1011
|
() => snapshot.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
993
1012
|
[snapshot.items]
|
|
@@ -1005,7 +1024,8 @@ function useCart(options = {}) {
|
|
|
1005
1024
|
removeItem,
|
|
1006
1025
|
updateQuantity,
|
|
1007
1026
|
clearCart,
|
|
1008
|
-
sync
|
|
1027
|
+
sync,
|
|
1028
|
+
reorder
|
|
1009
1029
|
};
|
|
1010
1030
|
}
|
|
1011
1031
|
var LOCATION_STORAGE_KEY = "cimplify_location_id";
|
|
@@ -1016,7 +1036,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1016
1036
|
function createDefaultClient() {
|
|
1017
1037
|
const processRef = globalThis.process;
|
|
1018
1038
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1019
|
-
return
|
|
1039
|
+
return chunkA7IQN5EK_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1020
1040
|
}
|
|
1021
1041
|
function getStoredLocationId() {
|
|
1022
1042
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -2008,6 +2028,7 @@ function useCategories(options = {}) {
|
|
|
2008
2028
|
}, [cacheKey, load]);
|
|
2009
2029
|
return { categories, isLoading, error, refetch };
|
|
2010
2030
|
}
|
|
2031
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "cancelled", "refunded"]);
|
|
2011
2032
|
var orderCache = /* @__PURE__ */ new Map();
|
|
2012
2033
|
var orderInflight = /* @__PURE__ */ new Map();
|
|
2013
2034
|
function buildOrderCacheKey(client, orderId) {
|
|
@@ -2024,6 +2045,9 @@ function useOrder(orderId, options = {}) {
|
|
|
2024
2045
|
const poll = options.poll ?? false;
|
|
2025
2046
|
const pollInterval = options.pollInterval ?? 5e3;
|
|
2026
2047
|
const requestIdRef = React3.useRef(0);
|
|
2048
|
+
const previousStatusRef = React3.useRef(null);
|
|
2049
|
+
const onStatusChangeRef = React3.useRef(options.onStatusChange);
|
|
2050
|
+
onStatusChangeRef.current = options.onStatusChange;
|
|
2027
2051
|
const cacheKey = React3.useMemo(
|
|
2028
2052
|
() => buildOrderCacheKey(client, normalizedOrderId),
|
|
2029
2053
|
[client, normalizedOrderId]
|
|
@@ -2074,6 +2098,12 @@ function useOrder(orderId, options = {}) {
|
|
|
2074
2098
|
if (nextRequestId === requestIdRef.current) {
|
|
2075
2099
|
setOrder(value);
|
|
2076
2100
|
setError(null);
|
|
2101
|
+
if (value && previousStatusRef.current !== null && previousStatusRef.current !== value.status) {
|
|
2102
|
+
onStatusChangeRef.current?.(previousStatusRef.current, value.status, value);
|
|
2103
|
+
}
|
|
2104
|
+
if (value) {
|
|
2105
|
+
previousStatusRef.current = value.status;
|
|
2106
|
+
}
|
|
2077
2107
|
}
|
|
2078
2108
|
} catch (loadError) {
|
|
2079
2109
|
if (nextRequestId === requestIdRef.current) {
|
|
@@ -2090,8 +2120,9 @@ function useOrder(orderId, options = {}) {
|
|
|
2090
2120
|
React3.useEffect(() => {
|
|
2091
2121
|
void load(false);
|
|
2092
2122
|
}, [load]);
|
|
2123
|
+
const isTerminal = order ? TERMINAL_STATUSES.has(order.status) : false;
|
|
2093
2124
|
React3.useEffect(() => {
|
|
2094
|
-
if (!poll || !enabled || normalizedOrderId.length === 0) {
|
|
2125
|
+
if (!poll || !enabled || normalizedOrderId.length === 0 || isTerminal) {
|
|
2095
2126
|
return;
|
|
2096
2127
|
}
|
|
2097
2128
|
const timer = window.setInterval(() => {
|
|
@@ -2100,12 +2131,12 @@ function useOrder(orderId, options = {}) {
|
|
|
2100
2131
|
return () => {
|
|
2101
2132
|
window.clearInterval(timer);
|
|
2102
2133
|
};
|
|
2103
|
-
}, [enabled, load, normalizedOrderId, poll, pollInterval]);
|
|
2134
|
+
}, [enabled, isTerminal, load, normalizedOrderId, poll, pollInterval]);
|
|
2104
2135
|
const refetch = React3.useCallback(async () => {
|
|
2105
2136
|
orderCache.delete(cacheKey);
|
|
2106
2137
|
await load(true);
|
|
2107
2138
|
}, [cacheKey, load]);
|
|
2108
|
-
return { order, isLoading, error, refetch };
|
|
2139
|
+
return { order, isLoading, error, refetch, isTerminal };
|
|
2109
2140
|
}
|
|
2110
2141
|
var LOCATION_STORAGE_KEY2 = "cimplify_location_id";
|
|
2111
2142
|
function readStoredLocationId() {
|
|
@@ -4462,6 +4493,7 @@ function useRecommendations(options = {}) {
|
|
|
4462
4493
|
return { recommendations, intent, isLoading, error, refetch };
|
|
4463
4494
|
}
|
|
4464
4495
|
var deliveryFeeCache = /* @__PURE__ */ new Map();
|
|
4496
|
+
var deliveryFeeInflight = /* @__PURE__ */ new Map();
|
|
4465
4497
|
function buildDeliveryFeeCacheKey(client, latitude, longitude, country) {
|
|
4466
4498
|
return JSON.stringify({
|
|
4467
4499
|
key: client.getPublicKey(),
|
|
@@ -4505,13 +4537,26 @@ function useDeliveryFee(options) {
|
|
|
4505
4537
|
setIsLoading(true);
|
|
4506
4538
|
const currentRequestId = ++requestIdRef.current;
|
|
4507
4539
|
try {
|
|
4508
|
-
const
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4540
|
+
const existing = deliveryFeeInflight.get(cacheKey);
|
|
4541
|
+
const promise = existing ?? (async () => {
|
|
4542
|
+
const result = await client.delivery.getFee(latitude, longitude, country);
|
|
4543
|
+
if (!result.ok) {
|
|
4544
|
+
throw result.error;
|
|
4545
|
+
}
|
|
4546
|
+
return result.value;
|
|
4547
|
+
})();
|
|
4548
|
+
if (!existing) {
|
|
4549
|
+
deliveryFeeInflight.set(
|
|
4550
|
+
cacheKey,
|
|
4551
|
+
promise.finally(() => {
|
|
4552
|
+
deliveryFeeInflight.delete(cacheKey);
|
|
4553
|
+
})
|
|
4554
|
+
);
|
|
4512
4555
|
}
|
|
4513
|
-
|
|
4514
|
-
|
|
4556
|
+
const value = await promise;
|
|
4557
|
+
if (currentRequestId !== requestIdRef.current) return;
|
|
4558
|
+
deliveryFeeCache.set(cacheKey, value);
|
|
4559
|
+
setFee(value);
|
|
4515
4560
|
} catch (loadError) {
|
|
4516
4561
|
if (currentRequestId !== requestIdRef.current) return;
|
|
4517
4562
|
setError(loadError);
|
|
@@ -4751,19 +4796,19 @@ function AuthElement({
|
|
|
4751
4796
|
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
4752
4797
|
React3.useEffect(() => {
|
|
4753
4798
|
if (!elements || !containerRef.current) return;
|
|
4754
|
-
const element = elements.create(
|
|
4799
|
+
const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
4755
4800
|
elementRef.current = element;
|
|
4756
|
-
element.on(
|
|
4801
|
+
element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4757
4802
|
element.on(
|
|
4758
|
-
|
|
4803
|
+
chunkVYSXEDBV_js.EVENT_TYPES.AUTHENTICATED,
|
|
4759
4804
|
(data) => onAuthenticatedRef.current?.(data)
|
|
4760
4805
|
);
|
|
4761
4806
|
element.on(
|
|
4762
|
-
|
|
4807
|
+
chunkVYSXEDBV_js.EVENT_TYPES.REQUIRES_OTP,
|
|
4763
4808
|
(data) => onRequiresOtpRef.current?.(data)
|
|
4764
4809
|
);
|
|
4765
4810
|
element.on(
|
|
4766
|
-
|
|
4811
|
+
chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
|
|
4767
4812
|
(data) => onErrorRef.current?.(data)
|
|
4768
4813
|
);
|
|
4769
4814
|
element.mount(containerRef.current);
|
|
@@ -4792,15 +4837,15 @@ function AddressElement({
|
|
|
4792
4837
|
}, [onReady, onChange, onError]);
|
|
4793
4838
|
React3.useEffect(() => {
|
|
4794
4839
|
if (!elements || !containerRef.current) return;
|
|
4795
|
-
const element = elements.create(
|
|
4840
|
+
const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
4796
4841
|
elementRef.current = element;
|
|
4797
|
-
element.on(
|
|
4842
|
+
element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4798
4843
|
element.on(
|
|
4799
|
-
|
|
4844
|
+
chunkVYSXEDBV_js.EVENT_TYPES.CHANGE,
|
|
4800
4845
|
(data) => onChangeRef.current?.(data)
|
|
4801
4846
|
);
|
|
4802
4847
|
element.on(
|
|
4803
|
-
|
|
4848
|
+
chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
|
|
4804
4849
|
(data) => onErrorRef.current?.(data)
|
|
4805
4850
|
);
|
|
4806
4851
|
element.mount(containerRef.current);
|
|
@@ -4830,15 +4875,15 @@ function PaymentElement({
|
|
|
4830
4875
|
}, [onReady, onChange, onError]);
|
|
4831
4876
|
React3.useEffect(() => {
|
|
4832
4877
|
if (!elements || !containerRef.current) return;
|
|
4833
|
-
const element = elements.create(
|
|
4878
|
+
const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
4834
4879
|
elementRef.current = element;
|
|
4835
|
-
element.on(
|
|
4880
|
+
element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
4836
4881
|
element.on(
|
|
4837
|
-
|
|
4882
|
+
chunkVYSXEDBV_js.EVENT_TYPES.CHANGE,
|
|
4838
4883
|
(data) => onChangeRef.current?.(data)
|
|
4839
4884
|
);
|
|
4840
4885
|
element.on(
|
|
4841
|
-
|
|
4886
|
+
chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
|
|
4842
4887
|
(data) => onErrorRef.current?.(data)
|
|
4843
4888
|
);
|
|
4844
4889
|
element.mount(containerRef.current);
|
|
@@ -5101,7 +5146,7 @@ function VariantSelector({
|
|
|
5101
5146
|
{
|
|
5102
5147
|
"data-cimplify-variant-name": true,
|
|
5103
5148
|
className: cn("flex-1 min-w-0 text-sm", classNames?.name),
|
|
5104
|
-
children:
|
|
5149
|
+
children: chunkA7IQN5EK_js.getVariantDisplayName(variant, productName)
|
|
5105
5150
|
}
|
|
5106
5151
|
),
|
|
5107
5152
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
|
|
@@ -6415,7 +6460,7 @@ function CartLineItemRow({
|
|
|
6415
6460
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, className: classNames?.item, children: [
|
|
6416
6461
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
|
|
6417
6462
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
|
|
6418
|
-
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children:
|
|
6463
|
+
item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkA7IQN5EK_js.getVariantDisplayName(item.variant, item.product.name) }),
|
|
6419
6464
|
item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
|
|
6420
6465
|
"+ ",
|
|
6421
6466
|
item.addOnOptions.map((opt) => opt.name).join(", ")
|
|
@@ -6855,11 +6900,8 @@ function ProductCard({
|
|
|
6855
6900
|
"div",
|
|
6856
6901
|
{
|
|
6857
6902
|
"data-cimplify-product-card-image-container": true,
|
|
6858
|
-
className: classNames?.imageContainer,
|
|
6859
|
-
style:
|
|
6860
|
-
overflow: "hidden",
|
|
6861
|
-
...ASPECT_STYLES2[aspectRatio]
|
|
6862
|
-
},
|
|
6903
|
+
className: cn("overflow-hidden rounded-t-xl", classNames?.imageContainer),
|
|
6904
|
+
style: ASPECT_STYLES2[aspectRatio],
|
|
6863
6905
|
children: renderImage ? renderImage({
|
|
6864
6906
|
src: imageUrl,
|
|
6865
6907
|
alt: product.name,
|
|
@@ -6869,8 +6911,7 @@ function ProductCard({
|
|
|
6869
6911
|
{
|
|
6870
6912
|
src: imageUrl,
|
|
6871
6913
|
alt: product.name,
|
|
6872
|
-
className: classNames?.image,
|
|
6873
|
-
style: { width: "100%", height: "100%", objectFit: "cover" },
|
|
6914
|
+
className: cn("w-full h-full object-cover transition-transform duration-300 group-hover:scale-105", classNames?.image),
|
|
6874
6915
|
"data-cimplify-product-card-image": true
|
|
6875
6916
|
}
|
|
6876
6917
|
)
|
|
@@ -6880,13 +6921,13 @@ function ProductCard({
|
|
|
6880
6921
|
"div",
|
|
6881
6922
|
{
|
|
6882
6923
|
"data-cimplify-product-card-body": true,
|
|
6883
|
-
className: classNames?.body,
|
|
6924
|
+
className: cn("p-4 flex flex-col gap-1", classNames?.body),
|
|
6884
6925
|
children: [
|
|
6885
6926
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6886
6927
|
"span",
|
|
6887
6928
|
{
|
|
6888
6929
|
"data-cimplify-product-card-name": true,
|
|
6889
|
-
className: classNames?.name,
|
|
6930
|
+
className: cn("font-semibold text-foreground leading-tight", classNames?.name),
|
|
6890
6931
|
children: product.name
|
|
6891
6932
|
}
|
|
6892
6933
|
),
|
|
@@ -6894,13 +6935,7 @@ function ProductCard({
|
|
|
6894
6935
|
"span",
|
|
6895
6936
|
{
|
|
6896
6937
|
"data-cimplify-product-card-description": true,
|
|
6897
|
-
className: classNames?.description,
|
|
6898
|
-
style: {
|
|
6899
|
-
display: "-webkit-box",
|
|
6900
|
-
WebkitLineClamp: 2,
|
|
6901
|
-
WebkitBoxOrient: "vertical",
|
|
6902
|
-
overflow: "hidden"
|
|
6903
|
-
},
|
|
6938
|
+
className: cn("text-sm text-muted-foreground line-clamp-2", classNames?.description),
|
|
6904
6939
|
children: product.description
|
|
6905
6940
|
}
|
|
6906
6941
|
),
|
|
@@ -6908,7 +6943,7 @@ function ProductCard({
|
|
|
6908
6943
|
Price,
|
|
6909
6944
|
{
|
|
6910
6945
|
amount: product.default_price,
|
|
6911
|
-
className: classNames?.price
|
|
6946
|
+
className: cn("text-sm font-medium text-foreground mt-1", classNames?.price)
|
|
6912
6947
|
}
|
|
6913
6948
|
)
|
|
6914
6949
|
]
|
|
@@ -6917,7 +6952,7 @@ function ProductCard({
|
|
|
6917
6952
|
] });
|
|
6918
6953
|
if (mode === "page") {
|
|
6919
6954
|
const linkHref = href ?? `/menu/${product.slug}`;
|
|
6920
|
-
const linkClassName = cn("block no-underline text-[inherit]", className, classNames?.root);
|
|
6955
|
+
const linkClassName = cn("group block no-underline text-[inherit] rounded-xl border border-border bg-background transition-shadow duration-200 hover:shadow-md", className, classNames?.root);
|
|
6921
6956
|
if (renderLink) {
|
|
6922
6957
|
return renderLink({ href: linkHref, className: linkClassName, children: cardBody });
|
|
6923
6958
|
}
|
|
@@ -6940,7 +6975,7 @@ function ProductCard({
|
|
|
6940
6975
|
"data-cimplify-product-card": true,
|
|
6941
6976
|
"data-display-mode": "card",
|
|
6942
6977
|
className: cn(
|
|
6943
|
-
"block w-full text-left
|
|
6978
|
+
"group block w-full text-left p-0 cursor-pointer font-[inherit] text-[inherit] rounded-xl border border-border bg-background transition-shadow duration-200 hover:shadow-md",
|
|
6944
6979
|
className,
|
|
6945
6980
|
classNames?.root
|
|
6946
6981
|
),
|
|
@@ -7523,12 +7558,15 @@ function OrderSummary({
|
|
|
7523
7558
|
orderId,
|
|
7524
7559
|
poll = false,
|
|
7525
7560
|
renderLineItem,
|
|
7561
|
+
onReorder,
|
|
7562
|
+
onStatusChange,
|
|
7526
7563
|
className,
|
|
7527
7564
|
classNames
|
|
7528
7565
|
}) {
|
|
7529
7566
|
const { order: fetched, isLoading } = useOrder(orderProp ? null : orderId, {
|
|
7530
7567
|
enabled: !orderProp && !!orderId,
|
|
7531
|
-
poll
|
|
7568
|
+
poll,
|
|
7569
|
+
onStatusChange
|
|
7532
7570
|
});
|
|
7533
7571
|
const order = orderProp ?? fetched;
|
|
7534
7572
|
if (isLoading && !order) {
|
|
@@ -7694,6 +7732,16 @@ function OrderSummary({
|
|
|
7694
7732
|
className: classNames?.trackingLink,
|
|
7695
7733
|
children: "Track your order"
|
|
7696
7734
|
}
|
|
7735
|
+
),
|
|
7736
|
+
onReorder && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7737
|
+
"button",
|
|
7738
|
+
{
|
|
7739
|
+
type: "button",
|
|
7740
|
+
onClick: () => onReorder(order),
|
|
7741
|
+
"data-cimplify-order-reorder": true,
|
|
7742
|
+
className: classNames?.reorderButton,
|
|
7743
|
+
children: "Reorder"
|
|
7744
|
+
}
|
|
7697
7745
|
)
|
|
7698
7746
|
] });
|
|
7699
7747
|
}
|
|
@@ -7717,6 +7765,7 @@ function OrderHistory({
|
|
|
7717
7765
|
limit,
|
|
7718
7766
|
onOrderClick,
|
|
7719
7767
|
renderOrder,
|
|
7768
|
+
onReorder,
|
|
7720
7769
|
emptyMessage = "No orders yet",
|
|
7721
7770
|
className,
|
|
7722
7771
|
classNames
|
|
@@ -7788,7 +7837,20 @@ function OrderHistory({
|
|
|
7788
7837
|
order.total_quantity === 1 ? "item" : "items"
|
|
7789
7838
|
] }),
|
|
7790
7839
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-order-history-total": true, className: classNames?.total, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_price }) })
|
|
7791
|
-
] })
|
|
7840
|
+
] }),
|
|
7841
|
+
onReorder && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7842
|
+
"button",
|
|
7843
|
+
{
|
|
7844
|
+
type: "button",
|
|
7845
|
+
onClick: (e) => {
|
|
7846
|
+
e.stopPropagation();
|
|
7847
|
+
onReorder(order);
|
|
7848
|
+
},
|
|
7849
|
+
"data-cimplify-order-reorder": true,
|
|
7850
|
+
className: classNames?.reorderButton,
|
|
7851
|
+
children: "Reorder"
|
|
7852
|
+
}
|
|
7853
|
+
)
|
|
7792
7854
|
] })
|
|
7793
7855
|
},
|
|
7794
7856
|
order.id
|
|
@@ -8247,10 +8309,14 @@ function BookingCard({
|
|
|
8247
8309
|
{
|
|
8248
8310
|
"data-cimplify-booking-card": true,
|
|
8249
8311
|
"data-status": booking.status,
|
|
8250
|
-
className: cn(
|
|
8312
|
+
className: cn(
|
|
8313
|
+
"rounded-xl border border-border bg-background p-4 flex flex-col gap-3",
|
|
8314
|
+
className,
|
|
8315
|
+
classNames?.root
|
|
8316
|
+
),
|
|
8251
8317
|
children: [
|
|
8252
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-main": true, children: [
|
|
8253
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-service": true, className: classNames?.service, children: [
|
|
8318
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-main": true, className: "flex items-center justify-between gap-2", children: [
|
|
8319
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-service": true, className: cn("font-semibold text-foreground", classNames?.service), children: [
|
|
8254
8320
|
"Booking #",
|
|
8255
8321
|
booking.order_id.slice(0, 8)
|
|
8256
8322
|
] }),
|
|
@@ -8259,22 +8325,37 @@ function BookingCard({
|
|
|
8259
8325
|
{
|
|
8260
8326
|
"data-cimplify-booking-status": true,
|
|
8261
8327
|
"data-status": booking.status,
|
|
8262
|
-
className:
|
|
8328
|
+
className: cn(
|
|
8329
|
+
"text-xs font-medium px-2 py-0.5 rounded-full",
|
|
8330
|
+
active ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground",
|
|
8331
|
+
classNames?.status
|
|
8332
|
+
),
|
|
8263
8333
|
children: STATUS_LABELS3[booking.status] ?? booking.status
|
|
8264
8334
|
}
|
|
8265
8335
|
)
|
|
8266
8336
|
] }),
|
|
8267
|
-
firstItem?.confirmation_code && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-code": true, className: classNames?.confirmationCode, children: firstItem.confirmation_code }),
|
|
8268
|
-
scheduledTime && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8269
|
-
|
|
8270
|
-
|
|
8337
|
+
firstItem?.confirmation_code && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-code": true, className: cn("text-xs font-mono text-muted-foreground tracking-wide", classNames?.confirmationCode), children: firstItem.confirmation_code }),
|
|
8338
|
+
scheduledTime && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8339
|
+
"time",
|
|
8340
|
+
{
|
|
8341
|
+
"data-cimplify-booking-time": true,
|
|
8342
|
+
dateTime: firstItem?.scheduled_start ?? void 0,
|
|
8343
|
+
className: cn("text-sm text-foreground", classNames?.time),
|
|
8344
|
+
children: scheduledTime
|
|
8345
|
+
}
|
|
8346
|
+
),
|
|
8347
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-total": true, className: cn("text-sm font-medium text-foreground", classNames?.total), children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: booking.total_price }) }),
|
|
8348
|
+
active && (onCancel || onReschedule) && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-actions": true, className: cn("flex gap-2 pt-1 border-t border-border mt-1", classNames?.actions), children: [
|
|
8271
8349
|
onReschedule && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8272
8350
|
"button",
|
|
8273
8351
|
{
|
|
8274
8352
|
type: "button",
|
|
8275
8353
|
onClick: () => onReschedule(booking),
|
|
8276
8354
|
"data-cimplify-booking-reschedule": true,
|
|
8277
|
-
className:
|
|
8355
|
+
className: cn(
|
|
8356
|
+
"flex-1 text-sm font-medium py-2 rounded-lg border border-border bg-background text-foreground transition-colors hover:bg-muted cursor-pointer",
|
|
8357
|
+
classNames?.rescheduleButton
|
|
8358
|
+
),
|
|
8278
8359
|
children: "Reschedule"
|
|
8279
8360
|
}
|
|
8280
8361
|
),
|
|
@@ -8284,7 +8365,10 @@ function BookingCard({
|
|
|
8284
8365
|
type: "button",
|
|
8285
8366
|
onClick: () => onCancel(booking),
|
|
8286
8367
|
"data-cimplify-booking-cancel": true,
|
|
8287
|
-
className:
|
|
8368
|
+
className: cn(
|
|
8369
|
+
"flex-1 text-sm font-medium py-2 rounded-lg border border-border bg-background text-destructive transition-colors hover:bg-destructive/10 cursor-pointer",
|
|
8370
|
+
classNames?.cancelButton
|
|
8371
|
+
),
|
|
8288
8372
|
children: "Cancel"
|
|
8289
8373
|
}
|
|
8290
8374
|
)
|
|
@@ -8397,11 +8481,8 @@ function ServiceCard({
|
|
|
8397
8481
|
"div",
|
|
8398
8482
|
{
|
|
8399
8483
|
"data-cimplify-service-card-image-container": true,
|
|
8400
|
-
className: classNames?.imageContainer,
|
|
8401
|
-
style:
|
|
8402
|
-
overflow: "hidden",
|
|
8403
|
-
...ASPECT_STYLES3[aspectRatio]
|
|
8404
|
-
},
|
|
8484
|
+
className: cn("overflow-hidden rounded-t-xl", classNames?.imageContainer),
|
|
8485
|
+
style: ASPECT_STYLES3[aspectRatio],
|
|
8405
8486
|
children: renderImage ? renderImage({
|
|
8406
8487
|
src: imageUrl,
|
|
8407
8488
|
alt: service.name,
|
|
@@ -8411,36 +8492,35 @@ function ServiceCard({
|
|
|
8411
8492
|
{
|
|
8412
8493
|
src: imageUrl,
|
|
8413
8494
|
alt: service.name,
|
|
8414
|
-
className: classNames?.image,
|
|
8415
|
-
style: { width: "100%", height: "100%", objectFit: "cover" },
|
|
8495
|
+
className: cn("w-full h-full object-cover transition-transform duration-300 group-hover:scale-105", classNames?.image),
|
|
8416
8496
|
"data-cimplify-service-card-image": true
|
|
8417
8497
|
}
|
|
8418
8498
|
)
|
|
8419
8499
|
}
|
|
8420
8500
|
),
|
|
8421
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-service-card-body": true, className: classNames?.body, children: [
|
|
8422
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-name": true, className: classNames?.name, children: service.name }),
|
|
8501
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-service-card-body": true, className: cn("p-4 flex flex-col gap-1.5", classNames?.body), children: [
|
|
8502
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-name": true, className: cn("font-semibold text-foreground leading-tight", classNames?.name), children: service.name }),
|
|
8423
8503
|
service.description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8424
8504
|
"span",
|
|
8425
8505
|
{
|
|
8426
8506
|
"data-cimplify-service-card-description": true,
|
|
8427
|
-
className: classNames?.description,
|
|
8428
|
-
style: {
|
|
8429
|
-
display: "-webkit-box",
|
|
8430
|
-
WebkitLineClamp: 2,
|
|
8431
|
-
WebkitBoxOrient: "vertical",
|
|
8432
|
-
overflow: "hidden"
|
|
8433
|
-
},
|
|
8507
|
+
className: cn("text-sm text-muted-foreground line-clamp-2", classNames?.description),
|
|
8434
8508
|
children: service.description
|
|
8435
8509
|
}
|
|
8436
8510
|
),
|
|
8437
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-service-card-meta": true, className: classNames?.meta, children: [
|
|
8438
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-duration": true, className: classNames?.duration, children: formatDuration2(service.duration_minutes, service.duration_unit) }),
|
|
8439
|
-
service.price && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-price": true, className: classNames?.price, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: service.price }) })
|
|
8511
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-service-card-meta": true, className: cn("flex items-center gap-2 mt-1 text-sm", classNames?.meta), children: [
|
|
8512
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-duration": true, className: cn("text-muted-foreground", classNames?.duration), children: formatDuration2(service.duration_minutes, service.duration_unit) }),
|
|
8513
|
+
service.price && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-price": true, className: cn("font-medium text-foreground", classNames?.price), children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: service.price }) })
|
|
8440
8514
|
] })
|
|
8441
8515
|
] }),
|
|
8442
|
-
!href && onBook && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-action": true, className: classNames?.action, children: actionLabel })
|
|
8516
|
+
!href && onBook && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-service-card-action": true, className: cn("px-4 pb-4 pt-1 text-sm font-medium text-primary", classNames?.action), children: actionLabel })
|
|
8443
8517
|
] });
|
|
8518
|
+
const cardClasses = cn(
|
|
8519
|
+
"group block w-full rounded-xl border border-border bg-background text-left transition-shadow duration-200 hover:shadow-md",
|
|
8520
|
+
!service.is_available && "opacity-60",
|
|
8521
|
+
className,
|
|
8522
|
+
classNames?.root
|
|
8523
|
+
);
|
|
8444
8524
|
if (href) {
|
|
8445
8525
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8446
8526
|
"a",
|
|
@@ -8448,8 +8528,7 @@ function ServiceCard({
|
|
|
8448
8528
|
href,
|
|
8449
8529
|
"data-cimplify-service-card": true,
|
|
8450
8530
|
"data-available": service.is_available || void 0,
|
|
8451
|
-
className: cn(
|
|
8452
|
-
style: { display: "block", textDecoration: "none", color: "inherit" },
|
|
8531
|
+
className: cn(cardClasses, "no-underline text-[inherit]"),
|
|
8453
8532
|
children: cardBody
|
|
8454
8533
|
}
|
|
8455
8534
|
);
|
|
@@ -8462,18 +8541,7 @@ function ServiceCard({
|
|
|
8462
8541
|
disabled: !service.is_available,
|
|
8463
8542
|
"data-cimplify-service-card": true,
|
|
8464
8543
|
"data-available": service.is_available || void 0,
|
|
8465
|
-
className: cn(
|
|
8466
|
-
style: {
|
|
8467
|
-
display: "block",
|
|
8468
|
-
width: "100%",
|
|
8469
|
-
textAlign: "inherit",
|
|
8470
|
-
background: "none",
|
|
8471
|
-
border: "none",
|
|
8472
|
-
padding: 0,
|
|
8473
|
-
cursor: service.is_available ? "pointer" : "default",
|
|
8474
|
-
font: "inherit",
|
|
8475
|
-
color: "inherit"
|
|
8476
|
-
},
|
|
8544
|
+
className: cn(cardClasses, "cursor-pointer font-[inherit] p-0 border-border"),
|
|
8477
8545
|
children: cardBody
|
|
8478
8546
|
}
|
|
8479
8547
|
);
|
|
@@ -8980,6 +9048,8 @@ function OrderDetailPage({
|
|
|
8980
9048
|
poll = true,
|
|
8981
9049
|
onBack,
|
|
8982
9050
|
renderLineItem,
|
|
9051
|
+
onReorder,
|
|
9052
|
+
onStatusChange,
|
|
8983
9053
|
backLabel = "Back to orders",
|
|
8984
9054
|
className,
|
|
8985
9055
|
classNames
|
|
@@ -9004,7 +9074,9 @@ function OrderDetailPage({
|
|
|
9004
9074
|
order,
|
|
9005
9075
|
orderId: order ? void 0 : orderId,
|
|
9006
9076
|
poll,
|
|
9007
|
-
renderLineItem
|
|
9077
|
+
renderLineItem,
|
|
9078
|
+
onReorder,
|
|
9079
|
+
onStatusChange
|
|
9008
9080
|
}
|
|
9009
9081
|
) })
|
|
9010
9082
|
] });
|
|
@@ -9020,6 +9092,7 @@ function OrderHistoryPage({
|
|
|
9020
9092
|
orders: ordersProp,
|
|
9021
9093
|
limit = 20,
|
|
9022
9094
|
onOrderNavigate,
|
|
9095
|
+
onReorder,
|
|
9023
9096
|
showFilters = true,
|
|
9024
9097
|
renderOrder,
|
|
9025
9098
|
className,
|
|
@@ -9057,7 +9130,7 @@ function OrderHistoryPage({
|
|
|
9057
9130
|
children: "Back to orders"
|
|
9058
9131
|
}
|
|
9059
9132
|
),
|
|
9060
|
-
/* @__PURE__ */ jsxRuntime.jsx(OrderSummary, { order: selectedOrder })
|
|
9133
|
+
/* @__PURE__ */ jsxRuntime.jsx(OrderSummary, { order: selectedOrder, onReorder })
|
|
9061
9134
|
] }) });
|
|
9062
9135
|
}
|
|
9063
9136
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-history-page": true, className: cn(className, classNames?.root), children: [
|
|
@@ -9080,7 +9153,8 @@ function OrderHistoryPage({
|
|
|
9080
9153
|
status: statusFilter,
|
|
9081
9154
|
limit,
|
|
9082
9155
|
onOrderClick: handleOrderClick,
|
|
9083
|
-
renderOrder
|
|
9156
|
+
renderOrder,
|
|
9157
|
+
onReorder
|
|
9084
9158
|
}
|
|
9085
9159
|
) })
|
|
9086
9160
|
] });
|
|
@@ -9203,10 +9277,114 @@ function DealsPage({
|
|
|
9203
9277
|
isEmpty && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-deals-empty": true, className: classNames?.empty, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "No deals available right now. Check back soon!" }) })
|
|
9204
9278
|
] });
|
|
9205
9279
|
}
|
|
9280
|
+
var ANY_VALUE2 = "__any__";
|
|
9281
|
+
function roomToResource(room) {
|
|
9282
|
+
return {
|
|
9283
|
+
id: room.id,
|
|
9284
|
+
name: room.name,
|
|
9285
|
+
capacity: room.capacity,
|
|
9286
|
+
floor: room.floor,
|
|
9287
|
+
is_available: room.status === "available"
|
|
9288
|
+
};
|
|
9289
|
+
}
|
|
9290
|
+
function ResourcePicker({
|
|
9291
|
+
resources,
|
|
9292
|
+
selectedResourceId,
|
|
9293
|
+
onResourceSelect,
|
|
9294
|
+
showAnyOption = true,
|
|
9295
|
+
anyLabel = "Any available",
|
|
9296
|
+
renderImage,
|
|
9297
|
+
className,
|
|
9298
|
+
classNames
|
|
9299
|
+
}) {
|
|
9300
|
+
const groupValue = selectedResourceId === null ? ANY_VALUE2 : selectedResourceId ?? "";
|
|
9301
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9302
|
+
radioGroup.RadioGroup,
|
|
9303
|
+
{
|
|
9304
|
+
"data-cimplify-resource-picker": true,
|
|
9305
|
+
className: cn("flex flex-col gap-2", className, classNames?.root),
|
|
9306
|
+
value: groupValue,
|
|
9307
|
+
onValueChange: (value) => {
|
|
9308
|
+
onResourceSelect?.(value === ANY_VALUE2 ? null : value);
|
|
9309
|
+
},
|
|
9310
|
+
children: [
|
|
9311
|
+
showAnyOption && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9312
|
+
radio.Radio.Root,
|
|
9313
|
+
{
|
|
9314
|
+
value: ANY_VALUE2,
|
|
9315
|
+
"data-cimplify-resource-option": true,
|
|
9316
|
+
"data-selected": selectedResourceId === null || void 0,
|
|
9317
|
+
"data-any": true,
|
|
9318
|
+
className: cn(
|
|
9319
|
+
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
9320
|
+
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
9321
|
+
classNames?.option
|
|
9322
|
+
),
|
|
9323
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: anyLabel })
|
|
9324
|
+
}
|
|
9325
|
+
),
|
|
9326
|
+
resources.map((resource) => {
|
|
9327
|
+
const unavailable = resource.is_available === false;
|
|
9328
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9329
|
+
radio.Radio.Root,
|
|
9330
|
+
{
|
|
9331
|
+
value: resource.id,
|
|
9332
|
+
disabled: unavailable,
|
|
9333
|
+
"data-cimplify-resource-option": true,
|
|
9334
|
+
"data-selected": selectedResourceId === resource.id || void 0,
|
|
9335
|
+
"data-unavailable": unavailable || void 0,
|
|
9336
|
+
className: cn(
|
|
9337
|
+
"flex items-center gap-3 rounded-lg border border-border p-3 transition-colors cursor-pointer",
|
|
9338
|
+
"hover:bg-muted data-[checked]:border-primary data-[checked]:bg-primary/5",
|
|
9339
|
+
unavailable && "opacity-50 cursor-not-allowed",
|
|
9340
|
+
classNames?.option,
|
|
9341
|
+
unavailable ? classNames?.unavailable : void 0
|
|
9342
|
+
),
|
|
9343
|
+
children: [
|
|
9344
|
+
resource.image_url && (renderImage ? renderImage({
|
|
9345
|
+
src: resource.image_url,
|
|
9346
|
+
alt: resource.name,
|
|
9347
|
+
className: classNames?.image
|
|
9348
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
9349
|
+
"img",
|
|
9350
|
+
{
|
|
9351
|
+
src: resource.image_url,
|
|
9352
|
+
alt: resource.name,
|
|
9353
|
+
"data-cimplify-resource-image": true,
|
|
9354
|
+
className: cn("w-10 h-10 rounded-lg object-cover", classNames?.image)
|
|
9355
|
+
}
|
|
9356
|
+
)),
|
|
9357
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [
|
|
9358
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-name": true, className: cn("font-medium text-foreground", classNames?.name), children: resource.name }),
|
|
9359
|
+
resource.description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-description": true, className: cn("text-sm text-muted-foreground truncate", classNames?.description), children: resource.description }),
|
|
9360
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-resource-meta": true, className: cn("flex items-center gap-2 text-xs text-muted-foreground", classNames?.meta), children: [
|
|
9361
|
+
resource.capacity !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-resource-capacity": true, className: classNames?.capacity, children: [
|
|
9362
|
+
"Up to ",
|
|
9363
|
+
resource.capacity
|
|
9364
|
+
] }),
|
|
9365
|
+
resource.floor && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-resource-floor": true, className: classNames?.floor, children: resource.floor })
|
|
9366
|
+
] })
|
|
9367
|
+
] })
|
|
9368
|
+
]
|
|
9369
|
+
},
|
|
9370
|
+
resource.id
|
|
9371
|
+
);
|
|
9372
|
+
})
|
|
9373
|
+
]
|
|
9374
|
+
}
|
|
9375
|
+
);
|
|
9376
|
+
}
|
|
9377
|
+
var STEP = {
|
|
9378
|
+
SELECT_SLOT: "select-slot",
|
|
9379
|
+
SELECT_RESOURCE: "select-resource",
|
|
9380
|
+
SELECT_STAFF: "select-staff",
|
|
9381
|
+
CONFIRM: "confirm"
|
|
9382
|
+
};
|
|
9206
9383
|
function BookingPage({
|
|
9207
9384
|
service,
|
|
9208
9385
|
product,
|
|
9209
9386
|
staff,
|
|
9387
|
+
resources,
|
|
9210
9388
|
participantCount,
|
|
9211
9389
|
title,
|
|
9212
9390
|
onBooked,
|
|
@@ -9220,12 +9398,14 @@ function BookingPage({
|
|
|
9220
9398
|
const { addItem } = useCart();
|
|
9221
9399
|
const { client } = useCimplifyClient();
|
|
9222
9400
|
const isReschedule = existingBooking !== void 0;
|
|
9223
|
-
const [step, setStep] = React3.useState(
|
|
9401
|
+
const [step, setStep] = React3.useState(STEP.SELECT_SLOT);
|
|
9224
9402
|
const [selectedSlot, setSelectedSlot] = React3.useState(null);
|
|
9225
9403
|
const [selectedDate, setSelectedDate] = React3.useState(null);
|
|
9226
9404
|
const [selectedStaffId, setSelectedStaffId] = React3.useState(null);
|
|
9405
|
+
const [selectedResourceId, setSelectedResourceId] = React3.useState(null);
|
|
9227
9406
|
const [isSubmitting, setIsSubmitting] = React3.useState(false);
|
|
9228
9407
|
const [error, setError] = React3.useState(null);
|
|
9408
|
+
const hasResourceStep = resources && resources.length > 0;
|
|
9229
9409
|
const hasStaffStep = staff && staff.length > 0;
|
|
9230
9410
|
const depositType = product?.deposit_type;
|
|
9231
9411
|
const depositAmount = product?.deposit_amount;
|
|
@@ -9237,28 +9417,45 @@ function BookingPage({
|
|
|
9237
9417
|
setSelectedSlot(slot);
|
|
9238
9418
|
setSelectedDate(date);
|
|
9239
9419
|
setError(null);
|
|
9420
|
+
if (hasResourceStep) {
|
|
9421
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9422
|
+
} else if (hasStaffStep) {
|
|
9423
|
+
setStep(STEP.SELECT_STAFF);
|
|
9424
|
+
} else {
|
|
9425
|
+
setStep(STEP.CONFIRM);
|
|
9426
|
+
}
|
|
9427
|
+
},
|
|
9428
|
+
[hasResourceStep, hasStaffStep]
|
|
9429
|
+
);
|
|
9430
|
+
const handleResourceSelect = React3.useCallback(
|
|
9431
|
+
(resourceId) => {
|
|
9432
|
+
setSelectedResourceId(resourceId);
|
|
9240
9433
|
if (hasStaffStep) {
|
|
9241
|
-
setStep(
|
|
9434
|
+
setStep(STEP.SELECT_STAFF);
|
|
9242
9435
|
} else {
|
|
9243
|
-
setStep(
|
|
9436
|
+
setStep(STEP.CONFIRM);
|
|
9244
9437
|
}
|
|
9245
9438
|
},
|
|
9246
9439
|
[hasStaffStep]
|
|
9247
9440
|
);
|
|
9248
9441
|
const handleStaffSelect = React3.useCallback((staffId) => {
|
|
9249
9442
|
setSelectedStaffId(staffId);
|
|
9250
|
-
setStep(
|
|
9443
|
+
setStep(STEP.CONFIRM);
|
|
9251
9444
|
}, []);
|
|
9252
9445
|
const handleBack = React3.useCallback(() => {
|
|
9253
9446
|
setError(null);
|
|
9254
|
-
if (step ===
|
|
9255
|
-
setStep(
|
|
9256
|
-
} else if (step ===
|
|
9257
|
-
setStep(
|
|
9447
|
+
if (step === STEP.CONFIRM && hasStaffStep) {
|
|
9448
|
+
setStep(STEP.SELECT_STAFF);
|
|
9449
|
+
} else if (step === STEP.CONFIRM && hasResourceStep) {
|
|
9450
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9451
|
+
} else if (step === STEP.SELECT_STAFF && hasResourceStep) {
|
|
9452
|
+
setStep(STEP.SELECT_RESOURCE);
|
|
9453
|
+
} else if (step === STEP.CONFIRM || step === STEP.SELECT_STAFF || step === STEP.SELECT_RESOURCE) {
|
|
9454
|
+
setStep(STEP.SELECT_SLOT);
|
|
9258
9455
|
} else {
|
|
9259
9456
|
onBack?.();
|
|
9260
9457
|
}
|
|
9261
|
-
}, [step, hasStaffStep, onBack]);
|
|
9458
|
+
}, [step, hasStaffStep, hasResourceStep, onBack]);
|
|
9262
9459
|
const handleConfirm = React3.useCallback(async () => {
|
|
9263
9460
|
if (!selectedSlot || !selectedDate) return;
|
|
9264
9461
|
setIsSubmitting(true);
|
|
@@ -9298,7 +9495,8 @@ function BookingPage({
|
|
|
9298
9495
|
await addItem(serviceProduct, 1, {
|
|
9299
9496
|
scheduledStart: selectedSlot.start_time,
|
|
9300
9497
|
scheduledEnd: selectedSlot.end_time,
|
|
9301
|
-
staffId: selectedStaffId || void 0
|
|
9498
|
+
staffId: selectedStaffId || void 0,
|
|
9499
|
+
resourceId: selectedResourceId || void 0
|
|
9302
9500
|
});
|
|
9303
9501
|
onBooked?.(selectedSlot, selectedStaffId);
|
|
9304
9502
|
}
|
|
@@ -9311,7 +9509,7 @@ function BookingPage({
|
|
|
9311
9509
|
}, [selectedSlot, selectedDate, selectedStaffId, service, addItem, onBooked, isReschedule, existingBooking, client, onRescheduled]);
|
|
9312
9510
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-page": true, className: cn(className, classNames?.root), children: [
|
|
9313
9511
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-page-header": true, className: classNames?.header, children: [
|
|
9314
|
-
onBack && step ===
|
|
9512
|
+
onBack && step === STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9315
9513
|
"button",
|
|
9316
9514
|
{
|
|
9317
9515
|
type: "button",
|
|
@@ -9321,7 +9519,7 @@ function BookingPage({
|
|
|
9321
9519
|
children: "Back"
|
|
9322
9520
|
}
|
|
9323
9521
|
),
|
|
9324
|
-
step !==
|
|
9522
|
+
step !== STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9325
9523
|
"button",
|
|
9326
9524
|
{
|
|
9327
9525
|
type: "button",
|
|
@@ -9356,7 +9554,7 @@ function BookingPage({
|
|
|
9356
9554
|
] })
|
|
9357
9555
|
] }),
|
|
9358
9556
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-booking-error": true, className: classNames?.error, children: error }),
|
|
9359
|
-
step ===
|
|
9557
|
+
step === STEP.SELECT_SLOT && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-slot", className: classNames?.step, children: [
|
|
9360
9558
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Select a date & time" }),
|
|
9361
9559
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9362
9560
|
DateSlotPicker,
|
|
@@ -9369,7 +9567,18 @@ function BookingPage({
|
|
|
9369
9567
|
}
|
|
9370
9568
|
)
|
|
9371
9569
|
] }),
|
|
9372
|
-
step ===
|
|
9570
|
+
step === STEP.SELECT_RESOURCE && resources && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-resource", className: cn(classNames?.step, classNames?.resourceStep), children: [
|
|
9571
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Choose a room" }),
|
|
9572
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9573
|
+
ResourcePicker,
|
|
9574
|
+
{
|
|
9575
|
+
resources,
|
|
9576
|
+
selectedResourceId,
|
|
9577
|
+
onResourceSelect: handleResourceSelect
|
|
9578
|
+
}
|
|
9579
|
+
)
|
|
9580
|
+
] }),
|
|
9581
|
+
step === STEP.SELECT_STAFF && staff && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "select-staff", className: classNames?.step, children: [
|
|
9373
9582
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Choose a provider" }),
|
|
9374
9583
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9375
9584
|
StaffPicker,
|
|
@@ -9380,7 +9589,7 @@ function BookingPage({
|
|
|
9380
9589
|
}
|
|
9381
9590
|
)
|
|
9382
9591
|
] }),
|
|
9383
|
-
step ===
|
|
9592
|
+
step === STEP.CONFIRM && selectedSlot && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-step": "confirm", className: classNames?.step, children: [
|
|
9384
9593
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { "data-cimplify-booking-step-title": true, className: classNames?.stepTitle, children: "Confirm your booking" }),
|
|
9385
9594
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary": true, className: classNames?.summary, children: [
|
|
9386
9595
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
@@ -9402,6 +9611,10 @@ function BookingPage({
|
|
|
9402
9611
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Duration" }),
|
|
9403
9612
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDuration2(service.duration_minutes, service.duration_unit) })
|
|
9404
9613
|
] }),
|
|
9614
|
+
selectedResourceId && resources && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9615
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Room" }),
|
|
9616
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: resources.find((r) => r.id === selectedResourceId)?.name ?? "Selected" })
|
|
9617
|
+
] }),
|
|
9405
9618
|
selectedStaffId && staff && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: classNames?.summaryRow, children: [
|
|
9406
9619
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Provider" }),
|
|
9407
9620
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: staff.find((s) => s.id === selectedStaffId)?.name ?? "Selected" })
|
|
@@ -9972,7 +10185,7 @@ function CurrencySelector({
|
|
|
9972
10185
|
|
|
9973
10186
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
9974
10187
|
enumerable: true,
|
|
9975
|
-
get: function () { return
|
|
10188
|
+
get: function () { return chunkA7IQN5EK_js.getVariantDisplayName; }
|
|
9976
10189
|
});
|
|
9977
10190
|
exports.Ad = Ad;
|
|
9978
10191
|
exports.AdProvider = AdProvider;
|
|
@@ -10019,6 +10232,7 @@ exports.ProductSheet = ProductSheet;
|
|
|
10019
10232
|
exports.QuantitySelector = QuantitySelector;
|
|
10020
10233
|
exports.RecentlyViewed = RecentlyViewed;
|
|
10021
10234
|
exports.RecommendationCarousel = RecommendationCarousel;
|
|
10235
|
+
exports.ResourcePicker = ResourcePicker;
|
|
10022
10236
|
exports.SaleBadge = SaleBadge;
|
|
10023
10237
|
exports.SearchInput = SearchInput;
|
|
10024
10238
|
exports.SearchPage = SearchPage;
|
|
@@ -10030,6 +10244,7 @@ exports.StaffPicker = StaffPicker;
|
|
|
10030
10244
|
exports.StoreNav = StoreNav;
|
|
10031
10245
|
exports.VariantSelector = VariantSelector;
|
|
10032
10246
|
exports.cn = cn;
|
|
10247
|
+
exports.roomToResource = roomToResource;
|
|
10033
10248
|
exports.useActivityState = useActivityState;
|
|
10034
10249
|
exports.useAds = useAds;
|
|
10035
10250
|
exports.useAttributeDefinitions = useAttributeDefinitions;
|