fix: #10973 back button not working as expected in embed (#11073)

Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
VijayandHariom Balhara authored and GitHub committed 2023-09-05 15:40:09 +05:30
1 parent 2e12f09f05
commit c12abd75a8
6 files changed
+51 -11

No files matched your search

@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import publicProcedure from "../../../procedures/publicProcedure";
import { router } from "../../../trpc";
import { ZGetScheduleInputSchema } from "./getSchedule.schema";
import { ZRemoveSelectedSlotInputSchema } from "./removeSelectedSlot.schema";
import { ZReserveSlotInputSchema } from "./reserveSlot.schema";
type SlotsRouterHandlerCache = {
@@ -49,12 +50,14 @@ export const slotsRouter = router({
});
}),
// This endpoint has no dependencies, it doesn't need its own file
removeSelectedSlotMark: publicProcedure.mutation(async ({ ctx }) => {
const { req, prisma } = ctx;
const uid = req?.cookies?.uid;
if (uid) {
await prisma.selectedSlots.deleteMany({ where: { uid: { equals: uid } } });
}
return;
}),
removeSelectedSlotMark: publicProcedure
.input(ZRemoveSelectedSlotInputSchema)
.mutation(async ({ input, ctx }) => {
const { req, prisma } = ctx;
const uid = req?.cookies?.uid || input.uid;
if (uid) {
await prisma.selectedSlots.deleteMany({ where: { uid: { equals: uid } } });
}
return;
}),
});
@@ -0,0 +1,7 @@
import type { z } from "zod";
import { removeSelectedSlotSchema } from "./types";
export const ZRemoveSelectedSlotInputSchema = removeSelectedSlotSchema;
export type TRemoveSelectedSlotInputSchema = z.infer<typeof ZRemoveSelectedSlotInputSchema>;
@@ -86,5 +86,7 @@ export const reserveSlotHandler = async ({ ctx, input }: ReserveSlotOptions) =>
}
}
res?.setHeader("Set-Cookie", serialize("uid", uid, { path: "/", sameSite: "lax" }));
return;
return {
uid: uid,
};
};
@@ -57,3 +57,7 @@ export type Slot = {
bookingUid?: string;
users?: string[];
};
export const removeSelectedSlotSchema = z.object({
uid: z.string().nullable(),
});