fix: fix wrong dates on OOO edit dialog (#17736)
* fix: fix wrong dates on OOO edit dialog * do not use utc() on the browser side
This commit is contained in:
1 parent
757e3a2faf
commit
997d6a75e8
3 files changed
+12
-11
No files matched your search
@@ -104,8 +104,8 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
|
|||||||
? currentlyEditingOutOfOfficeEntry
|
? currentlyEditingOutOfOfficeEntry
|
||||||
: {
|
: {
|
||||||
dateRange: {
|
dateRange: {
|
||||||
startDate: dayjs().utc().startOf("d").toDate(),
|
startDate: dayjs().startOf("d").toDate(),
|
||||||
endDate: dayjs().utc().add(1, "d").endOf("d").toDate(),
|
endDate: dayjs().startOf("d").add(2, "d").toDate(),
|
||||||
},
|
},
|
||||||
offset: dayjs().utcOffset(),
|
offset: dayjs().utcOffset(),
|
||||||
toTeamUserId: null,
|
toTeamUserId: null,
|
||||||
|
|||||||
@@ -126,13 +126,14 @@ export const OutOfOfficeEntriesList = () => {
|
|||||||
data-testid={`ooo-edit-${item.toUser?.username || "n-a"}`}
|
data-testid={`ooo-edit-${item.toUser?.username || "n-a"}`}
|
||||||
StartIcon="pencil"
|
StartIcon="pencil"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const offset = dayjs().utcOffset();
|
||||||
const outOfOfficeEntryData: BookingRedirectForm = {
|
const outOfOfficeEntryData: BookingRedirectForm = {
|
||||||
uuid: item.uuid,
|
uuid: item.uuid,
|
||||||
dateRange: {
|
dateRange: {
|
||||||
startDate: item.start,
|
startDate: dayjs(item.start).subtract(offset, "minute").toDate(),
|
||||||
endDate: dayjs(item.end).subtract(1, "d").toDate(),
|
endDate: dayjs(item.end).subtract(offset, "minute").startOf("d").toDate(),
|
||||||
},
|
},
|
||||||
offset: dayjs().utcOffset(),
|
offset,
|
||||||
toTeamUserId: item.toUserId,
|
toTeamUserId: item.toUserId,
|
||||||
reasonId: item.reason?.id ?? 1,
|
reasonId: item.reason?.id ?? 1,
|
||||||
notes: item.notes ?? undefined,
|
notes: item.notes ?? undefined,
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
|
|||||||
if (existingOutOfOfficeEntry) {
|
if (existingOutOfOfficeEntry) {
|
||||||
throw new TRPCError({ code: "BAD_REQUEST", message: "booking_redirect_infinite_not_allowed" });
|
throw new TRPCError({ code: "BAD_REQUEST", message: "booking_redirect_infinite_not_allowed" });
|
||||||
}
|
}
|
||||||
const startDateUtc = dayjs.utc(startDate).add(input.offset, "minute");
|
const startTimeUtc = dayjs.utc(startDate).add(input.offset, "minute").startOf("day").toISOString();
|
||||||
const endDateUtc = dayjs.utc(endDate).add(input.offset, "minute");
|
const endTimeUtc = dayjs.utc(endDate).add(input.offset, "minute").endOf("day").toISOString();
|
||||||
|
|
||||||
// Get the existing redirected user from existing out of office entry to send that user appropriate email.
|
// Get the existing redirected user from existing out of office entry to send that user appropriate email.
|
||||||
const previousOutOfOfficeEntry = await prisma.outOfOfficeEntry.findUnique({
|
const previousOutOfOfficeEntry = await prisma.outOfOfficeEntry.findUnique({
|
||||||
@@ -181,8 +181,8 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
|
|||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
uuid: uuidv4(),
|
uuid: uuidv4(),
|
||||||
start: startDateUtc.startOf("day").toISOString(),
|
start: startTimeUtc,
|
||||||
end: endDateUtc.endOf("day").toISOString(),
|
end: endTimeUtc,
|
||||||
notes: input.notes,
|
notes: input.notes,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
reasonId: input.reasonId,
|
reasonId: input.reasonId,
|
||||||
@@ -191,8 +191,8 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
|
|||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
start: startDateUtc.startOf("day").toISOString(),
|
start: startTimeUtc,
|
||||||
end: endDateUtc.endOf("day").toISOString(),
|
end: endTimeUtc,
|
||||||
notes: input.notes,
|
notes: input.notes,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
reasonId: input.reasonId,
|
reasonId: input.reasonId,
|
||||||
|
|||||||
Reference in new issue
Block a user