max future days

main
alex 2024-01-28 22:55:30 +01:00
parent 0238e22393
commit 35817e0084
3 changed files with 25 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import User from "../models/user";
import UserGoogleTokens from "../models/userGoogleTokens"; import UserGoogleTokens from "../models/userGoogleTokens";
import axios from "axios"; import axios from "axios";
import { isPasswordValid } from "../validator/validator"; 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 // 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) { export async function GetStoreId(req: Request, res: Response) {
@ -233,6 +234,8 @@ export async function UpdateStoreCalendarSettings(req: Request, res: Response) {
...update, ...update,
calendar_min_earliest_booking_time: calendarMinEarliestBookingTime, calendar_min_earliest_booking_time: calendarMinEarliestBookingTime,
}; };
requestTerminPlanerChangeFutureBookingDays(store.store_id);
} }
if (Object.keys(update).length === 0) { if (Object.keys(update).length === 0) {

View File

@ -20,6 +20,7 @@ import {
USER_ANALYTICS_ENABLED_DEFAULT, USER_ANALYTICS_ENABLED_DEFAULT,
} from "../utils/constants"; } from "../utils/constants";
import Store from "../models/store"; import Store from "../models/store";
import { requestTerminPlanerChangeFutureBookingDays } from "../utils/terminPlaner";
export async function AddEmployee(req: Request, res: Response) { export async function AddEmployee(req: Request, res: Response) {
try { try {
@ -319,6 +320,8 @@ export async function UpdateEmployee(req: Request, res: Response) {
...update, ...update,
calendar_min_earliest_booking_time: calendarMinEarliestBookingTime, calendar_min_earliest_booking_time: calendarMinEarliestBookingTime,
}; };
requestTerminPlanerChangeFutureBookingDays(store.store_id);
} }
if (Object.keys(update).length === 0) { if (Object.keys(update).length === 0) {

19
src/utils/terminPlaner.ts Normal file
View File

@ -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);
});
}