@anker-in/ui 0.3.4 → 0.3.5
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 +24 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11456,6 +11456,10 @@ var DateTimePicker2 = ({
|
|
|
11456
11456
|
);
|
|
11457
11457
|
const [isInitialized, setIsInitialized] = React15.useState(() => !!booking);
|
|
11458
11458
|
const [hasResolvedBookingSlot, setHasResolvedBookingSlot] = React15.useState(false);
|
|
11459
|
+
const autoSelectLockRef = React15.useRef(false);
|
|
11460
|
+
React15.useEffect(() => {
|
|
11461
|
+
autoSelectLockRef.current = false;
|
|
11462
|
+
}, [demoRoomCode]);
|
|
11459
11463
|
const {
|
|
11460
11464
|
createBooking,
|
|
11461
11465
|
loading: bookingLoading,
|
|
@@ -11467,13 +11471,17 @@ var DateTimePicker2 = ({
|
|
|
11467
11471
|
error: editError
|
|
11468
11472
|
} = useEditBooking(apiClient);
|
|
11469
11473
|
const isManagedByParent = demoRoomLoading !== void 0;
|
|
11470
|
-
const {
|
|
11474
|
+
const {
|
|
11475
|
+
data: fetchedDemoRoom,
|
|
11476
|
+
loading: fetchedDemoRoomLoading
|
|
11477
|
+
} = useDemoRoom(
|
|
11471
11478
|
apiClient,
|
|
11472
11479
|
demoRoomCode || "",
|
|
11473
11480
|
locale,
|
|
11474
11481
|
{ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
|
|
11475
11482
|
);
|
|
11476
11483
|
const demoRoom = demoRoomProp ?? fetchedDemoRoom;
|
|
11484
|
+
const effectiveDemoRoomLoading = !demoRoom && !!(isManagedByParent ? demoRoomLoading : fetchedDemoRoomLoading);
|
|
11477
11485
|
const isPodPurpose = selectedPurposeType === "pod";
|
|
11478
11486
|
const effectiveQuestionnaireId = isPodPurpose && demoRoom?.pod_config?.questionnaire_id || demoRoom?.questionnaire_id;
|
|
11479
11487
|
const { data: questionnaire, loading: questionnaireLoading } = useQuestionnaire(
|
|
@@ -11522,7 +11530,8 @@ var DateTimePicker2 = ({
|
|
|
11522
11530
|
return dates;
|
|
11523
11531
|
}, [timeslotsData, demoRoom?.timezone, timezone5]);
|
|
11524
11532
|
React15.useEffect(() => {
|
|
11525
|
-
if (booking || isInitialized || !demoRoom?.timeslots?.length)
|
|
11533
|
+
if (booking || isInitialized || autoSelectLockRef.current || !demoRoom?.timeslots?.length)
|
|
11534
|
+
return;
|
|
11526
11535
|
const tz = demoRoom?.timezone || timezone5;
|
|
11527
11536
|
const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
|
|
11528
11537
|
const nearestSlot = demoRoom.timeslots.filter((slot) => {
|
|
@@ -11534,6 +11543,7 @@ var DateTimePicker2 = ({
|
|
|
11534
11543
|
return timeA.unix() - timeB.unix();
|
|
11535
11544
|
})[0];
|
|
11536
11545
|
if (!nearestSlot) return;
|
|
11546
|
+
autoSelectLockRef.current = true;
|
|
11537
11547
|
const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
|
|
11538
11548
|
setSelectedDate(nearestDate);
|
|
11539
11549
|
setCalendarValue(nearestDate);
|
|
@@ -11541,7 +11551,7 @@ var DateTimePicker2 = ({
|
|
|
11541
11551
|
setIsInitialized(true);
|
|
11542
11552
|
}, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
|
|
11543
11553
|
React15.useEffect(() => {
|
|
11544
|
-
if (!timeslotsData?.timeslots || isInitialized) return;
|
|
11554
|
+
if (!timeslotsData?.timeslots || isInitialized || autoSelectLockRef.current) return;
|
|
11545
11555
|
const tz = demoRoom?.timezone || timezone5;
|
|
11546
11556
|
const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
|
|
11547
11557
|
const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
|
|
@@ -11556,16 +11566,25 @@ var DateTimePicker2 = ({
|
|
|
11556
11566
|
});
|
|
11557
11567
|
const nearestSlot = sortedSlots[0];
|
|
11558
11568
|
const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
|
|
11569
|
+
autoSelectLockRef.current = true;
|
|
11559
11570
|
setSelectedDate(nearestDate);
|
|
11560
11571
|
setCalendarValue(nearestDate);
|
|
11561
11572
|
setSelectedTimeslotId(nearestSlot.id);
|
|
11562
11573
|
setIsInitialized(true);
|
|
11563
|
-
} else if (!selectedDate) {
|
|
11574
|
+
} else if (!selectedDate && !effectiveDemoRoomLoading) {
|
|
11575
|
+
autoSelectLockRef.current = true;
|
|
11564
11576
|
setSelectedDate(now2);
|
|
11565
11577
|
setCalendarValue(now2);
|
|
11566
11578
|
setIsInitialized(true);
|
|
11567
11579
|
}
|
|
11568
|
-
}, [
|
|
11580
|
+
}, [
|
|
11581
|
+
timeslotsData,
|
|
11582
|
+
isInitialized,
|
|
11583
|
+
selectedDate,
|
|
11584
|
+
demoRoom?.timezone,
|
|
11585
|
+
timezone5,
|
|
11586
|
+
effectiveDemoRoomLoading
|
|
11587
|
+
]);
|
|
11569
11588
|
React15.useEffect(() => {
|
|
11570
11589
|
if (!timeslotsData?.timeslots || !isInitialized) return;
|
|
11571
11590
|
if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
|