Open joelweight opened 5 months ago
Hey there, @joelweight! I'm Dosu, a bot here to help you with bug fixes, questions, and becoming a contributor. I'm ready to assist you with the issue you've posted.
To fix the bug in transformers.js
at line 41 that prevents same-day availability overrides from being saved and displayed correctly, you need to modify the transformDateOverridesForClient
function. The issue likely stems from the condition that checks if the override date is in the future, which prevents same-day overrides from being processed.
Here's the corrected function:
export function transformDateOverridesForClient(schedule: ScheduleWithAvailabilities, timeZone: string) {
return schedule.availability.reduce((acc, override) => {
// Allow same-day overrides by changing the condition to include the current day
if (!override.date || dayjs.tz(override.date, timeZone).isBefore(dayjs(), "day")) {
return acc;
}
const newValue = {
start: dayjs
.utc(override.date)
.hour(override.startTime.getUTCHours())
.minute(override.startTime.getUTCMinutes())
.toDate(),
end: dayjs
.utc(override.date)
.hour(override.endTime.getUTCHours())
.minute(override.endTime.getUTCMinutes())
.toDate(),
};
const dayRangeIndex = acc.findIndex(
// early return prevents override.date from ever being empty.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(item) => yyyymmdd(item.ranges[0].start) === yyyymmdd(override.date!)
);
if (dayRangeIndex === -1) {
acc.push({ ranges: [newValue] });
return acc;
}
acc[dayRangeIndex].ranges.push(newValue);
return acc;
}, [] as { ranges: TimeRange[] }[]);
}
The key change is in the condition that checks if the override date is in the future. By modifying this condition to include the current day, same-day availability overrides will be processed correctly [1].
To continue the conversation, mention @dosu.
Also experiencing this issue with same-day overrides. Currently running v4.6.14. It works on booking calendars, but not showing up if you refresh Date overrides in the settings.
Issue Summary
User is unable to add availability override on the current day. If you attempt to add availability it will appear to succeed. If you hit "save" on the override page it will also appear to succeed, and is actually saved, but if you then reload the availability page, it will be culled by a bug on line 41 of transformers.js which is looking at day granularity instead of looking at minute granularity.
Steps to Reproduce
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
Actual Results
Expected Results
Technical details
Loom simple demo of the problem. Note: I am adding availability override for TODAY.
https://www.loom.com/share/3bbcbfe3d8c94159a52f96f7e2b5fc25?sid=3c4e2db6-b214-48fa-8b11-5fec10c0d4df
The problem is in transformers.js line 41. It is looking at the override from a "day" perspective instead of from a "minute" perspective.
Evidence
https://www.loom.com/share/3bbcbfe3d8c94159a52f96f7e2b5fc25?sid=3c4e2db6-b214-48fa-8b11-5fec10c0d4df
CAL-3891