@anker-in/ui 0.3.2 → 0.3.4
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/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +247 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10853,7 +10853,9 @@ var QuestionnaireForm2 = ({
|
|
|
10853
10853
|
error,
|
|
10854
10854
|
initialResponses
|
|
10855
10855
|
}) => {
|
|
10856
|
-
const [responses, setResponses] = useState(
|
|
10856
|
+
const [responses, setResponses] = useState(
|
|
10857
|
+
() => initialResponses || {}
|
|
10858
|
+
);
|
|
10857
10859
|
const [errors, setErrors] = useState({});
|
|
10858
10860
|
const [agreements, setAgreements] = useState({});
|
|
10859
10861
|
const [agreementError, setAgreementError] = useState("");
|
|
@@ -10875,8 +10877,12 @@ var QuestionnaireForm2 = ({
|
|
|
10875
10877
|
});
|
|
10876
10878
|
return seeded;
|
|
10877
10879
|
});
|
|
10878
|
-
const prevHasBookedBeforeRef = useRef(
|
|
10879
|
-
|
|
10880
|
+
const prevHasBookedBeforeRef = useRef(
|
|
10881
|
+
initialResponses?.["has_booked_before"] === "option2"
|
|
10882
|
+
);
|
|
10883
|
+
const hasBookedBeforeInitialized = useRef(
|
|
10884
|
+
!!initialResponses?.["has_booked_before"]
|
|
10885
|
+
);
|
|
10880
10886
|
const hasBookedBeforeQuestion = questions.find(
|
|
10881
10887
|
(q) => (q.key || q.id) === "has_booked_before"
|
|
10882
10888
|
);
|
|
@@ -10966,7 +10972,7 @@ var QuestionnaireForm2 = ({
|
|
|
10966
10972
|
if (!emailRegex.test(value)) {
|
|
10967
10973
|
setErrors((prev) => ({
|
|
10968
10974
|
...prev,
|
|
10969
|
-
[questionId]: "Please enter a valid email address"
|
|
10975
|
+
[questionId]: pageData?.emailValidError || "Please enter a valid email address"
|
|
10970
10976
|
}));
|
|
10971
10977
|
}
|
|
10972
10978
|
};
|
|
@@ -11004,7 +11010,7 @@ var QuestionnaireForm2 = ({
|
|
|
11004
11010
|
const questionId = getQuestionId(question);
|
|
11005
11011
|
const value = responses[questionId];
|
|
11006
11012
|
if (!value || Array.isArray(value) && value.length === 0) {
|
|
11007
|
-
newErrors[questionId] = "This field is required";
|
|
11013
|
+
newErrors[questionId] = pageData?.fieldRuquired || "This field is required";
|
|
11008
11014
|
}
|
|
11009
11015
|
}
|
|
11010
11016
|
});
|
|
@@ -11015,7 +11021,7 @@ var QuestionnaireForm2 = ({
|
|
|
11015
11021
|
);
|
|
11016
11022
|
if (!allAgreed) {
|
|
11017
11023
|
setAgreementError(
|
|
11018
|
-
"Please agree to all terms and conditions to continue"
|
|
11024
|
+
pageData?.agreeRuquired || "Please agree to all terms and conditions to continue"
|
|
11019
11025
|
);
|
|
11020
11026
|
setErrors(newErrors);
|
|
11021
11027
|
return false;
|
|
@@ -11046,7 +11052,9 @@ var QuestionnaireForm2 = ({
|
|
|
11046
11052
|
onSubmit?.(finalResponses);
|
|
11047
11053
|
} else {
|
|
11048
11054
|
setTimeout(() => {
|
|
11049
|
-
const firstErrorElement = document.querySelector(
|
|
11055
|
+
const firstErrorElement = document.querySelector(
|
|
11056
|
+
'[data-has-error="true"]'
|
|
11057
|
+
);
|
|
11050
11058
|
if (firstErrorElement) {
|
|
11051
11059
|
firstErrorElement.scrollIntoView({
|
|
11052
11060
|
behavior: "smooth",
|
|
@@ -11402,7 +11410,7 @@ var QuestionnaireForm2 = ({
|
|
|
11402
11410
|
children: loading ? pageData?.submitting || "Submitting..." : pageData?.submit || "Submit Booking"
|
|
11403
11411
|
}
|
|
11404
11412
|
),
|
|
11405
|
-
error && /* @__PURE__ */ jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsx("p", { className: "text-[#FF4D4D] font-bold", children: error.message }) })
|
|
11413
|
+
error && /* @__PURE__ */ jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsx("p", { className: "text-[#FF4D4D] font-bold", children: pageData?.errorMsg?.[String(error.code)] || pageData?.errorMsg?.[error.code || ""] || error.message }) })
|
|
11406
11414
|
] })
|
|
11407
11415
|
] });
|
|
11408
11416
|
};
|
|
@@ -11499,6 +11507,25 @@ var DateTimePicker2 = ({
|
|
|
11499
11507
|
});
|
|
11500
11508
|
return dates;
|
|
11501
11509
|
}, [timeslotsData, demoRoom?.timezone, timezone5]);
|
|
11510
|
+
useEffect(() => {
|
|
11511
|
+
if (booking || isInitialized || !demoRoom?.timeslots?.length) return;
|
|
11512
|
+
const tz = demoRoom?.timezone || timezone5;
|
|
11513
|
+
const now2 = tz ? dayjs4().tz(tz) : dayjs4();
|
|
11514
|
+
const nearestSlot = demoRoom.timeslots.filter((slot) => {
|
|
11515
|
+
const slotTime = tz ? dayjs4(slot.start_time).tz(tz) : dayjs4(slot.start_time);
|
|
11516
|
+
return slot.status === "available" && slotTime.isAfter(now2);
|
|
11517
|
+
}).sort((a, b) => {
|
|
11518
|
+
const timeA = tz ? dayjs4(a.start_time).tz(tz) : dayjs4(a.start_time);
|
|
11519
|
+
const timeB = tz ? dayjs4(b.start_time).tz(tz) : dayjs4(b.start_time);
|
|
11520
|
+
return timeA.unix() - timeB.unix();
|
|
11521
|
+
})[0];
|
|
11522
|
+
if (!nearestSlot) return;
|
|
11523
|
+
const nearestDate = tz ? dayjs4(nearestSlot.start_time).tz(tz) : dayjs4(nearestSlot.start_time);
|
|
11524
|
+
setSelectedDate(nearestDate);
|
|
11525
|
+
setCalendarValue(nearestDate);
|
|
11526
|
+
setSelectedTimeslotId(nearestSlot.id);
|
|
11527
|
+
setIsInitialized(true);
|
|
11528
|
+
}, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
|
|
11502
11529
|
useEffect(() => {
|
|
11503
11530
|
if (!timeslotsData?.timeslots || isInitialized) return;
|
|
11504
11531
|
const tz = demoRoom?.timezone || timezone5;
|
|
@@ -11564,22 +11591,34 @@ var DateTimePicker2 = ({
|
|
|
11564
11591
|
return `${start} - ${end}`;
|
|
11565
11592
|
};
|
|
11566
11593
|
useEffect(() => {
|
|
11567
|
-
if (!booking
|
|
11594
|
+
if (!booking?.booking_date) return;
|
|
11595
|
+
setSelectedDate(dayjs4(booking.booking_date));
|
|
11596
|
+
setCalendarValue(dayjs4(booking.booking_date));
|
|
11597
|
+
setIsInitialized(true);
|
|
11598
|
+
if (booking.timeslot_id) {
|
|
11599
|
+
setSelectedTimeslotId(booking.timeslot_id);
|
|
11600
|
+
setHasResolvedBookingSlot(true);
|
|
11601
|
+
}
|
|
11602
|
+
}, [booking?.booking_date, booking?.timeslot_id]);
|
|
11603
|
+
useEffect(() => {
|
|
11604
|
+
if (!booking || hasResolvedBookingSlot || !dayTimeslots.length) return;
|
|
11568
11605
|
if (booking.timeslot_id) {
|
|
11569
11606
|
setSelectedTimeslotId(booking.timeslot_id);
|
|
11570
11607
|
setHasResolvedBookingSlot(true);
|
|
11571
11608
|
return;
|
|
11572
11609
|
}
|
|
11573
|
-
if (booking.time_slot)
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11610
|
+
if (!booking.time_slot) return;
|
|
11611
|
+
const tz = demoRoom?.timezone || timezone5;
|
|
11612
|
+
const target = booking.time_slot.replace(/\s+/g, "");
|
|
11613
|
+
const match = dayTimeslots.find((slot) => {
|
|
11614
|
+
const toHm = (iso) => (tz ? dayjs4(iso).tz(tz) : dayjs4(iso)).format("HH:mm");
|
|
11615
|
+
return `${toHm(slot.start_time)}-${toHm(slot.end_time)}` === target;
|
|
11616
|
+
});
|
|
11617
|
+
if (match) {
|
|
11618
|
+
setSelectedTimeslotId(match.id);
|
|
11619
|
+
setHasResolvedBookingSlot(true);
|
|
11581
11620
|
}
|
|
11582
|
-
}, [booking,
|
|
11621
|
+
}, [booking, dayTimeslots, hasResolvedBookingSlot, demoRoom?.timezone, timezone5]);
|
|
11583
11622
|
const initialResponses = useMemo(() => {
|
|
11584
11623
|
if (!booking) return void 0;
|
|
11585
11624
|
return {
|
|
@@ -12486,6 +12525,9 @@ var BookingFormO2O = ({
|
|
|
12486
12525
|
const [selectedPurposeType, setSelectedPurposeType] = useState(
|
|
12487
12526
|
() => initialBusinessType || purposeOptions[0]?.type || ""
|
|
12488
12527
|
);
|
|
12528
|
+
const [isPurposeConfirmed, setIsPurposeConfirmed] = useState(
|
|
12529
|
+
() => !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType)
|
|
12530
|
+
);
|
|
12489
12531
|
useEffect(() => {
|
|
12490
12532
|
setSelectedPurposeType((currentType) => {
|
|
12491
12533
|
if (purposeOptions.some((item) => item.type === currentType)) {
|
|
@@ -12499,11 +12541,16 @@ var BookingFormO2O = ({
|
|
|
12499
12541
|
}
|
|
12500
12542
|
return purposeOptions[0]?.type || "";
|
|
12501
12543
|
});
|
|
12544
|
+
const resolvedFromExplicitSource = !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType) || !!booking?.business_type && purposeOptions.some((item) => item.type === booking.business_type);
|
|
12545
|
+
if (resolvedFromExplicitSource) {
|
|
12546
|
+
setIsPurposeConfirmed(true);
|
|
12547
|
+
}
|
|
12502
12548
|
}, [purposeOptions, initialBusinessType, booking?.business_type]);
|
|
12503
12549
|
const selectedPurpose = useMemo(() => {
|
|
12504
|
-
return purposeOptions.find((item) => item.type === selectedPurposeType) ||
|
|
12550
|
+
return purposeOptions.find((item) => item.type === selectedPurposeType) || {};
|
|
12505
12551
|
}, [purposeOptions, selectedPurposeType]);
|
|
12506
|
-
const
|
|
12552
|
+
const isPodSelected = isPurposeConfirmed && selectedPurpose?.type === "pod";
|
|
12553
|
+
const selectedPodContent = isPodSelected ? selectedPurpose?.podContent : void 0;
|
|
12507
12554
|
const selectedPodDescription = getPodContentDescription(selectedPodContent);
|
|
12508
12555
|
const podDesignId = useMemo(() => getQueryParam("design_id"), []);
|
|
12509
12556
|
const isPodDesignEditMode = !!podDesignId || !!booking?.design_project_id;
|
|
@@ -12585,85 +12632,95 @@ var BookingFormO2O = ({
|
|
|
12585
12632
|
}
|
|
12586
12633
|
) }),
|
|
12587
12634
|
/* @__PURE__ */ jsxs("div", { className: "bg-[#f5f5f5]", children: [
|
|
12588
|
-
!!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs(
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12595
|
-
children: getPurposeLabel(pageData)
|
|
12596
|
-
}
|
|
12597
|
-
),
|
|
12598
|
-
/* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12599
|
-
/* @__PURE__ */ jsx(
|
|
12600
|
-
"select",
|
|
12601
|
-
{
|
|
12602
|
-
id: "booking-purpose-select",
|
|
12603
|
-
value: selectedPurpose?.type || "",
|
|
12604
|
-
onChange: (event2) => {
|
|
12605
|
-
setSelectedPurposeType(event2.target.value);
|
|
12606
|
-
},
|
|
12607
|
-
disabled: !!token,
|
|
12608
|
-
className: cn(
|
|
12609
|
-
"h-[48px] w-full appearance-none rounded-[8px] border border-[#D9DCE1] bg-white px-[16px] pr-[48px] text-[16px] font-medium text-[#2A2C32] outline-none transition-colors focus:border-[#080A0F] focus:ring-2 focus:ring-[#3ADB67]/30 l:text-[14px]",
|
|
12610
|
-
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12611
|
-
),
|
|
12612
|
-
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsx(
|
|
12613
|
-
"option",
|
|
12614
|
-
{
|
|
12615
|
-
value: item.type || "",
|
|
12616
|
-
children: item.label || item.type
|
|
12617
|
-
},
|
|
12618
|
-
`${item.type || item.label || "purpose"}-${index}`
|
|
12619
|
-
))
|
|
12620
|
-
}
|
|
12621
|
-
),
|
|
12622
|
-
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsx(ChevronIcon2, {}) })
|
|
12623
|
-
] }),
|
|
12624
|
-
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12625
|
-
] }),
|
|
12626
|
-
selectedPurpose?.type === "pod" && !!selectedPodContent && /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12627
|
-
!!selectedPodContent.title && /* @__PURE__ */ jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12628
|
-
!!selectedPodDescription && /* @__PURE__ */ jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12629
|
-
!!selectedPodImage && /* @__PURE__ */ jsx(
|
|
12630
|
-
"img",
|
|
12631
|
-
{
|
|
12632
|
-
src: selectedPodImage,
|
|
12633
|
-
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12634
|
-
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12635
|
-
}
|
|
12635
|
+
!!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs(
|
|
12636
|
+
"div",
|
|
12637
|
+
{
|
|
12638
|
+
className: cn(
|
|
12639
|
+
"grid gap-[16px] l:grid-cols-1",
|
|
12640
|
+
isPodSelected && "grid-cols-2"
|
|
12636
12641
|
),
|
|
12637
|
-
|
|
12638
|
-
"
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
rel: "noopener noreferrer",
|
|
12647
|
-
className: cn(
|
|
12648
|
-
"mt-[12px] inline-flex h-[42px] items-center justify-center gap-[6px] rounded-full bg-[#080A0F] px-[24px] text-[14px] font-bold text-white transition-colors hover:bg-[#2A2C32]",
|
|
12649
|
-
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12642
|
+
children: [
|
|
12643
|
+
/* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[24px] l:px-[16px] l:py-[20px]", children: [
|
|
12644
|
+
/* @__PURE__ */ jsx(
|
|
12645
|
+
"label",
|
|
12646
|
+
{
|
|
12647
|
+
htmlFor: "booking-purpose-select",
|
|
12648
|
+
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12649
|
+
children: getPurposeLabel(pageData)
|
|
12650
|
+
}
|
|
12650
12651
|
),
|
|
12651
|
-
children: [
|
|
12652
|
-
|
|
12653
|
-
"
|
|
12652
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12653
|
+
/* @__PURE__ */ jsx(
|
|
12654
|
+
"select",
|
|
12654
12655
|
{
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12656
|
+
id: "booking-purpose-select",
|
|
12657
|
+
value: selectedPurpose?.type || "",
|
|
12658
|
+
onChange: (event2) => {
|
|
12659
|
+
setSelectedPurposeType(event2.target.value);
|
|
12660
|
+
setIsPurposeConfirmed(true);
|
|
12661
|
+
},
|
|
12662
|
+
disabled: !!token,
|
|
12663
|
+
className: cn(
|
|
12664
|
+
"h-[48px] w-full appearance-none rounded-[8px] border border-[#D9DCE1] bg-white px-[16px] pr-[48px] text-[16px] font-medium text-[#2A2C32] outline-none transition-colors focus:border-[#080A0F] focus:ring-2 focus:ring-[#3ADB67]/30 l:text-[14px]",
|
|
12665
|
+
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12666
|
+
),
|
|
12667
|
+
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsx(
|
|
12668
|
+
"option",
|
|
12669
|
+
{
|
|
12670
|
+
value: item.type || "",
|
|
12671
|
+
children: item.label || item.type
|
|
12672
|
+
},
|
|
12673
|
+
`${item.type || item.label || "purpose"}-${index}`
|
|
12674
|
+
))
|
|
12659
12675
|
}
|
|
12660
12676
|
),
|
|
12661
|
-
|
|
12662
|
-
]
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12677
|
+
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsx(ChevronIcon2, {}) })
|
|
12678
|
+
] }),
|
|
12679
|
+
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12680
|
+
] }),
|
|
12681
|
+
isPodSelected && !!selectedPodContent && /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12682
|
+
!!selectedPodContent.title && /* @__PURE__ */ jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12683
|
+
!!selectedPodDescription && /* @__PURE__ */ jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12684
|
+
!!selectedPodImage && /* @__PURE__ */ jsx(
|
|
12685
|
+
"img",
|
|
12686
|
+
{
|
|
12687
|
+
src: selectedPodImage,
|
|
12688
|
+
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12689
|
+
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12690
|
+
}
|
|
12691
|
+
),
|
|
12692
|
+
!!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxs(
|
|
12693
|
+
"a",
|
|
12694
|
+
{
|
|
12695
|
+
href: selectedPodButtonLink || "#",
|
|
12696
|
+
"aria-disabled": isPodButtonDisabled,
|
|
12697
|
+
tabIndex: isPodButtonDisabled ? -1 : void 0,
|
|
12698
|
+
onClick: (event2) => {
|
|
12699
|
+
if (isPodButtonDisabled) event2.preventDefault();
|
|
12700
|
+
},
|
|
12701
|
+
rel: "noopener noreferrer",
|
|
12702
|
+
className: cn(
|
|
12703
|
+
"mt-[12px] inline-flex h-[42px] items-center justify-center gap-[6px] rounded-full bg-[#080A0F] px-[24px] text-[14px] font-bold text-white transition-colors hover:bg-[#2A2C32]",
|
|
12704
|
+
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12705
|
+
),
|
|
12706
|
+
children: [
|
|
12707
|
+
selectedPodButtonIcon && /* @__PURE__ */ jsx(
|
|
12708
|
+
"img",
|
|
12709
|
+
{
|
|
12710
|
+
src: selectedPodButtonIcon,
|
|
12711
|
+
alt: "",
|
|
12712
|
+
className: "h-[16px] w-[16px]",
|
|
12713
|
+
"aria-hidden": "true"
|
|
12714
|
+
}
|
|
12715
|
+
),
|
|
12716
|
+
selectedPodButtonText
|
|
12717
|
+
]
|
|
12718
|
+
}
|
|
12719
|
+
)
|
|
12720
|
+
] })
|
|
12721
|
+
]
|
|
12722
|
+
}
|
|
12723
|
+
) }),
|
|
12667
12724
|
/* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
12668
12725
|
DateTimePicker_default2,
|
|
12669
12726
|
{
|
|
@@ -12733,10 +12790,14 @@ var BookingSuccessO2O = ({
|
|
|
12733
12790
|
const [loading, setLoading] = useState(false);
|
|
12734
12791
|
const [bookingDesign, setBookingDesign] = useState(null);
|
|
12735
12792
|
const [isCancelled, setIsCancelled] = useState(false);
|
|
12793
|
+
const [isPending, setIsPending] = useState(false);
|
|
12736
12794
|
const [showCancelDialog, setShowCancelDialog] = useState(false);
|
|
12737
12795
|
const [cancelLoading, setCancelLoading] = useState(false);
|
|
12738
12796
|
const [cancelError, setCancelError] = useState(null);
|
|
12797
|
+
const [checkinLoading, setCheckinLoading] = useState(false);
|
|
12798
|
+
const [checkinError, setCheckinError] = useState(null);
|
|
12739
12799
|
const qrCodeContainerRef = useRef(null);
|
|
12800
|
+
const isStore = Boolean(isStoreUser);
|
|
12740
12801
|
const handlePrintQRCode = () => {
|
|
12741
12802
|
const canvas = qrCodeContainerRef.current?.querySelector("canvas");
|
|
12742
12803
|
const qrImageSrc = canvas?.toDataURL("image/png");
|
|
@@ -12774,16 +12835,30 @@ var BookingSuccessO2O = ({
|
|
|
12774
12835
|
const subtitle = iframeDoc.createElement("p");
|
|
12775
12836
|
subtitle.textContent = pageData.podData?.QRCodeSubTitle || "";
|
|
12776
12837
|
const image = iframeDoc.createElement("img");
|
|
12777
|
-
image.src = qrImageSrc;
|
|
12778
12838
|
image.alt = "QR Code";
|
|
12779
12839
|
iframeDoc.body.appendChild(title);
|
|
12780
12840
|
iframeDoc.body.appendChild(subtitle);
|
|
12781
12841
|
iframeDoc.body.appendChild(image);
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12842
|
+
const doPrint = () => {
|
|
12843
|
+
iframe.contentWindow?.focus();
|
|
12844
|
+
iframe.contentWindow?.print();
|
|
12845
|
+
setTimeout(() => {
|
|
12846
|
+
document.body.removeChild(iframe);
|
|
12847
|
+
}, 1e3);
|
|
12848
|
+
};
|
|
12849
|
+
let printed = false;
|
|
12850
|
+
const triggerPrintOnce = () => {
|
|
12851
|
+
if (printed) return;
|
|
12852
|
+
printed = true;
|
|
12853
|
+
doPrint();
|
|
12854
|
+
};
|
|
12855
|
+
image.onload = triggerPrintOnce;
|
|
12856
|
+
image.onerror = triggerPrintOnce;
|
|
12857
|
+
setTimeout(triggerPrintOnce, 1500);
|
|
12858
|
+
image.src = qrImageSrc;
|
|
12859
|
+
if (image.complete) {
|
|
12860
|
+
triggerPrintOnce();
|
|
12861
|
+
}
|
|
12787
12862
|
};
|
|
12788
12863
|
useEffect(() => {
|
|
12789
12864
|
if (token && apiConfig && !initialBookingData) {
|
|
@@ -12794,6 +12869,7 @@ var BookingSuccessO2O = ({
|
|
|
12794
12869
|
const booking = await apiClient.getBooking(token, apiConfig.locale);
|
|
12795
12870
|
setBookingData(booking);
|
|
12796
12871
|
setIsCancelled(booking.status === "cancelled");
|
|
12872
|
+
setIsPending(booking.status === "pending");
|
|
12797
12873
|
} catch (err) {
|
|
12798
12874
|
console.error("Failed to fetch booking data:", err);
|
|
12799
12875
|
} finally {
|
|
@@ -12857,6 +12933,33 @@ var BookingSuccessO2O = ({
|
|
|
12857
12933
|
setCancelLoading(false);
|
|
12858
12934
|
}
|
|
12859
12935
|
};
|
|
12936
|
+
const handleCheckin = async () => {
|
|
12937
|
+
if (!token || !apiConfig) {
|
|
12938
|
+
setCheckinError(
|
|
12939
|
+
pageData.cancelError || "Unable to check in: Missing token or API configuration"
|
|
12940
|
+
);
|
|
12941
|
+
return;
|
|
12942
|
+
}
|
|
12943
|
+
setCheckinLoading(true);
|
|
12944
|
+
setCheckinError(null);
|
|
12945
|
+
try {
|
|
12946
|
+
const apiClient = createDemoRoomApi(apiConfig);
|
|
12947
|
+
const checkedInBooking = await apiClient.checkinBooking({
|
|
12948
|
+
booking_token: token
|
|
12949
|
+
});
|
|
12950
|
+
if (checkedInBooking) {
|
|
12951
|
+
setBookingData(checkedInBooking);
|
|
12952
|
+
window.location.reload();
|
|
12953
|
+
}
|
|
12954
|
+
} catch (err) {
|
|
12955
|
+
console.error("Failed to check in booking:", err);
|
|
12956
|
+
setCheckinError(
|
|
12957
|
+
pageData.cancelError || "Failed to check in. Please try again."
|
|
12958
|
+
);
|
|
12959
|
+
} finally {
|
|
12960
|
+
setCheckinLoading(false);
|
|
12961
|
+
}
|
|
12962
|
+
};
|
|
12860
12963
|
if (loading) {
|
|
12861
12964
|
return /* @__PURE__ */ jsx("div", { className: `min-h-screen py-12 px-6 ${className || ""}`, children: /* @__PURE__ */ jsx("div", { className: "mx-auto", children: /* @__PURE__ */ jsxs("div", { className: "animate-pulse space-y-6", children: [
|
|
12862
12965
|
/* @__PURE__ */ jsx("div", { className: "h-8 bg-gray-200 rounded w-1/3" }),
|
|
@@ -12876,21 +12979,33 @@ var BookingSuccessO2O = ({
|
|
|
12876
12979
|
bookingDesign?.order_code;
|
|
12877
12980
|
return /* @__PURE__ */ jsx("div", { className: `min-h-screen l:py-0 l:px-0 py-12 px-6 ${className || ""}`, children: /* @__PURE__ */ jsxs("div", { className: "mx-auto", children: [
|
|
12878
12981
|
/* @__PURE__ */ jsx("h1", { className: "text-[48px] xxl:text-[32px] font-bold text-[#080A0F] mb-8 print:hidden", children: pageData.yourAppointment }),
|
|
12879
|
-
isCancelled && /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-[16px] l:items-start p-6 mb-4 l:gap-2 flex l:flex-col items-center justify-between print:hidden", children: [
|
|
12982
|
+
isCancelled && !isStore && /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-[16px] l:items-start l:p-3 p-6 mb-4 l:gap-2 flex l:flex-col items-center justify-between print:hidden", children: [
|
|
12880
12983
|
/* @__PURE__ */ jsx("p", { className: "text-base text-[#080A0F]", children: pageData.appointmentCanceled }),
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12984
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center l:gap-2 gap-4", children: [
|
|
12985
|
+
!!pageData.contactUs && /* @__PURE__ */ jsx(
|
|
12986
|
+
"a",
|
|
12987
|
+
{
|
|
12988
|
+
href: pageData?.contactUsLink,
|
|
12989
|
+
target: "_blank",
|
|
12990
|
+
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] l:px-[12px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
12991
|
+
rel: "noreferrer",
|
|
12992
|
+
children: pageData.contactUs
|
|
12993
|
+
}
|
|
12994
|
+
),
|
|
12995
|
+
onScheduleAgain && bookingData && /* @__PURE__ */ jsx(
|
|
12996
|
+
"button",
|
|
12997
|
+
{
|
|
12998
|
+
onClick: () => onScheduleAgain(bookingData.demoroom_code),
|
|
12999
|
+
className: "text-[14px] cursor-pointer w-fit bg-black text-white rounded-full hover:bg-gray-800 border-2 border-[#080A0F] px-[20px] l:px-[12px] py-[10px] leading-[1] transition-colors",
|
|
13000
|
+
children: pageData.scheduleAgain
|
|
13001
|
+
}
|
|
13002
|
+
)
|
|
13003
|
+
] })
|
|
12889
13004
|
] }),
|
|
12890
13005
|
/* @__PURE__ */ jsxs(
|
|
12891
13006
|
"div",
|
|
12892
13007
|
{
|
|
12893
|
-
className: bookingData.business_type === "pod" ? "grid grid-cols-2 gap-[16px] l:grid-cols-1 print:grid-cols-1" : "",
|
|
13008
|
+
className: bookingData.business_type === "pod" && !isCancelled && !isStore ? "grid grid-cols-2 gap-[16px] l:grid-cols-1 print:grid-cols-1" : "",
|
|
12894
13009
|
children: [
|
|
12895
13010
|
/* @__PURE__ */ jsxs("div", { className: "space-y-8 bg-white px-[48px] l:px-[16px] l:py-[16px] py-[32px] rounded-[16px] print:hidden", children: [
|
|
12896
13011
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -13002,7 +13117,7 @@ var BookingSuccessO2O = ({
|
|
|
13002
13117
|
] })
|
|
13003
13118
|
] })
|
|
13004
13119
|
] }),
|
|
13005
|
-
bookingData.business_type === "pod" && /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-[16px] px-[48px] l:px-[16px] l:py-[16px] py-[32px] flex flex-col items-center justify-center text-center print:w-full", children: [
|
|
13120
|
+
bookingData.business_type === "pod" && !isStore && !isCancelled && /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-[16px] px-[48px] l:px-[16px] l:py-[16px] py-[32px] flex flex-col items-center justify-center text-center print:w-full", children: [
|
|
13006
13121
|
/* @__PURE__ */ jsx("h2", { className: "text-[24px] l:text-[20px] text-[#4A4C56] text-center", children: pageData.podData?.QRCodeTitle }),
|
|
13007
13122
|
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 text-center mt-2", children: pageData.podData?.QRCodeSubTitle }),
|
|
13008
13123
|
/* @__PURE__ */ jsx(
|
|
@@ -13020,19 +13135,19 @@ var BookingSuccessO2O = ({
|
|
|
13020
13135
|
}
|
|
13021
13136
|
),
|
|
13022
13137
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-center gap-3 mt-6 print:hidden", children: [
|
|
13023
|
-
/* @__PURE__ */ jsx(
|
|
13138
|
+
!!pageData.podData?.btnToWallet && /* @__PURE__ */ jsx(
|
|
13024
13139
|
"button",
|
|
13025
13140
|
{
|
|
13026
13141
|
onClick: () => onAddToWallet?.(bookingData),
|
|
13027
|
-
className: "rounded-full border-2 border-[#080A0F] px-[20px] py-[10px]
|
|
13142
|
+
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13028
13143
|
children: pageData.podData?.btnToWallet
|
|
13029
13144
|
}
|
|
13030
13145
|
),
|
|
13031
|
-
/* @__PURE__ */ jsx(
|
|
13146
|
+
!!pageData.podData?.btnToPrint && /* @__PURE__ */ jsx(
|
|
13032
13147
|
"button",
|
|
13033
13148
|
{
|
|
13034
13149
|
onClick: handlePrintQRCode,
|
|
13035
|
-
className: "rounded-full border-2 border-[#080A0F] px-[20px] py-[10px]
|
|
13150
|
+
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13036
13151
|
children: pageData.podData?.btnToPrint
|
|
13037
13152
|
}
|
|
13038
13153
|
)
|
|
@@ -13041,8 +13156,8 @@ var BookingSuccessO2O = ({
|
|
|
13041
13156
|
]
|
|
13042
13157
|
}
|
|
13043
13158
|
),
|
|
13044
|
-
|
|
13045
|
-
/* @__PURE__ */
|
|
13159
|
+
isPending && /* @__PURE__ */ jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
|
|
13160
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex md:w-full gap-4 md:flex-col md:items-center md:justify-center", children: [
|
|
13046
13161
|
onEditBooking && token && /* @__PURE__ */ jsx(
|
|
13047
13162
|
"button",
|
|
13048
13163
|
{
|
|
@@ -13051,7 +13166,7 @@ var BookingSuccessO2O = ({
|
|
|
13051
13166
|
bookingData.demoroom_code,
|
|
13052
13167
|
bookingData.business_type
|
|
13053
13168
|
),
|
|
13054
|
-
className: "text-[14px] cursor-pointer w-fit rounded-full
|
|
13169
|
+
className: "text-[14px] cursor-pointer w-fit bg-black text-white rounded-full hover:bg-gray-800 border-2 border-[#080A0F] l:px-[12px] px-[20px] py-[10px] leading-[1] transition-colors",
|
|
13055
13170
|
children: pageData.editAppointment
|
|
13056
13171
|
}
|
|
13057
13172
|
),
|
|
@@ -13060,13 +13175,25 @@ var BookingSuccessO2O = ({
|
|
|
13060
13175
|
{
|
|
13061
13176
|
onClick: () => setShowCancelDialog(true),
|
|
13062
13177
|
disabled: cancelLoading,
|
|
13063
|
-
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13178
|
+
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] l:px-[12px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13064
13179
|
children: pageData.cancelAppointment
|
|
13065
13180
|
}
|
|
13066
13181
|
)
|
|
13067
|
-
] }),
|
|
13182
|
+
] }) }),
|
|
13068
13183
|
cancelError && /* @__PURE__ */ jsx("p", { className: "text-sm mt-2", style: { color: "#FF4D4D" }, children: cancelError })
|
|
13069
13184
|
] }),
|
|
13185
|
+
isStore && bookingData?.print_status === "completed" && /* @__PURE__ */ jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
|
|
13186
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsx(
|
|
13187
|
+
"button",
|
|
13188
|
+
{
|
|
13189
|
+
onClick: handleCheckin,
|
|
13190
|
+
disabled: checkinLoading,
|
|
13191
|
+
className: "text-[14px] cursor-pointer w-fit rounded-full text-[#080A0F] border-2 border-[#080A0F] px-[20px] l:px-[12px] py-[10px] leading-[1] hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13192
|
+
children: pageData.changeStatusButton || "Change Pickup Status"
|
|
13193
|
+
}
|
|
13194
|
+
) }),
|
|
13195
|
+
checkinError && /* @__PURE__ */ jsx("p", { className: "text-sm mt-2", style: { color: "#FF4D4D" }, children: checkinError })
|
|
13196
|
+
] }),
|
|
13070
13197
|
showCancelDialog && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 print:hidden", children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-[24px] max-w-[600px] p-8 shadow-xl relative", children: [
|
|
13071
13198
|
/* @__PURE__ */ jsx(
|
|
13072
13199
|
"button",
|