
* wip * wip * db: schedule schema * fix adding time goes into new day fix adding new time not keeping updating ranges fix updating ranges not maintaining changed values * remove photo upload * remove unused code * remove more unused code * undo time lib * didnt actually change this * dont show onboardi ng flow for users created before sept 1 2021 * use more consistent max-widths * align all inputs in scheduler component * allow overriding of default styles * match figma designs implement goto previous step * add more types, match figma Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
35 lines
915 B
TypeScript
35 lines
915 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
import { getSession } from "next-auth/client";
|
|
import prisma from "@lib/prisma";
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const session = await getSession({ req: req });
|
|
|
|
if (!session) {
|
|
res.status(401).json({ message: "Not authenticated" });
|
|
return;
|
|
}
|
|
|
|
if (req.method === "POST") {
|
|
try {
|
|
const createdSchedule = await prisma.schedule.create({
|
|
data: {
|
|
freeBusyTimes: req.body.data.freeBusyTimes,
|
|
user: {
|
|
connect: {
|
|
id: session.user.id,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return res.status(200).json({
|
|
message: "created",
|
|
data: createdSchedule,
|
|
});
|
|
} catch (error) {
|
|
console.error(error);
|
|
return res.status(500).json({ message: "Unable to create schedule." });
|
|
}
|
|
}
|
|
}
|