dont allow user to book a past date
parent
f853865600
commit
d1bdac45eb
|
@ -66,6 +66,16 @@ const getLocationRequestFromIntegration = ({ location }: GetLocationRequestFromI
|
|||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { user } = req.query;
|
||||
|
||||
const isTimeInPast = (time) => {
|
||||
return dayjs(time).isBefore(new Date(), "day");
|
||||
};
|
||||
|
||||
if (isTimeInPast(req.body.start)) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ errorCode: "BookingDateInPast", message: "Attempting to create a meeting in the past." });
|
||||
}
|
||||
|
||||
const currentUser = await prisma.user.findFirst({
|
||||
where: {
|
||||
username: user,
|
||||
|
|
Loading…
Reference in New Issue