fix: wrong dates on OOO due to summer time (#20408)
* fix: wrong dates on OOO due to summer time * update styles * fix test * fix edit button
This commit is contained in:
1 parent
48016e0f3e
commit
a7b1981cf1
6 files changed
+30
-19
No files matched your search
@@ -24,7 +24,8 @@ import { OutOfOfficeTab } from "./OutOfOfficeToggleGroup";
|
||||
|
||||
export type BookingRedirectForm = {
|
||||
dateRange: { startDate: Date; endDate: Date };
|
||||
offset: number;
|
||||
startDateOffset: number;
|
||||
endDateOffset: number;
|
||||
toTeamUserId: number | null;
|
||||
reasonId: number;
|
||||
notes?: string;
|
||||
@@ -149,7 +150,8 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
|
||||
startDate: dayjs().startOf("d").toDate(),
|
||||
endDate: dayjs().startOf("d").add(2, "d").toDate(),
|
||||
},
|
||||
offset: dayjs().utcOffset(),
|
||||
startDateOffset: dayjs().utcOffset(),
|
||||
endDateOffset: dayjs().utcOffset(),
|
||||
toTeamUserId: null,
|
||||
reasonId: 1,
|
||||
forUserId: null,
|
||||
@@ -194,7 +196,11 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
|
||||
if (!data.dateRange.endDate) {
|
||||
showToast(t("end_date_not_selected"), "error");
|
||||
} else {
|
||||
createOrEditOutOfOfficeEntry.mutate(data);
|
||||
createOrEditOutOfOfficeEntry.mutate({
|
||||
...data,
|
||||
startDateOffset: -1 * data.dateRange.startDate.getTimezoneOffset(),
|
||||
endDateOffset: -1 * data.dateRange.endDate.getTimezoneOffset(),
|
||||
});
|
||||
}
|
||||
})}>
|
||||
<div className="h-full px-1">
|
||||
|
||||
@@ -245,14 +245,16 @@ function OutOfOfficeEntriesListContent() {
|
||||
data-testid={`ooo-edit-${item.toUser?.username || "n-a"}`}
|
||||
StartIcon="pencil"
|
||||
onClick={() => {
|
||||
const offset = dayjs().utcOffset();
|
||||
const startDateOffset = -1 * item.start.getTimezoneOffset();
|
||||
const endDateOffset = -1 * item.end.getTimezoneOffset();
|
||||
const outOfOfficeEntryData: BookingRedirectForm = {
|
||||
uuid: item.uuid,
|
||||
dateRange: {
|
||||
startDate: dayjs(item.start).subtract(offset, "minute").toDate(),
|
||||
endDate: dayjs(item.end).subtract(offset, "minute").startOf("d").toDate(),
|
||||
startDate: dayjs(item.start).subtract(startDateOffset, "minute").toDate(),
|
||||
endDate: dayjs(item.end).subtract(endDateOffset, "minute").startOf("d").toDate(),
|
||||
},
|
||||
offset,
|
||||
startDateOffset,
|
||||
endDateOffset,
|
||||
toTeamUserId: item.toUserId,
|
||||
reasonId: item.reason?.id ?? 1,
|
||||
notes: item.notes ?? undefined,
|
||||
|
||||
Reference in new issue
Block a user