@anker-in/ui 0.3.4 → 0.3.6

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
@@ -3233,7 +3233,7 @@ var RoomsList2 = ({
3233
3233
  }
3234
3234
  ) })
3235
3235
  ] }),
3236
- !!mergedPageData?.note && /* @__PURE__ */ jsx("div", { children: mergedPageData?.note })
3236
+ !!mergedPageData?.note && /* @__PURE__ */ jsx("div", { className: "mt-[32px] xl:mt-[16px]", children: mergedPageData?.note })
3237
3237
  ] });
3238
3238
  };
3239
3239
  RoomsList2.displayName = "RoomsList";
@@ -11435,13 +11435,21 @@ var DateTimePicker2 = ({
11435
11435
  podDesignId
11436
11436
  }) => {
11437
11437
  const { token: themeToken } = theme.useToken();
11438
- const [selectedDate, setSelectedDate] = useState(() => booking ? dayjs4(booking.booking_date) : null);
11439
- const [calendarValue, setCalendarValue] = useState(() => booking ? dayjs4(booking.booking_date) : dayjs4());
11438
+ const [selectedDate, setSelectedDate] = useState(
11439
+ () => booking ? dayjs4(booking.booking_date) : null
11440
+ );
11441
+ const [calendarValue, setCalendarValue] = useState(
11442
+ () => booking ? dayjs4(booking.booking_date) : dayjs4()
11443
+ );
11440
11444
  const [selectedTimeslotId, setSelectedTimeslotId] = useState(
11441
11445
  null
11442
11446
  );
11443
11447
  const [isInitialized, setIsInitialized] = useState(() => !!booking);
11444
11448
  const [hasResolvedBookingSlot, setHasResolvedBookingSlot] = useState(false);
11449
+ const autoSelectLockRef = useRef(false);
11450
+ useEffect(() => {
11451
+ autoSelectLockRef.current = false;
11452
+ }, [demoRoomCode]);
11445
11453
  const {
11446
11454
  createBooking,
11447
11455
  loading: bookingLoading,
@@ -11453,13 +11461,11 @@ var DateTimePicker2 = ({
11453
11461
  error: editError
11454
11462
  } = useEditBooking(apiClient);
11455
11463
  const isManagedByParent = demoRoomLoading !== void 0;
11456
- const { data: fetchedDemoRoom } = useDemoRoom(
11457
- apiClient,
11458
- demoRoomCode || "",
11459
- locale,
11460
- { enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
11461
- );
11464
+ const { data: fetchedDemoRoom, loading: fetchedDemoRoomLoading } = useDemoRoom(apiClient, demoRoomCode || "", locale, {
11465
+ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode
11466
+ });
11462
11467
  const demoRoom = demoRoomProp ?? fetchedDemoRoom;
11468
+ const effectiveDemoRoomLoading = !demoRoom && !!(isManagedByParent ? demoRoomLoading : fetchedDemoRoomLoading);
11463
11469
  const isPodPurpose = selectedPurposeType === "pod";
11464
11470
  const effectiveQuestionnaireId = isPodPurpose && demoRoom?.pod_config?.questionnaire_id || demoRoom?.questionnaire_id;
11465
11471
  const { data: questionnaire, loading: questionnaireLoading } = useQuestionnaire(
@@ -11508,7 +11514,8 @@ var DateTimePicker2 = ({
11508
11514
  return dates;
11509
11515
  }, [timeslotsData, demoRoom?.timezone, timezone5]);
11510
11516
  useEffect(() => {
11511
- if (booking || isInitialized || !demoRoom?.timeslots?.length) return;
11517
+ if (booking || isInitialized || autoSelectLockRef.current || !demoRoom?.timeslots?.length)
11518
+ return;
11512
11519
  const tz = demoRoom?.timezone || timezone5;
11513
11520
  const now2 = tz ? dayjs4().tz(tz) : dayjs4();
11514
11521
  const nearestSlot = demoRoom.timeslots.filter((slot) => {
@@ -11520,14 +11527,22 @@ var DateTimePicker2 = ({
11520
11527
  return timeA.unix() - timeB.unix();
11521
11528
  })[0];
11522
11529
  if (!nearestSlot) return;
11530
+ autoSelectLockRef.current = true;
11523
11531
  const nearestDate = tz ? dayjs4(nearestSlot.start_time).tz(tz) : dayjs4(nearestSlot.start_time);
11524
11532
  setSelectedDate(nearestDate);
11525
11533
  setCalendarValue(nearestDate);
11526
11534
  setSelectedTimeslotId(nearestSlot.id);
11527
11535
  setIsInitialized(true);
11528
- }, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
11536
+ }, [
11537
+ booking,
11538
+ isInitialized,
11539
+ demoRoom?.timeslots,
11540
+ demoRoom?.timezone,
11541
+ timezone5
11542
+ ]);
11529
11543
  useEffect(() => {
11530
- if (!timeslotsData?.timeslots || isInitialized) return;
11544
+ if (!timeslotsData?.timeslots || isInitialized || autoSelectLockRef.current)
11545
+ return;
11531
11546
  const tz = demoRoom?.timezone || timezone5;
11532
11547
  const now2 = tz ? dayjs4().tz(tz) : dayjs4();
11533
11548
  const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
@@ -11542,16 +11557,25 @@ var DateTimePicker2 = ({
11542
11557
  });
11543
11558
  const nearestSlot = sortedSlots[0];
11544
11559
  const nearestDate = tz ? dayjs4(nearestSlot.start_time).tz(tz) : dayjs4(nearestSlot.start_time);
11560
+ autoSelectLockRef.current = true;
11545
11561
  setSelectedDate(nearestDate);
11546
11562
  setCalendarValue(nearestDate);
11547
11563
  setSelectedTimeslotId(nearestSlot.id);
11548
11564
  setIsInitialized(true);
11549
- } else if (!selectedDate) {
11565
+ } else if (!selectedDate && !effectiveDemoRoomLoading) {
11566
+ autoSelectLockRef.current = true;
11550
11567
  setSelectedDate(now2);
11551
11568
  setCalendarValue(now2);
11552
11569
  setIsInitialized(true);
11553
11570
  }
11554
- }, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone5]);
11571
+ }, [
11572
+ timeslotsData,
11573
+ isInitialized,
11574
+ selectedDate,
11575
+ demoRoom?.timezone,
11576
+ timezone5,
11577
+ effectiveDemoRoomLoading
11578
+ ]);
11555
11579
  useEffect(() => {
11556
11580
  if (!timeslotsData?.timeslots || !isInitialized) return;
11557
11581
  if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
@@ -11618,7 +11642,13 @@ var DateTimePicker2 = ({
11618
11642
  setSelectedTimeslotId(match.id);
11619
11643
  setHasResolvedBookingSlot(true);
11620
11644
  }
11621
- }, [booking, dayTimeslots, hasResolvedBookingSlot, demoRoom?.timezone, timezone5]);
11645
+ }, [
11646
+ booking,
11647
+ dayTimeslots,
11648
+ hasResolvedBookingSlot,
11649
+ demoRoom?.timezone,
11650
+ timezone5
11651
+ ]);
11622
11652
  const initialResponses = useMemo(() => {
11623
11653
  if (!booking) return void 0;
11624
11654
  return {
@@ -11639,7 +11669,6 @@ var DateTimePicker2 = ({
11639
11669
  borderRadius: 16
11640
11670
  };
11641
11671
  return /* @__PURE__ */ jsxs("div", { children: [
11642
- /* @__PURE__ */ jsx("div", { className: "text-[48px] l:text-[32px] py-[64px] l:py-[24px] l:pt-[64px] font-bold text-center", children: pageData?.scheduleYourVisit }),
11643
11672
  /* @__PURE__ */ jsxs("div", { className: "flex gap-4 l:flex-col", children: [
11644
11673
  /* @__PURE__ */ jsx(
11645
11674
  ConfigProvider,
@@ -12009,7 +12038,7 @@ var DateTimePicker2 = ({
12009
12038
  ] }),
12010
12039
  /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 mt-[40px] gap-4 l:mt-[16px] l:flex l:flex-col l:gap-2", children: timeslotsLoading ? /* @__PURE__ */ jsx("div", { className: "col-span-2 text-center text-[#767880] py-8", children: pageData?.loadingTimeSlots }) : timeslotsError ? /* @__PURE__ */ jsx("div", { className: "col-span-2 text-center text-red-600 py-8", children: pageData?.failedToLoadTimeSlots }) : dayTimeslots.length === 0 ? /* @__PURE__ */ jsx("div", { className: "col-span-2 text-center text-[#767880] py-8", children: pageData?.noAvailableTimeSlots }) : dayTimeslots.map((slot) => {
12011
12040
  const isAvailable = slot.status === "available";
12012
- const isFull = slot.status === "full";
12041
+ slot.status === "full";
12013
12042
  const isSelected = selectedTimeslotId === slot.id;
12014
12043
  return /* @__PURE__ */ jsx(
12015
12044
  "button",
@@ -12025,20 +12054,7 @@ var DateTimePicker2 = ({
12025
12054
  border text-center transition-colors
12026
12055
  ${isSelected ? "border-[#3ADB67] bg-[#3ADB67] cursor-pointer" : isAvailable ? "border-[#E4E5E6] hover:border-[#3ADB67] hover:bg-[#3ADB67] cursor-pointer" : "border-[#E4E5E6] bg-[#F5F5F5] text-[#767880] cursor-not-allowed"}
12027
12056
  `,
12028
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
12029
- /* @__PURE__ */ jsx("div", { children: formatTimeslot(slot) }),
12030
- isFull && /* @__PURE__ */ jsx("div", { className: "text-[16px] l:text-[14px] text-[#767880] mt-[2px]", children: pageData?.full }),
12031
- isAvailable && !isSelected && /* @__PURE__ */ jsxs("div", { className: "text-[16px] l:text-[14px] text-[#767880] mt-1", children: [
12032
- slot.capacity - slot.booked_count,
12033
- " ",
12034
- pageData?.spotsLeft
12035
- ] }),
12036
- isAvailable && isSelected && /* @__PURE__ */ jsxs("div", { className: "text-[16px] l:text-[14px] mt-1", children: [
12037
- slot.capacity - slot.booked_count,
12038
- " ",
12039
- pageData?.spotsLeft
12040
- ] })
12041
- ] })
12057
+ children: /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ jsx("div", { children: formatTimeslot(slot) }) })
12042
12058
  },
12043
12059
  slot.id
12044
12060
  );
@@ -12049,8 +12065,16 @@ var DateTimePicker2 = ({
12049
12065
  ) })
12050
12066
  ] })
12051
12067
  ] }),
12052
- /* @__PURE__ */ jsxs("div", { className: "mt-12", children: [
12053
- !!questionnaire?.questions?.length && /* @__PURE__ */ jsx("div", { className: "text-[48px] font-bold text-center mb-8 l:mb-[24px] l:text-[32px] l:text-left", children: pageData?.fillOutForm }),
12068
+ /* @__PURE__ */ jsxs("div", { children: [
12069
+ !!questionnaire?.questions?.length && /* @__PURE__ */ jsx(
12070
+ "div",
12071
+ {
12072
+ className: cn(
12073
+ "text-[48px] l:text-[32px] pb-[24px] pt-[64px] l:pt-[32px] font-bold"
12074
+ ),
12075
+ children: pageData?.fillOutForm
12076
+ }
12077
+ ),
12054
12078
  questionnaireLoading ? /* @__PURE__ */ jsx("div", { className: "text-center text-[#767880] py-8", children: pageData?.loadingQuestionnaire }) : /* @__PURE__ */ jsx(
12055
12079
  QuestionnaireForm2,
12056
12080
  {
@@ -12391,6 +12415,7 @@ function sanitizeRedirectSource(source) {
12391
12415
  function buildMirWelcomeUrl({
12392
12416
  baseUrl,
12393
12417
  language,
12418
+ countrycode = "US",
12394
12419
  managerId,
12395
12420
  credential,
12396
12421
  currentUrl,
@@ -12401,7 +12426,7 @@ function buildMirWelcomeUrl({
12401
12426
  if (language) {
12402
12427
  url.searchParams.set("language", language);
12403
12428
  }
12404
- url.searchParams.set("countrycode", "US");
12429
+ url.searchParams.set("countrycode", countrycode);
12405
12430
  url.searchParams.set(managerIdParam, managerId);
12406
12431
  url.searchParams.set(credentialParam, credential);
12407
12432
  const redirectSource = sanitizeRedirectSource(
@@ -12467,12 +12492,12 @@ var normalizePurposeData = (purposeData) => {
12467
12492
  return normalizePurposeSource(purposeData);
12468
12493
  };
12469
12494
  var filterPurposeOptionsByBusinessTypes = (purposeOptions, businessTypes) => {
12470
- if (!businessTypes?.length) return purposeOptions;
12495
+ if (!businessTypes?.length) return [];
12471
12496
  const allowedTypes = new Set(businessTypes);
12472
12497
  const filtered = purposeOptions.filter(
12473
12498
  (item) => !!item.type && allowedTypes.has(item.type)
12474
12499
  );
12475
- return filtered.length ? filtered : purposeOptions;
12500
+ return filtered.length ? filtered : [];
12476
12501
  };
12477
12502
  var getPurposeLabel = (pageData) => {
12478
12503
  const purposeData = pageData?.purposeData;
@@ -12542,7 +12567,7 @@ var BookingFormO2O = ({
12542
12567
  return purposeOptions[0]?.type || "";
12543
12568
  });
12544
12569
  const resolvedFromExplicitSource = !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType) || !!booking?.business_type && purposeOptions.some((item) => item.type === booking.business_type);
12545
- if (resolvedFromExplicitSource) {
12570
+ if (resolvedFromExplicitSource || purposeOptions.length > 0) {
12546
12571
  setIsPurposeConfirmed(true);
12547
12572
  }
12548
12573
  }, [purposeOptions, initialBusinessType, booking?.business_type]);
@@ -12585,7 +12610,8 @@ var BookingFormO2O = ({
12585
12610
  }
12586
12611
  return buildMirWelcomeUrl({
12587
12612
  baseUrl: editBaseUrl,
12588
- language: apiConfig.locale,
12613
+ language: apiConfig?.podLanguage,
12614
+ countrycode: apiConfig?.podCountry,
12589
12615
  managerId: effectiveStoreManagerId,
12590
12616
  credential: effectiveMirSessionId,
12591
12617
  managerIdParam: "store_manager_id",
@@ -12597,17 +12623,20 @@ var BookingFormO2O = ({
12597
12623
  if (!baseUrl) return void 0;
12598
12624
  return buildMirWelcomeUrl({
12599
12625
  baseUrl,
12600
- language: apiConfig.locale,
12626
+ language: apiConfig?.podLanguage,
12627
+ countrycode: apiConfig?.podCountry,
12601
12628
  managerId,
12602
12629
  credential: mirCredential
12603
12630
  });
12604
12631
  }, [
12605
- selectedPodContent,
12606
- apiConfig.locale,
12607
- managerId,
12608
12632
  isPodButtonDisabled,
12609
- mirCredential,
12610
12633
  isPodDesignEditMode,
12634
+ managerId,
12635
+ selectedPodContent?.buttonLink,
12636
+ selectedPodContent?.buttonEditLink,
12637
+ apiConfig?.podLanguage,
12638
+ apiConfig?.podCountry,
12639
+ mirCredential,
12611
12640
  effectiveStoreManagerId,
12612
12641
  effectiveMirSessionId
12613
12642
  ]);
@@ -12619,7 +12648,7 @@ var BookingFormO2O = ({
12619
12648
  [pageData?.dateTimePicker, pageData?.questionnaireForm]
12620
12649
  );
12621
12650
  return /* @__PURE__ */ jsxs("div", { children: [
12622
- /* @__PURE__ */ jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsx(
12651
+ !token && /* @__PURE__ */ jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsx(
12623
12652
  DemoRoomDetail2,
12624
12653
  {
12625
12654
  className: cn("min-l:mt-8", layoutClassName),
@@ -12632,7 +12661,17 @@ var BookingFormO2O = ({
12632
12661
  }
12633
12662
  ) }),
12634
12663
  /* @__PURE__ */ jsxs("div", { className: "bg-[#f5f5f5]", children: [
12635
- !!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs(
12664
+ /* @__PURE__ */ jsx(
12665
+ "div",
12666
+ {
12667
+ className: cn(
12668
+ "text-[48px] l:text-[32px] pb-[24px] pt-[128px] l:pt-[64px] font-bold",
12669
+ className
12670
+ ),
12671
+ children: dateTimePickerPageData?.scheduleYourVisit
12672
+ }
12673
+ ),
12674
+ !!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("pb-[40px] l:pb-[24px]", className), children: /* @__PURE__ */ jsxs(
12636
12675
  "div",
12637
12676
  {
12638
12677
  className: cn(
@@ -12686,7 +12725,7 @@ var BookingFormO2O = ({
12686
12725
  {
12687
12726
  src: selectedPodImage,
12688
12727
  alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
12689
- className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
12728
+ className: "mt-[12px] h-[220px] rounded-[8px] object-cover max-h-[360px]"
12690
12729
  }
12691
12730
  ),
12692
12731
  !!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxs(
@@ -13156,7 +13195,7 @@ var BookingSuccessO2O = ({
13156
13195
  ]
13157
13196
  }
13158
13197
  ),
13159
- isPending && /* @__PURE__ */ jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13198
+ isPending && !isCancelled && !isStore && /* @__PURE__ */ jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13160
13199
  /* @__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: [
13161
13200
  onEditBooking && token && /* @__PURE__ */ jsx(
13162
13201
  "button",