settings
parent
11b7207501
commit
5fd028c6ed
|
@ -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" });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,5 +32,6 @@ router.get(
|
|||
);
|
||||
|
||||
router.get("/store", calendarController.GetStoreId);
|
||||
router.get("/settings", calendarController.GetCalendarSettings);
|
||||
|
||||
export default router;
|
||||
|
|
Loading…
Reference in New Issue