@anker-in/ui 0.3.1 → 0.3.3

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.js CHANGED
@@ -10867,7 +10867,9 @@ var QuestionnaireForm2 = ({
10867
10867
  error,
10868
10868
  initialResponses
10869
10869
  }) => {
10870
- const [responses, setResponses] = React15.useState(() => initialResponses || {});
10870
+ const [responses, setResponses] = React15.useState(
10871
+ () => initialResponses || {}
10872
+ );
10871
10873
  const [errors, setErrors] = React15.useState({});
10872
10874
  const [agreements, setAgreements] = React15.useState({});
10873
10875
  const [agreementError, setAgreementError] = React15.useState("");
@@ -10889,8 +10891,12 @@ var QuestionnaireForm2 = ({
10889
10891
  });
10890
10892
  return seeded;
10891
10893
  });
10892
- const prevHasBookedBeforeRef = React15.useRef(initialResponses?.["has_booked_before"] === "option2");
10893
- const hasBookedBeforeInitialized = React15.useRef(!!initialResponses?.["has_booked_before"]);
10894
+ const prevHasBookedBeforeRef = React15.useRef(
10895
+ initialResponses?.["has_booked_before"] === "option2"
10896
+ );
10897
+ const hasBookedBeforeInitialized = React15.useRef(
10898
+ !!initialResponses?.["has_booked_before"]
10899
+ );
10894
10900
  const hasBookedBeforeQuestion = questions.find(
10895
10901
  (q) => (q.key || q.id) === "has_booked_before"
10896
10902
  );
@@ -10908,6 +10914,7 @@ var QuestionnaireForm2 = ({
10908
10914
  return true;
10909
10915
  });
10910
10916
  }, [questions, hasBookedBefore]);
10917
+ console.log(error, pageData);
10911
10918
  React15.useEffect(() => {
10912
10919
  if (hasBookedBeforeInitialized.current) return;
10913
10920
  if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
@@ -11060,7 +11067,9 @@ var QuestionnaireForm2 = ({
11060
11067
  onSubmit?.(finalResponses);
11061
11068
  } else {
11062
11069
  setTimeout(() => {
11063
- const firstErrorElement = document.querySelector('[data-has-error="true"]');
11070
+ const firstErrorElement = document.querySelector(
11071
+ '[data-has-error="true"]'
11072
+ );
11064
11073
  if (firstErrorElement) {
11065
11074
  firstErrorElement.scrollIntoView({
11066
11075
  behavior: "smooth",
@@ -11416,7 +11425,7 @@ var QuestionnaireForm2 = ({
11416
11425
  children: loading ? pageData?.submitting || "Submitting..." : pageData?.submit || "Submit Booking"
11417
11426
  }
11418
11427
  ),
11419
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[#FF4D4D] font-bold", children: error.message }) })
11428
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[#FF4D4D] font-bold", children: pageData?.errorMsg?.[String(error.code)] || pageData?.errorMsg?.[error.code || ""] || error.message }) })
11420
11429
  ] })
11421
11430
  ] });
11422
11431
  };
@@ -11578,22 +11587,34 @@ var DateTimePicker2 = ({
11578
11587
  return `${start} - ${end}`;
11579
11588
  };
11580
11589
  React15.useEffect(() => {
11581
- if (!booking || hasResolvedBookingSlot || !timeslotsData?.timeslots?.length) return;
11590
+ if (!booking?.booking_date) return;
11591
+ setSelectedDate(dayjs4__default.default(booking.booking_date));
11592
+ setCalendarValue(dayjs4__default.default(booking.booking_date));
11593
+ setIsInitialized(true);
11594
+ if (booking.timeslot_id) {
11595
+ setSelectedTimeslotId(booking.timeslot_id);
11596
+ setHasResolvedBookingSlot(true);
11597
+ }
11598
+ }, [booking?.booking_date, booking?.timeslot_id]);
11599
+ React15.useEffect(() => {
11600
+ if (!booking || hasResolvedBookingSlot || !dayTimeslots.length) return;
11582
11601
  if (booking.timeslot_id) {
11583
11602
  setSelectedTimeslotId(booking.timeslot_id);
11584
11603
  setHasResolvedBookingSlot(true);
11585
11604
  return;
11586
11605
  }
11587
- if (booking.time_slot) {
11588
- const match = timeslotsData.timeslots.find(
11589
- (slot) => formatTimeslot(slot) === booking.time_slot
11590
- );
11591
- if (match) {
11592
- setSelectedTimeslotId(match.id);
11593
- setHasResolvedBookingSlot(true);
11594
- }
11606
+ if (!booking.time_slot) return;
11607
+ const tz = demoRoom?.timezone || timezone5;
11608
+ const target = booking.time_slot.replace(/\s+/g, "");
11609
+ const match = dayTimeslots.find((slot) => {
11610
+ const toHm = (iso) => (tz ? dayjs4__default.default(iso).tz(tz) : dayjs4__default.default(iso)).format("HH:mm");
11611
+ return `${toHm(slot.start_time)}-${toHm(slot.end_time)}` === target;
11612
+ });
11613
+ if (match) {
11614
+ setSelectedTimeslotId(match.id);
11615
+ setHasResolvedBookingSlot(true);
11595
11616
  }
11596
- }, [booking, timeslotsData, hasResolvedBookingSlot]);
11617
+ }, [booking, dayTimeslots, hasResolvedBookingSlot, demoRoom?.timezone, timezone5]);
11597
11618
  const initialResponses = React15.useMemo(() => {
11598
11619
  if (!booking) return void 0;
11599
11620
  return {
@@ -12136,7 +12157,9 @@ var DemoRoomDetail2 = ({
12136
12157
  if (demoRoom?.latitude && demoRoom?.longitude) {
12137
12158
  return `https://www.google.com/maps/search/?api=1&query=${demoRoom.latitude},${demoRoom.longitude}`;
12138
12159
  } else if (address) {
12139
- return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address)}`;
12160
+ return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(
12161
+ address
12162
+ )}`;
12140
12163
  }
12141
12164
  return "#";
12142
12165
  })();
@@ -12157,129 +12180,133 @@ var DemoRoomDetail2 = ({
12157
12180
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm mt-2", children: error.message })
12158
12181
  ] }) });
12159
12182
  }
12160
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
12161
- "gap-[80px] l:gap-[40px] l:flex l:flex-col-reverse items-start py-[24px] l:pb-[64px]",
12162
- images.length > 0 ? "grid grid-cols-2" : "flex"
12163
- ), children: [
12164
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
12165
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-[48px] l:text-[32px] font-bold text-gray-900 leading-tight", children: title }),
12166
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-[20px]", children: descriptions?.map((desc, index) => /* @__PURE__ */ jsxRuntime.jsx(
12167
- "p",
12168
- {
12169
- className: "text-base text-gray-600 leading-relaxed",
12170
- children: desc
12171
- },
12172
- index
12173
- )) }),
12174
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
12175
- /* @__PURE__ */ jsxRuntime.jsxs(
12176
- "svg",
12177
- {
12178
- width: "24",
12179
- height: "24",
12180
- viewBox: "0 0 24 24",
12181
- fill: "none",
12182
- xmlns: "http://www.w3.org/2000/svg",
12183
- className: "flex-shrink-0 mt-0.5",
12184
- children: [
12185
- /* @__PURE__ */ jsxRuntime.jsx(
12186
- "path",
12187
- {
12188
- d: "M14.4643 7.4929H9.65565M3.16391 18.7132H20.8171C22.0122 18.7132 22.981 17.7563 22.981 16.576L23 13.8348L22.981 6.42431C22.981 5.24396 22.0122 4.28711 20.8171 4.28711H3.16391C1.96882 4.28711 1 5.24396 1 6.42431V16.576C1 17.7563 1.96882 18.7132 3.16391 18.7132Z",
12189
- stroke: "currentColor",
12190
- strokeWidth: "2",
12191
- strokeLinecap: "round",
12192
- strokeLinejoin: "round"
12193
- }
12194
- ),
12195
- /* @__PURE__ */ jsxRuntime.jsx(
12196
- "path",
12197
- {
12198
- d: "M5.32812 18.2325V14.4238C5.32812 13.8715 5.77584 13.4238 6.32813 13.4238H17.7925C18.3447 13.4238 18.7925 13.8715 18.7925 14.4238V18.2325",
12199
- stroke: "currentColor",
12200
- strokeWidth: "2",
12201
- strokeLinecap: "round",
12202
- strokeLinejoin: "round"
12203
- }
12204
- )
12205
- ]
12206
- }
12207
- ),
12208
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base text-gray-900", children: devices })
12209
- ] }),
12210
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
12211
- /* @__PURE__ */ jsxRuntime.jsxs(
12212
- "svg",
12213
- {
12214
- width: "24",
12215
- height: "24",
12216
- viewBox: "0 0 24 24",
12217
- fill: "none",
12218
- xmlns: "http://www.w3.org/2000/svg",
12219
- className: "flex-shrink-0 mt-0.5",
12220
- children: [
12221
- /* @__PURE__ */ jsxRuntime.jsx(
12222
- "path",
12223
- {
12224
- d: "M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2Z",
12225
- stroke: "currentColor",
12226
- strokeWidth: "2",
12227
- strokeLinecap: "round",
12228
- strokeLinejoin: "round"
12229
- }
12230
- ),
12231
- /* @__PURE__ */ jsxRuntime.jsx(
12232
- "circle",
12233
- {
12234
- cx: "12",
12235
- cy: "9",
12236
- r: "2.5",
12237
- stroke: "currentColor",
12238
- strokeWidth: "2"
12239
- }
12240
- )
12241
- ]
12242
- }
12243
- ),
12244
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
12245
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base text-gray-900", children: address }),
12246
- /* @__PURE__ */ jsxRuntime.jsxs(
12247
- "a",
12183
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(
12184
+ "div",
12185
+ {
12186
+ className: cn(
12187
+ "gap-[80px] l:gap-[40px] l:flex l:flex-col-reverse items-start py-[24px] l:pb-[64px]",
12188
+ images.length > 0 ? "grid grid-cols-2" : "flex"
12189
+ ),
12190
+ children: [
12191
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
12192
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-[48px] l:text-[32px] font-bold text-gray-900 leading-tight", children: title }),
12193
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-[20px]", children: descriptions?.map((desc, index) => /* @__PURE__ */ jsxRuntime.jsx(
12194
+ "p",
12248
12195
  {
12249
- href: googleMapsLink,
12250
- target: "_blank",
12251
- rel: "noopener noreferrer",
12252
- className: "inline-flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 mt-1 underline",
12253
- children: [
12254
- pageData.openInGoogleMaps,
12255
- /* @__PURE__ */ jsxRuntime.jsx(
12256
- "svg",
12257
- {
12258
- width: "12",
12259
- height: "12",
12260
- viewBox: "0 0 12 12",
12261
- fill: "none",
12262
- xmlns: "http://www.w3.org/2000/svg",
12263
- children: /* @__PURE__ */ jsxRuntime.jsx(
12264
- "path",
12196
+ className: "text-base text-gray-600 leading-relaxed",
12197
+ children: desc
12198
+ },
12199
+ index
12200
+ )) }),
12201
+ !!devices && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
12202
+ /* @__PURE__ */ jsxRuntime.jsxs(
12203
+ "svg",
12204
+ {
12205
+ width: "24",
12206
+ height: "24",
12207
+ viewBox: "0 0 24 24",
12208
+ fill: "none",
12209
+ xmlns: "http://www.w3.org/2000/svg",
12210
+ className: "flex-shrink-0 mt-0.5",
12211
+ children: [
12212
+ /* @__PURE__ */ jsxRuntime.jsx(
12213
+ "path",
12214
+ {
12215
+ d: "M14.4643 7.4929H9.65565M3.16391 18.7132H20.8171C22.0122 18.7132 22.981 17.7563 22.981 16.576L23 13.8348L22.981 6.42431C22.981 5.24396 22.0122 4.28711 20.8171 4.28711H3.16391C1.96882 4.28711 1 5.24396 1 6.42431V16.576C1 17.7563 1.96882 18.7132 3.16391 18.7132Z",
12216
+ stroke: "currentColor",
12217
+ strokeWidth: "2",
12218
+ strokeLinecap: "round",
12219
+ strokeLinejoin: "round"
12220
+ }
12221
+ ),
12222
+ /* @__PURE__ */ jsxRuntime.jsx(
12223
+ "path",
12224
+ {
12225
+ d: "M5.32812 18.2325V14.4238C5.32812 13.8715 5.77584 13.4238 6.32813 13.4238H17.7925C18.3447 13.4238 18.7925 13.8715 18.7925 14.4238V18.2325",
12226
+ stroke: "currentColor",
12227
+ strokeWidth: "2",
12228
+ strokeLinecap: "round",
12229
+ strokeLinejoin: "round"
12230
+ }
12231
+ )
12232
+ ]
12233
+ }
12234
+ ),
12235
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base text-gray-900", children: devices })
12236
+ ] }),
12237
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
12238
+ /* @__PURE__ */ jsxRuntime.jsxs(
12239
+ "svg",
12240
+ {
12241
+ width: "24",
12242
+ height: "24",
12243
+ viewBox: "0 0 24 24",
12244
+ fill: "none",
12245
+ xmlns: "http://www.w3.org/2000/svg",
12246
+ className: "flex-shrink-0 mt-0.5",
12247
+ children: [
12248
+ /* @__PURE__ */ jsxRuntime.jsx(
12249
+ "path",
12250
+ {
12251
+ d: "M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2Z",
12252
+ stroke: "currentColor",
12253
+ strokeWidth: "2",
12254
+ strokeLinecap: "round",
12255
+ strokeLinejoin: "round"
12256
+ }
12257
+ ),
12258
+ /* @__PURE__ */ jsxRuntime.jsx(
12259
+ "circle",
12260
+ {
12261
+ cx: "12",
12262
+ cy: "9",
12263
+ r: "2.5",
12264
+ stroke: "currentColor",
12265
+ strokeWidth: "2"
12266
+ }
12267
+ )
12268
+ ]
12269
+ }
12270
+ ),
12271
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
12272
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base text-gray-900", children: address }),
12273
+ /* @__PURE__ */ jsxRuntime.jsxs(
12274
+ "a",
12275
+ {
12276
+ href: googleMapsLink,
12277
+ target: "_blank",
12278
+ rel: "noopener noreferrer",
12279
+ className: "inline-flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 mt-1 underline",
12280
+ children: [
12281
+ pageData.openInGoogleMaps,
12282
+ /* @__PURE__ */ jsxRuntime.jsx(
12283
+ "svg",
12265
12284
  {
12266
- d: "M3 9L9 3M9 3H3M9 3V9",
12267
- stroke: "currentColor",
12268
- strokeWidth: "1.5",
12269
- strokeLinecap: "round",
12270
- strokeLinejoin: "round"
12285
+ width: "12",
12286
+ height: "12",
12287
+ viewBox: "0 0 12 12",
12288
+ fill: "none",
12289
+ xmlns: "http://www.w3.org/2000/svg",
12290
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12291
+ "path",
12292
+ {
12293
+ d: "M3 9L9 3M9 3H3M9 3V9",
12294
+ stroke: "currentColor",
12295
+ strokeWidth: "1.5",
12296
+ strokeLinecap: "round",
12297
+ strokeLinejoin: "round"
12298
+ }
12299
+ )
12271
12300
  }
12272
12301
  )
12273
- }
12274
- )
12275
- ]
12276
- }
12277
- )
12278
- ] })
12279
- ] })
12280
- ] }),
12281
- images.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative l:w-full min-l:h-[400px] rounded-2xl overflow-hidden demo-room-swiper", children: [
12282
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
12302
+ ]
12303
+ }
12304
+ )
12305
+ ] })
12306
+ ] })
12307
+ ] }),
12308
+ images.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative l:w-full min-l:h-[400px] rounded-2xl overflow-hidden demo-room-swiper", children: [
12309
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
12283
12310
  .demo-room-swiper .swiper-pagination-bullet {
12284
12311
  background-color: rgba(255, 255, 255, 0.5);
12285
12312
  }
@@ -12309,32 +12336,34 @@ var DemoRoomDetail2 = ({
12309
12336
  right: 16px !important;
12310
12337
  }
12311
12338
  ` }),
12312
- /* @__PURE__ */ jsxRuntime.jsx(
12313
- Swiper2,
12314
- {
12315
- modules: [Navigation, Pagination, Autoplay],
12316
- spaceBetween: 0,
12317
- slidesPerView: 1,
12318
- navigation: images.length > 1,
12319
- pagination: images.length > 1 ? { clickable: true } : false,
12320
- autoplay: images.length > 1 ? {
12321
- delay: 3e3,
12322
- disableOnInteraction: false
12323
- } : false,
12324
- loop: images.length > 1,
12325
- className: "h-full rounded-2xl",
12326
- children: images.map((img, index) => /* @__PURE__ */ jsxRuntime.jsx(SwiperSlide, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full h-full bg-gray-100", children: /* @__PURE__ */ jsxRuntime.jsx(
12327
- "img",
12339
+ /* @__PURE__ */ jsxRuntime.jsx(
12340
+ Swiper2,
12328
12341
  {
12329
- src: img,
12330
- alt: `Demo room view ${index + 1}`,
12331
- className: "w-full h-full object-cover"
12342
+ modules: [Navigation, Pagination, Autoplay],
12343
+ spaceBetween: 0,
12344
+ slidesPerView: 1,
12345
+ navigation: images.length > 1,
12346
+ pagination: images.length > 1 ? { clickable: true } : false,
12347
+ autoplay: images.length > 1 ? {
12348
+ delay: 3e3,
12349
+ disableOnInteraction: false
12350
+ } : false,
12351
+ loop: images.length > 1,
12352
+ className: "h-full rounded-2xl",
12353
+ children: images.map((img, index) => /* @__PURE__ */ jsxRuntime.jsx(SwiperSlide, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full h-full bg-gray-100", children: /* @__PURE__ */ jsxRuntime.jsx(
12354
+ "img",
12355
+ {
12356
+ src: img,
12357
+ alt: `Demo room view ${index + 1}`,
12358
+ className: "w-full h-full object-cover"
12359
+ }
12360
+ ) }) }, index))
12332
12361
  }
12333
- ) }) }, index))
12334
- }
12335
- )
12336
- ] })
12337
- ] }) });
12362
+ )
12363
+ ] })
12364
+ ]
12365
+ }
12366
+ ) });
12338
12367
  };
12339
12368
  DemoRoomDetail2.displayName = "DemoRoomDetail";
12340
12369
 
@@ -12538,9 +12567,7 @@ var BookingFormO2O = ({
12538
12567
  const selectedPodButtonLink = React15.useMemo(() => {
12539
12568
  if (isPodButtonDisabled) return void 0;
12540
12569
  if (isPodDesignEditMode) {
12541
- const editBaseUrl = getSafePageDataUrl(
12542
- selectedPodContent?.buttonEditLink
12543
- );
12570
+ const editBaseUrl = getSafePageDataUrl(selectedPodContent?.buttonEditLink);
12544
12571
  if (!editBaseUrl || !effectiveStoreManagerId || !effectiveMirSessionId) {
12545
12572
  return void 0;
12546
12573
  }
@@ -12612,7 +12639,11 @@ var BookingFormO2O = ({
12612
12639
  onChange: (event2) => {
12613
12640
  setSelectedPurposeType(event2.target.value);
12614
12641
  },
12615
- className: "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]",
12642
+ disabled: !!token,
12643
+ className: cn(
12644
+ "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]",
12645
+ token && "pointer-events-none cursor-not-allowed opacity-50"
12646
+ ),
12616
12647
  children: purposeOptions.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
12617
12648
  "option",
12618
12649
  {
@@ -12638,7 +12669,7 @@ var BookingFormO2O = ({
12638
12669
  className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
12639
12670
  }
12640
12671
  ),
12641
- !!selectedPodButtonText && /* @__PURE__ */ jsxRuntime.jsxs(
12672
+ !!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxRuntime.jsxs(
12642
12673
  "a",
12643
12674
  {
12644
12675
  href: selectedPodButtonLink || "#",
@@ -12683,7 +12714,7 @@ var BookingFormO2O = ({
12683
12714
  onQuestionnaireSubmit,
12684
12715
  pageData: dateTimePickerPageData,
12685
12716
  selectedPurposeType: selectedPurpose?.type,
12686
- podDesignId
12717
+ podDesignId: mirSessionId
12687
12718
  }
12688
12719
  ) })
12689
12720
  ] })
@@ -12693,6 +12724,7 @@ BookingFormO2O.displayName = "BookingFormO2O";
12693
12724
  var BookingSuccessO2O = ({
12694
12725
  bookingData: initialBookingData,
12695
12726
  token,
12727
+ isStoreUser,
12696
12728
  apiConfig,
12697
12729
  onScheduleAgain,
12698
12730
  onCancelSuccess,
@@ -12736,10 +12768,14 @@ var BookingSuccessO2O = ({
12736
12768
  const [loading, setLoading] = React15.useState(false);
12737
12769
  const [bookingDesign, setBookingDesign] = React15.useState(null);
12738
12770
  const [isCancelled, setIsCancelled] = React15.useState(false);
12771
+ const [isPending, setIsPending] = React15.useState(false);
12739
12772
  const [showCancelDialog, setShowCancelDialog] = React15.useState(false);
12740
12773
  const [cancelLoading, setCancelLoading] = React15.useState(false);
12741
12774
  const [cancelError, setCancelError] = React15.useState(null);
12775
+ const [checkinLoading, setCheckinLoading] = React15.useState(false);
12776
+ const [checkinError, setCheckinError] = React15.useState(null);
12742
12777
  const qrCodeContainerRef = React15.useRef(null);
12778
+ const isStore = Boolean(isStoreUser);
12743
12779
  const handlePrintQRCode = () => {
12744
12780
  const canvas = qrCodeContainerRef.current?.querySelector("canvas");
12745
12781
  const qrImageSrc = canvas?.toDataURL("image/png");
@@ -12777,16 +12813,30 @@ var BookingSuccessO2O = ({
12777
12813
  const subtitle = iframeDoc.createElement("p");
12778
12814
  subtitle.textContent = pageData.podData?.QRCodeSubTitle || "";
12779
12815
  const image = iframeDoc.createElement("img");
12780
- image.src = qrImageSrc;
12781
12816
  image.alt = "QR Code";
12782
12817
  iframeDoc.body.appendChild(title);
12783
12818
  iframeDoc.body.appendChild(subtitle);
12784
12819
  iframeDoc.body.appendChild(image);
12785
- iframe.contentWindow?.focus();
12786
- iframe.contentWindow?.print();
12787
- setTimeout(() => {
12788
- document.body.removeChild(iframe);
12789
- }, 1e3);
12820
+ const doPrint = () => {
12821
+ iframe.contentWindow?.focus();
12822
+ iframe.contentWindow?.print();
12823
+ setTimeout(() => {
12824
+ document.body.removeChild(iframe);
12825
+ }, 1e3);
12826
+ };
12827
+ let printed = false;
12828
+ const triggerPrintOnce = () => {
12829
+ if (printed) return;
12830
+ printed = true;
12831
+ doPrint();
12832
+ };
12833
+ image.onload = triggerPrintOnce;
12834
+ image.onerror = triggerPrintOnce;
12835
+ setTimeout(triggerPrintOnce, 1500);
12836
+ image.src = qrImageSrc;
12837
+ if (image.complete) {
12838
+ triggerPrintOnce();
12839
+ }
12790
12840
  };
12791
12841
  React15.useEffect(() => {
12792
12842
  if (token && apiConfig && !initialBookingData) {
@@ -12797,6 +12847,7 @@ var BookingSuccessO2O = ({
12797
12847
  const booking = await apiClient.getBooking(token, apiConfig.locale);
12798
12848
  setBookingData(booking);
12799
12849
  setIsCancelled(booking.status === "cancelled");
12850
+ setIsPending(booking.status === "pending");
12800
12851
  } catch (err) {
12801
12852
  console.error("Failed to fetch booking data:", err);
12802
12853
  } finally {
@@ -12812,7 +12863,9 @@ var BookingSuccessO2O = ({
12812
12863
  const fetchBookingDesign = async () => {
12813
12864
  try {
12814
12865
  const apiClient = createDemoRoomApi(apiConfig);
12815
- const design = await apiClient.getBookingDesign({ booking_token: token });
12866
+ const design = await apiClient.getBookingDesign({
12867
+ booking_token: token
12868
+ });
12816
12869
  setBookingDesign(design);
12817
12870
  } catch (err) {
12818
12871
  console.error("Failed to fetch booking design:", err);
@@ -12858,6 +12911,33 @@ var BookingSuccessO2O = ({
12858
12911
  setCancelLoading(false);
12859
12912
  }
12860
12913
  };
12914
+ const handleCheckin = async () => {
12915
+ if (!token || !apiConfig) {
12916
+ setCheckinError(
12917
+ pageData.cancelError || "Unable to check in: Missing token or API configuration"
12918
+ );
12919
+ return;
12920
+ }
12921
+ setCheckinLoading(true);
12922
+ setCheckinError(null);
12923
+ try {
12924
+ const apiClient = createDemoRoomApi(apiConfig);
12925
+ const checkedInBooking = await apiClient.checkinBooking({
12926
+ booking_token: token
12927
+ });
12928
+ if (checkedInBooking) {
12929
+ setBookingData(checkedInBooking);
12930
+ window.location.reload();
12931
+ }
12932
+ } catch (err) {
12933
+ console.error("Failed to check in booking:", err);
12934
+ setCheckinError(
12935
+ pageData.cancelError || "Failed to check in. Please try again."
12936
+ );
12937
+ } finally {
12938
+ setCheckinLoading(false);
12939
+ }
12940
+ };
12861
12941
  if (loading) {
12862
12942
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `min-h-screen py-12 px-6 ${className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "animate-pulse space-y-6", children: [
12863
12943
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 bg-gray-200 rounded w-1/3" }),
@@ -12874,26 +12954,36 @@ var BookingSuccessO2O = ({
12874
12954
  }
12875
12955
  const podDesignName = bookingDesign?.material;
12876
12956
  const podDesignImage = bookingDesign?.thumb_url;
12877
- const podOrderCode = bookingDesign?.order_code;
12878
- console.log(bookingDesign);
12879
- console.log(bookingData);
12957
+ bookingDesign?.order_code;
12880
12958
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `min-h-screen l:py-0 l:px-0 py-12 px-6 ${className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto", children: [
12881
12959
  /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-[48px] xxl:text-[32px] font-bold text-[#080A0F] mb-8 print:hidden", children: pageData.yourAppointment }),
12882
- isCancelled && /* @__PURE__ */ jsxRuntime.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: [
12960
+ isCancelled && !isStore && /* @__PURE__ */ jsxRuntime.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: [
12883
12961
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base text-[#080A0F]", children: pageData.appointmentCanceled }),
12884
- onScheduleAgain && bookingData && /* @__PURE__ */ jsxRuntime.jsx(
12885
- "button",
12886
- {
12887
- onClick: () => onScheduleAgain(bookingData.demoroom_code),
12888
- className: "px-6 py-3 text-[16px] bg-black text-white rounded-full hover:bg-gray-800 transition-colors whitespace-nowrap",
12889
- children: pageData.scheduleAgain
12890
- }
12891
- )
12962
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center l:gap-2 gap-4", children: [
12963
+ !!pageData.contactUs && /* @__PURE__ */ jsxRuntime.jsx(
12964
+ "a",
12965
+ {
12966
+ href: pageData?.contactUsLink,
12967
+ target: "_blank",
12968
+ 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",
12969
+ rel: "noreferrer",
12970
+ children: pageData.contactUs
12971
+ }
12972
+ ),
12973
+ onScheduleAgain && bookingData && /* @__PURE__ */ jsxRuntime.jsx(
12974
+ "button",
12975
+ {
12976
+ onClick: () => onScheduleAgain(bookingData.demoroom_code),
12977
+ 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",
12978
+ children: pageData.scheduleAgain
12979
+ }
12980
+ )
12981
+ ] })
12892
12982
  ] }),
12893
12983
  /* @__PURE__ */ jsxRuntime.jsxs(
12894
12984
  "div",
12895
12985
  {
12896
- className: bookingData.business_type === "pod" ? "grid grid-cols-2 gap-[16px] l:grid-cols-1 print:grid-cols-1" : "",
12986
+ className: bookingData.business_type === "pod" && !isCancelled && !isStore ? "grid grid-cols-2 gap-[16px] l:grid-cols-1 print:grid-cols-1" : "",
12897
12987
  children: [
12898
12988
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-8 bg-white px-[48px] l:px-[16px] l:py-[16px] py-[32px] rounded-[16px] print:hidden", children: [
12899
12989
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -12992,21 +13082,20 @@ var BookingSuccessO2O = ({
12992
13082
  " ",
12993
13083
  podDesignName
12994
13084
  ] }),
12995
- bookingData?.status && pageData.podData?.status?.[bookingData.status] && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-[#4A4C56]", children: pageData.podData.status[bookingData.status] }),
12996
- podOrderCode && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-[#4A4C56]", children: podOrderCode })
13085
+ bookingData?.status && pageData.podData?.status?.[bookingData.status] && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-[#4A4C56]", children: pageData.podData.status[bookingData.status] })
12997
13086
  ] }),
12998
13087
  podDesignImage && /* @__PURE__ */ jsxRuntime.jsx(
12999
- "img",
13088
+ antd.Image,
13000
13089
  {
13001
13090
  src: podDesignImage,
13002
13091
  alt: podDesignName,
13003
- className: "w-[88px] h-[88px] rounded-[8px] object-cover shrink-0"
13092
+ className: "!w-[88px] !h-[88px] rounded-[8px] !object-cover"
13004
13093
  }
13005
13094
  )
13006
13095
  ] })
13007
13096
  ] })
13008
13097
  ] }),
13009
- bookingData.business_type === "pod" && /* @__PURE__ */ jsxRuntime.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: [
13098
+ bookingData.business_type === "pod" && !isStore && !isCancelled && /* @__PURE__ */ jsxRuntime.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: [
13010
13099
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-[24px] l:text-[20px] text-[#4A4C56] text-center", children: pageData.podData?.QRCodeTitle }),
13011
13100
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 text-center mt-2", children: pageData.podData?.QRCodeSubTitle }),
13012
13101
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -13017,26 +13106,26 @@ var BookingSuccessO2O = ({
13017
13106
  children: /* @__PURE__ */ jsxRuntime.jsx(
13018
13107
  antd.QRCode,
13019
13108
  {
13020
- value: "https://www.eufymake.com/?type=qrcode",
13109
+ value: `${pageData.podData?.QRCodeUrl}${token}&isStoreUser=true` || "",
13021
13110
  size: 200
13022
13111
  }
13023
13112
  )
13024
13113
  }
13025
13114
  ),
13026
13115
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center gap-3 mt-6 print:hidden", children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(
13116
+ !!pageData.podData?.btnToWallet && /* @__PURE__ */ jsxRuntime.jsx(
13028
13117
  "button",
13029
13118
  {
13030
13119
  onClick: () => onAddToWallet?.(bookingData),
13031
- className: "rounded-full border-2 border-[#080A0F] px-[20px] py-[10px] text-[14px] hover:bg-gray-50 transition-colors",
13120
+ 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",
13032
13121
  children: pageData.podData?.btnToWallet
13033
13122
  }
13034
13123
  ),
13035
- /* @__PURE__ */ jsxRuntime.jsx(
13124
+ !!pageData.podData?.btnToPrint && /* @__PURE__ */ jsxRuntime.jsx(
13036
13125
  "button",
13037
13126
  {
13038
13127
  onClick: handlePrintQRCode,
13039
- className: "rounded-full border-2 border-[#080A0F] px-[20px] py-[10px] text-[14px] hover:bg-gray-50 transition-colors",
13128
+ 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",
13040
13129
  children: pageData.podData?.btnToPrint
13041
13130
  }
13042
13131
  )
@@ -13045,8 +13134,8 @@ var BookingSuccessO2O = ({
13045
13134
  ]
13046
13135
  }
13047
13136
  ),
13048
- !isCancelled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-[64px] print:hidden", children: [
13049
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
13137
+ isPending && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13138
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex md:w-full gap-4 md:flex-col md:items-center md:justify-center", children: [
13050
13139
  onEditBooking && token && /* @__PURE__ */ jsxRuntime.jsx(
13051
13140
  "button",
13052
13141
  {
@@ -13055,7 +13144,7 @@ var BookingSuccessO2O = ({
13055
13144
  bookingData.demoroom_code,
13056
13145
  bookingData.business_type
13057
13146
  ),
13058
- 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",
13147
+ 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",
13059
13148
  children: pageData.editAppointment
13060
13149
  }
13061
13150
  ),
@@ -13064,13 +13153,25 @@ var BookingSuccessO2O = ({
13064
13153
  {
13065
13154
  onClick: () => setShowCancelDialog(true),
13066
13155
  disabled: cancelLoading,
13067
- 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",
13156
+ 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",
13068
13157
  children: pageData.cancelAppointment
13069
13158
  }
13070
13159
  )
13071
- ] }),
13160
+ ] }) }),
13072
13161
  cancelError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm mt-2", style: { color: "#FF4D4D" }, children: cancelError })
13073
13162
  ] }),
13163
+ isStore && bookingData?.print_status === "completed" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13164
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
13165
+ "button",
13166
+ {
13167
+ onClick: handleCheckin,
13168
+ disabled: checkinLoading,
13169
+ 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",
13170
+ children: pageData.changeStatusButton || "Change Pickup Status"
13171
+ }
13172
+ ) }),
13173
+ checkinError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm mt-2", style: { color: "#FF4D4D" }, children: checkinError })
13174
+ ] }),
13074
13175
  showCancelDialog && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 print:hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-[24px] max-w-[600px] p-8 shadow-xl relative", children: [
13075
13176
  /* @__PURE__ */ jsxRuntime.jsx(
13076
13177
  "button",