From 35817e00843372cc2531737bf9a5ac92aa744a58 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jan 2024 22:55:30 +0100 Subject: [PATCH] max future days --- src/controllers/calendarController.ts | 3 +++ src/controllers/usersController.ts | 3 +++ src/utils/terminPlaner.ts | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/utils/terminPlaner.ts diff --git a/src/controllers/calendarController.ts b/src/controllers/calendarController.ts index 3ae6056..dfab90f 100644 --- a/src/controllers/calendarController.ts +++ b/src/controllers/calendarController.ts @@ -6,6 +6,7 @@ import User from "../models/user"; import UserGoogleTokens from "../models/userGoogleTokens"; import axios from "axios"; import { isPasswordValid } from "../validator/validator"; +import { requestTerminPlanerChangeFutureBookingDays } from "../utils/terminPlaner"; // this request is needed to get the store id after the user has connected his calendar to redirect him back to the calendar page export async function GetStoreId(req: Request, res: Response) { @@ -233,6 +234,8 @@ export async function UpdateStoreCalendarSettings(req: Request, res: Response) { ...update, calendar_min_earliest_booking_time: calendarMinEarliestBookingTime, }; + + requestTerminPlanerChangeFutureBookingDays(store.store_id); } if (Object.keys(update).length === 0) { diff --git a/src/controllers/usersController.ts b/src/controllers/usersController.ts index 00cb571..198f5ee 100644 --- a/src/controllers/usersController.ts +++ b/src/controllers/usersController.ts @@ -20,6 +20,7 @@ import { USER_ANALYTICS_ENABLED_DEFAULT, } from "../utils/constants"; import Store from "../models/store"; +import { requestTerminPlanerChangeFutureBookingDays } from "../utils/terminPlaner"; export async function AddEmployee(req: Request, res: Response) { try { @@ -319,6 +320,8 @@ export async function UpdateEmployee(req: Request, res: Response) { ...update, calendar_min_earliest_booking_time: calendarMinEarliestBookingTime, }; + + requestTerminPlanerChangeFutureBookingDays(store.store_id); } if (Object.keys(update).length === 0) { diff --git a/src/utils/terminPlaner.ts b/src/utils/terminPlaner.ts new file mode 100644 index 0000000..fdce3e4 --- /dev/null +++ b/src/utils/terminPlaner.ts @@ -0,0 +1,19 @@ +import axios from "axios"; +import logger from "../logger/logger"; + +export function requestTerminPlanerChangeFutureBookingDays(storeId: string) { + axios + .post( + `${process.env.TERMIN_PLANNER_URL}/changeFutureBookingDays` as string, + { + storeId: storeId, + pass: process.env.TERMIN_PLANNER_AUTHORIZATION_PASSWORD as string, + } + ) + .then((res) => { + logger.info("req planner max future booking days %s", res.data); + }) + .catch((err) => { + logger.info("req planner max future booking days err %s", err); + }); +}