fix: add isDryRun behaviour for date overrides (#24464)

* chore: add `isDryRun` prop for date overrides

* chore: add changesets

* chore: implement PR feedback

* fix: merge conflicts
This commit is contained in:
Rajiv Sahal authored and GitHub committed 2025-10-17 08:42:25 +00:00
1 parent ae4b807500
commit ec3656e646
5 files changed
+37 -7

No files matched your search

@@ -26,6 +26,7 @@ const DateOverrideForm = ({
onChange,
userTimeFormat,
weekStart,
isDryRun = false,
}: {
workingHours?: WorkingHours[];
onChange: (newValue: TimeRange[]) => void;
@@ -34,6 +35,7 @@ const DateOverrideForm = ({
onClose?: () => void;
userTimeFormat: number | null;
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
isDryRun?: boolean;
}) => {
const [browsingDate, setBrowsingDate] = useState<Dayjs>();
const { t, i18n, isLocaleReady } = useLocale();
@@ -109,6 +111,11 @@ const DateOverrideForm = ({
if (selectedDates.length === 0) return;
if (isDryRun) {
setSelectedDates([]);
return;
}
if (datesUnavailable) {
selectedDates.map((date) => {
datesInRanges.push({
@@ -116,6 +123,7 @@ const DateOverrideForm = ({
end: date.utc(true).startOf("day").toDate(),
});
});
onChange(datesInRanges);
} else {
selectedDates.map((date) => {
values.range.map((item) => {
@@ -129,9 +137,9 @@ const DateOverrideForm = ({
});
});
});
onChange(datesInRanges);
}
onChange(datesInRanges);
setSelectedDates([]);
}}
className="p-6 sm:flex sm:p-0 xl:flex-row">
@@ -215,6 +223,7 @@ const DateOverrideInputDialog = ({
userTimeFormat: number | null;
weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
className?: string;
isDryRun?: boolean;
}) => {
const [open, setOpen] = useState(false);
return (
@@ -27,6 +27,7 @@ const DateOverrideList = ({
fields,
weekStart = 0,
handleAvailabilityUpdate = noop,
isDryRun = false,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
replace: any;
@@ -38,6 +39,7 @@ const DateOverrideList = ({
travelSchedules?: RouterOutputs["viewer"]["travelSchedules"]["get"];
weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
handleAvailabilityUpdate?: VoidFunction;
isDryRun?: boolean;
}) => {
const { t, i18n } = useLocale();
const isPlatform = useIsPlatform();
@@ -109,10 +111,12 @@ const DateOverrideList = ({
}))}
weekStart={weekStart}
onChange={(ranges) => {
// update has very weird side-effects with sorting.
replace([...fields.filter((currentItem) => currentItem.id !== item.id), { ranges }]);
delete unsortedFieldArrayMap[item.id];
handleAvailabilityUpdate();
if (!isDryRun) {
// update has very weird side-effects with sorting.
replace([...fields.filter((currentItem) => currentItem.id !== item.id), { ranges }]);
delete unsortedFieldArrayMap[item.id];
handleAvailabilityUpdate();
}
}}
Trigger={
<DialogTrigger asChild>
@@ -145,7 +149,9 @@ const DateOverrideList = ({
StartIcon="trash-2"
onClick={() => {
replace([...fields.filter((currentItem) => currentItem.id !== item.id)]);
handleAvailabilityUpdate();
if (!isDryRun) {
handleAvailabilityUpdate();
}
}}
/>
</Tooltip>