Merge pull request #322 from femyeda/hotfix/user-can-book-a-day-in-past

This commit is contained in:
Bailey Pumfleet 2021-06-29 09:49:49 +01:00 committed by GitHub
commit 9ad1d4fcda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,16 @@ const getLocationRequestFromIntegration = ({ location }: GetLocationRequestFromI
export default async function handler(req: NextApiRequest, res: NextApiResponse) { export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { user } = req.query; 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({ const currentUser = await prisma.user.findFirst({
where: { where: {
username: user, username: user,