@anker-in/ui 0.3.3 → 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.mjs CHANGED
@@ -10900,7 +10900,6 @@ var QuestionnaireForm2 = ({
10900
10900
  return true;
10901
10901
  });
10902
10902
  }, [questions, hasBookedBefore]);
10903
- console.log(error, pageData);
10904
10903
  useEffect(() => {
10905
10904
  if (hasBookedBeforeInitialized.current) return;
10906
10905
  if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
@@ -10973,7 +10972,7 @@ var QuestionnaireForm2 = ({
10973
10972
  if (!emailRegex.test(value)) {
10974
10973
  setErrors((prev) => ({
10975
10974
  ...prev,
10976
- [questionId]: "Please enter a valid email address"
10975
+ [questionId]: pageData?.emailValidError || "Please enter a valid email address"
10977
10976
  }));
10978
10977
  }
10979
10978
  };
@@ -11011,7 +11010,7 @@ var QuestionnaireForm2 = ({
11011
11010
  const questionId = getQuestionId(question);
11012
11011
  const value = responses[questionId];
11013
11012
  if (!value || Array.isArray(value) && value.length === 0) {
11014
- newErrors[questionId] = "This field is required";
11013
+ newErrors[questionId] = pageData?.fieldRuquired || "This field is required";
11015
11014
  }
11016
11015
  }
11017
11016
  });
@@ -11022,7 +11021,7 @@ var QuestionnaireForm2 = ({
11022
11021
  );
11023
11022
  if (!allAgreed) {
11024
11023
  setAgreementError(
11025
- "Please agree to all terms and conditions to continue"
11024
+ pageData?.agreeRuquired || "Please agree to all terms and conditions to continue"
11026
11025
  );
11027
11026
  setErrors(newErrors);
11028
11027
  return false;
@@ -11508,6 +11507,25 @@ var DateTimePicker2 = ({
11508
11507
  });
11509
11508
  return dates;
11510
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]);
11511
11529
  useEffect(() => {
11512
11530
  if (!timeslotsData?.timeslots || isInitialized) return;
11513
11531
  const tz = demoRoom?.timezone || timezone5;
@@ -12507,6 +12525,9 @@ var BookingFormO2O = ({
12507
12525
  const [selectedPurposeType, setSelectedPurposeType] = useState(
12508
12526
  () => initialBusinessType || purposeOptions[0]?.type || ""
12509
12527
  );
12528
+ const [isPurposeConfirmed, setIsPurposeConfirmed] = useState(
12529
+ () => !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType)
12530
+ );
12510
12531
  useEffect(() => {
12511
12532
  setSelectedPurposeType((currentType) => {
12512
12533
  if (purposeOptions.some((item) => item.type === currentType)) {
@@ -12520,11 +12541,16 @@ var BookingFormO2O = ({
12520
12541
  }
12521
12542
  return purposeOptions[0]?.type || "";
12522
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
+ }
12523
12548
  }, [purposeOptions, initialBusinessType, booking?.business_type]);
12524
12549
  const selectedPurpose = useMemo(() => {
12525
- return purposeOptions.find((item) => item.type === selectedPurposeType) || purposeOptions[0];
12550
+ return purposeOptions.find((item) => item.type === selectedPurposeType) || {};
12526
12551
  }, [purposeOptions, selectedPurposeType]);
12527
- const selectedPodContent = selectedPurpose?.podContent;
12552
+ const isPodSelected = isPurposeConfirmed && selectedPurpose?.type === "pod";
12553
+ const selectedPodContent = isPodSelected ? selectedPurpose?.podContent : void 0;
12528
12554
  const selectedPodDescription = getPodContentDescription(selectedPodContent);
12529
12555
  const podDesignId = useMemo(() => getQueryParam("design_id"), []);
12530
12556
  const isPodDesignEditMode = !!podDesignId || !!booking?.design_project_id;
@@ -12606,85 +12632,95 @@ var BookingFormO2O = ({
12606
12632
  }
12607
12633
  ) }),
12608
12634
  /* @__PURE__ */ jsxs("div", { className: "bg-[#f5f5f5]", children: [
12609
- !!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-[16px] l:grid-cols-1", children: [
12610
- /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[24px] l:px-[16px] l:py-[20px]", children: [
12611
- /* @__PURE__ */ jsx(
12612
- "label",
12613
- {
12614
- htmlFor: "booking-purpose-select",
12615
- className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
12616
- children: getPurposeLabel(pageData)
12617
- }
12618
- ),
12619
- /* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
12620
- /* @__PURE__ */ jsx(
12621
- "select",
12622
- {
12623
- id: "booking-purpose-select",
12624
- value: selectedPurpose?.type || "",
12625
- onChange: (event2) => {
12626
- setSelectedPurposeType(event2.target.value);
12627
- },
12628
- disabled: !!token,
12629
- className: cn(
12630
- "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]",
12631
- token && "pointer-events-none cursor-not-allowed opacity-50"
12632
- ),
12633
- children: purposeOptions.map((item, index) => /* @__PURE__ */ jsx(
12634
- "option",
12635
- {
12636
- value: item.type || "",
12637
- children: item.label || item.type
12638
- },
12639
- `${item.type || item.label || "purpose"}-${index}`
12640
- ))
12641
- }
12642
- ),
12643
- /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsx(ChevronIcon2, {}) })
12644
- ] }),
12645
- !!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 })
12646
- ] }),
12647
- selectedPurpose?.type === "pod" && !!selectedPodContent && /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
12648
- !!selectedPodContent.title && /* @__PURE__ */ jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
12649
- !!selectedPodDescription && /* @__PURE__ */ jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
12650
- !!selectedPodImage && /* @__PURE__ */ jsx(
12651
- "img",
12652
- {
12653
- src: selectedPodImage,
12654
- alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
12655
- className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
12656
- }
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"
12657
12641
  ),
12658
- !!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxs(
12659
- "a",
12660
- {
12661
- href: selectedPodButtonLink || "#",
12662
- "aria-disabled": isPodButtonDisabled,
12663
- tabIndex: isPodButtonDisabled ? -1 : void 0,
12664
- onClick: (event2) => {
12665
- if (isPodButtonDisabled) event2.preventDefault();
12666
- },
12667
- rel: "noopener noreferrer",
12668
- className: cn(
12669
- "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]",
12670
- 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
+ }
12671
12651
  ),
12672
- children: [
12673
- selectedPodButtonIcon && /* @__PURE__ */ jsx(
12674
- "img",
12652
+ /* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
12653
+ /* @__PURE__ */ jsx(
12654
+ "select",
12675
12655
  {
12676
- src: selectedPodButtonIcon,
12677
- alt: "",
12678
- className: "h-[16px] w-[16px]",
12679
- "aria-hidden": "true"
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
+ ))
12680
12675
  }
12681
12676
  ),
12682
- selectedPodButtonText
12683
- ]
12684
- }
12685
- )
12686
- ] })
12687
- ] }) }),
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
+ ) }),
12688
12724
  /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
12689
12725
  DateTimePicker_default2,
12690
12726
  {