main
alex 2024-01-14 19:45:19 +01:00
parent 11b7207501
commit 5fd028c6ed
2 changed files with 43 additions and 0 deletions

View File

@ -31,3 +31,45 @@ export async function GetStoreId(req: Request, res: Response) {
res.status(500).send({ err: "invalid request" });
}
}
export async function GetCalendarSettings(req: Request, res: Response) {
try {
const userSession = await getUserSession(req);
if (!userSession) {
return res.status(401).send({ err: "unauthorized" });
}
// check if user has a store
const store = await Store.findOne({
where: {
owner_user_id: userSession.user_id,
},
attributes: [
"calendar_max_future_booking_days",
"calendar_min_earliest_booking_time",
"calendar_max_service_duration",
],
});
if (!store) {
return res.status(401).send({ err: "unauthorized" });
}
console.log("test", req.user);
res.status(200).send({
settings: {
calendar_max_future_booking_days:
store.calendar_max_future_booking_days,
calendar_min_earliest_booking_time:
store.calendar_min_earliest_booking_time,
calendar_max_service_duration: store.calendar_max_service_duration,
},
});
} catch (error) {
logger.error(error);
res.status(500).send({ err: "invalid request" });
}
}

View File

@ -32,5 +32,6 @@ router.get(
);
router.get("/store", calendarController.GetStoreId);
router.get("/settings", calendarController.GetCalendarSettings);
export default router;