dont allow user to book a past date

pull/322/head
femyeda 2021-06-28 19:39:08 -05:00
parent f853865600
commit d1bdac45eb
1 changed files with 11 additions and 1 deletions

View File

@ -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,