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AAM,SAAAC,GAAO,MAAM,QAAYA,EAAG,KARnC,G,+RCjCK+C,EAAmB,WAEnBC,EAAgB,SAAC3E,EAAc4E,GACxC,OAAO5E,EAAK6E,MAAM,KAAK,GAAK,IAAMD,EAAO,GAC7C,EAEaE,EAAU,SAACC,GACpB,OAAOA,EAASF,MAAM,KAAK,EAC/B,EAEaG,EAAU,SAACD,GACpB,GAAIA,EAASE,SAAS,KAAM,CACxB,IAAIL,EAAOG,EAASF,MAAM,KAAK,GAU/B,OATID,GAAQA,EAAKK,SAAS,OACtBL,EAAOA,EAAKC,MAAM,KAAK,IAEvBD,GAAQA,EAAKK,SAAS,OACtBL,EAAOA,EAAKC,MAAM,KAAK,IAEvBD,GAAQA,EAAKK,SAAS,OACtBL,EAAOA,EAAKC,MAAM,KAAK,IAEpBD,C,CAEX,MAAO,EACX,EAWaM,EAAkB,SAACC,GAC5B,IAAMC,EAAc,MAASC,OAAO,KAC9BC,EAAS,OAAkBH,GAAUE,OAAO,KAClD,OAAOD,IAAgBE,EAAS,GAAK,eAAQA,EAAM,IACvD,EAEaC,EAAc,SAACR,EAAyBS,GACjD,IAAKT,EACD,OAAO,EAEX,IAAMH,EAAOI,EAAQD,GACrB,QAAUS,EAAc7E,MAAK,SAAA8E,GAAK,OAAAb,EAAKc,WAAWD,EAAhB,GACtC,EAEaE,EAAc,SAACZ,EAAkBa,GAC1C,IAAM5F,EAAO8E,EAAQC,GACrB,SAAUa,IAAYA,EAASjF,MAAK,SAAAkF,GAAK,OAAAf,EAAQe,KAAO7F,CAAf,IAC7C,EAEa8F,EAAqB,SAACC,GAC/B,OAAOA,IAAW,IAAUC,GAAK,aAAe,WACpD,C","sources":["components/BookingFlow/ReservationEnd/functions/helperFunctions.ts","entities/common.ts","entities/paymentReservation.ts","entities/reservation.ts","entities/service.ts","services/api/schedule.ts","services/dateTime.ts"],"sourcesContent":["import { isPaymentReservationResponse } from './../../../../entities/paymentReservation';\r\nimport { IReservationModel, reservationModelToServiceSum } from 'src/entities/reservation';\r\nimport { calculateSubtotal, IServiceDetails, IServiceSubtotal, PaymentMethod } from 'src/entities/service';\r\nimport { IReservationEndUser } from 'src/entities/user';\r\nimport { StepType } from 'src/services/getStepOrder';\r\nimport { ISendReservationResponse } from '../ReservationEnd';\r\n\r\nexport const getPaymentNeed = (isPaymentEnabled: boolean | undefined, isPayable: boolean | undefined): boolean => {\r\n return (isPaymentEnabled && isPayable) || false;\r\n}\r\n\r\nexport const getPaymentNeedWithPrice = (isPaymentEnabled: boolean | undefined, service: IServiceDetails | undefined) => {\r\n if (isPaymentEnabled && service) {\r\n return (service.Payable && service.Price !== 0);\r\n }\r\n return false;\r\n}\r\n\r\nexport const advanceOrFullPrice = (paymentMethod?: PaymentMethod): boolean => {\r\n if (paymentMethod) {\r\n return (paymentMethod === PaymentMethod.Advance || paymentMethod === PaymentMethod.FullPrice);\r\n }\r\n return false;\r\n}\r\n\r\nexport const getSubtotal = (reservations: IReservationModel[]): IServiceSubtotal | null => {\r\n const servicePriceData = reservations\r\n .filter(reservation => getServiceFromReservation(reservation).Payable)\r\n .map(reservation => reservationModelToServiceSum(reservation));\r\n return servicePriceData.length ? calculateSubtotal(servicePriceData) : null;\r\n}\r\n\r\nexport const isValidSubtotal = (reservations: IReservationModel[]): boolean => {\r\n const subTotal = getSubtotal(reservations);\r\n if (subTotal) {\r\n return subTotal.Price !== 0;\r\n }\r\n return false;\r\n}\r\n\r\nexport const getServiceFromReservation = (reservation: IReservationModel) => {\r\n return (reservation[StepType.Service] || reservation[StepType.Timetable]?.service)!;\r\n}\r\n\r\nexport const getServicesFromReservations = (reservationList: IReservationModel[]) => {\r\n return reservationList.map(r => getServiceFromReservation(r));\r\n}\r\n\r\nexport const isReservationEndUserDirty = (reservationEndUser: IReservationEndUser): boolean => {\r\n return isDirty(\r\n reservationEndUser.InvoiceDetails\r\n ? {\r\n ...reservationEndUser,\r\n InvoiceDetails: {\r\n ...reservationEndUser.InvoiceDetails,\r\n Country: ''\r\n }\r\n }\r\n : reservationEndUser\r\n )\r\n}\r\n\r\nexport const isDirty = (object: any): boolean => {\r\n return Object.values(object).some(x => {\r\n if (x !== null && x !== '' && x !== undefined && x !== false) {\r\n if (typeof x === 'object') {\r\n return isDirty(x);\r\n }\r\n return true;\r\n }\r\n return false;\r\n });\r\n}\r\n\r\nexport const transformResponse = (response: any): ISendReservationResponse | null => {\r\n const result: ISendReservationResponse = {\r\n ReservedReservations: null,\r\n PaymentReservationResponse: null\r\n }\r\n\r\n if (response && response.constructor === Array) {\r\n const paymentReservationResponse = response[1];\r\n if (paymentReservationResponse && isPaymentReservationResponse(paymentReservationResponse)) {\r\n result.ReservedReservations = response[0];\r\n result.PaymentReservationResponse = paymentReservationResponse;\r\n }\r\n else {\r\n result.ReservedReservations = response;\r\n }\r\n }\r\n else if (response && isPaymentReservationResponse(response)) {\r\n result.PaymentReservationResponse = response;\r\n }\r\n else {\r\n return null;\r\n }\r\n\r\n return result;\r\n}","export interface IErrorDto {\r\n ErrorCode: number;\r\n ErrorMessage: string;\r\n}\r\n\r\nexport interface IValidationDto extends IErrorDto {\r\n Field: string;\r\n}\r\n\r\nexport interface IResponseDto {\r\n Success: boolean;\r\n Error: IErrorDto | null;\r\n ValidationErrors: IValidationDto[];\r\n}\r\n\r\nexport interface IDTO extends IResponseDto {\r\n Data: T;\r\n}\r\n\r\nexport interface ILoginErrorDto {\r\n error: string;\r\n // eslint-disable-next-line camelcase\r\n error_description: string;\r\n}\r\n\r\nexport function isSame(e1?: T, e2?: T) {\r\n return !!(\r\n !e1 && !e2 ||\r\n e1 && e2 && e1.Id === e2.Id);\r\n}","import { IAnswer, IQuestion } from './question';\r\nimport { IReservationResponse } from './reservation';\r\n\r\nexport interface IPaymentReservation {\r\n CalendarId?: number;\r\n ServiceId: number;\r\n ScheduleId?: number,\r\n ClientKey?: string;\r\n PersonCount: number;\r\n StartTime: string;\r\n ArriveTime?: string;\r\n Questions?: IQuestion[] | IAnswer[];\r\n}\r\n\r\nexport interface IPaymentReservationDetails extends IPaymentReservation {\r\n Id: number;\r\n PaymentUser?: IPaymentUserDetails;\r\n EndTime: string;\r\n}\r\n\r\nexport interface IPaymentUser {\r\n Name: string;\r\n Email: string;\r\n Phone: string;\r\n InvoiceName?: string;\r\n Country?: string;\r\n City?: string;\r\n StreetAddress?: string;\r\n PostalCode?: string;\r\n PrivatePerson?: boolean;\r\n TaxNumber?: string;\r\n PocketId: number;\r\n}\r\n\r\nexport interface IPaymentUserDetails extends IPaymentUser {\r\n Id: number;\r\n}\r\n\r\nexport interface IPaymentReservationRequest {\r\n User: IPaymentUser;\r\n Reservations: IPaymentReservation[];\r\n TermsAccepted: boolean;\r\n}\r\n\r\nexport enum TransactionStatus {\r\n Success = 1,\r\n Failed = 2,\r\n Pending = 3\r\n}\r\n\r\nexport interface IPaymentResultResponse {\r\n TransactionStatus: TransactionStatus;\r\n OnlinePaymentKey: string;\r\n PaidReservations: IReservationResponse[];\r\n UnPaidReservations: IPaymentReservationDetails[];\r\n FailedPaidReservations: IPaymentReservationDetails[];\r\n}\r\n\r\nexport interface IPaymentReservationResponse {\r\n PaymentUrl: string;\r\n HasCollision: boolean;\r\n HasPaymentError: boolean;\r\n}\r\n\r\nexport const isPaymentReservationResponse = (variableToCheck: any): variableToCheck is IPaymentReservationResponse => {\r\n return variableToCheck.PaymentUrl !== undefined;\r\n}","import { IServiceDetails, IServicePriceData } from 'src/entities/service';\r\nimport { handleError } from './../services/api/errorHandler';\r\nimport { IPagination } from './../components/Reservations/Paginator';\r\nimport { StepType } from './../services/getStepOrder';\r\nimport { ICalendar } from './calendar';\r\nimport { IResponseDto, isSame, IValidationDto } from './common';\r\nimport { ModuleSearchParam } from '../models/modules';\r\nimport { IAnswer, IQuestion } from './question';\r\nimport { IUserBase, IUser, ISignupUser } from './user';\r\nimport { IRequiredFieldInfo } from './company';\r\nimport { getDate } from 'src/services/dateTime';\r\nimport Moment from 'moment';\r\nimport { ISchedule } from './schedule';\r\nimport { getScheduleList } from 'src/services/api/schedule';\r\n\r\nexport const enum ReservationStateType {\r\n Reserved = 'reserved',\r\n NotConfirmed = 'notconfirmed',\r\n Deleted = 'deleted',\r\n}\r\n\r\nexport const enum ReservationRequestOrder {\r\n Date,\r\n Service,\r\n Calendar,\r\n}\r\n\r\nexport type IFilterType = 'all' | 'past' | 'future';\r\n\r\nexport interface IFilter {\r\n type: IFilterType;\r\n isAscending: boolean;\r\n}\r\n\r\nexport interface IReservationDto extends IResponseDto {\r\n Data: IReservationDetails;\r\n}\r\n\r\nexport interface IReservationRequest {\r\n Id: number;\r\n ClientKey?: string;\r\n}\r\n\r\nexport interface IReservationQueryOptions {\r\n pagination?: IPagination;\r\n filter: IFilter;\r\n clientKey?: string;\r\n}\r\n\r\nexport interface IPaidTransactionResponse {\r\n HasPaidTransaction: boolean;\r\n}\r\n\r\ninterface IMockReservationDetailsList {\r\n Reservations: IReservationDetails[];\r\n TotalCount: number;\r\n FilteredCount: number;\r\n}\r\n\r\nexport type IReservationDetailsList = IMockReservationDetailsList;\r\n\r\nexport interface IReservationDetails extends IReservation {\r\n Id: number;\r\n EventState?: ReservationStateType;\r\n Title: string;\r\n CalendarName?: string;\r\n User?: IUser;\r\n LastModified?: string;\r\n DurationToUser?: number;\r\n IsDurationVisible?: boolean;\r\n}\r\n\r\nexport interface IPendingReservation {\r\n StartTime: string;\r\n PersonCount: number;\r\n CalendarId?: number;\r\n ServiceId: number;\r\n}\r\n\r\nexport interface IReservationResponse extends IReservationDetails {\r\n Blocked: boolean;\r\n ValidationErrors: IValidationDto[];\r\n ClientKey: string;\r\n}\r\n\r\n/**\r\n * @property Id - Unique, generated identifier of the Question\r\n * @property FieldName - Unique, given identifier of the Question defined by the admin user\r\n * @property Name - Visible name of the Question\r\n * @property Value - Value of the Question (the answer for the question)\r\n */\r\nexport interface IReservationDate {\r\n StartTime: Date;\r\n EndTime?: Date;\r\n ArriveTime?: Date;\r\n}\r\n\r\n/**\r\n * @property StartTime - Start time of the reservation (with date and time)\r\n * @property EndTime - End time of the reservation (with date and time)\r\n * @property ArriveTime - Arrival time planned by the user who made the reservation\r\n * @property CalendarId - Id of the selected Calendar\r\n * @property ServiceId - Id of the selected Service\r\n * @property ScheduleId - Unique identifier of the schedule the reservation belongs to (null if the type of the calendar is not Timetable)\r\n * @property PersonCount - Number of persons belong to the reservation\r\n * @property Questions - Custom questions with answers belong to the reservation\r\n */\r\nexport interface IReservation {\r\n StartTime: string;\r\n EndTime: string;\r\n ArriveTime: string;\r\n CalendarId?: number;\r\n Calendar?: ICalendar;\r\n Service?: IServiceDetails;\r\n ServiceId: number;\r\n PersonCount: number;\r\n Questions?: IQuestion[] | IAnswer[];\r\n ClientKey?: string;\r\n ScheduleId?: number;\r\n}\r\n\r\n/**\r\n * Interface for creating reservation request body\r\n * @property User - Logged in user data\r\n * @property Reservations - List of user created reservations\r\n */\r\nexport interface IReservationSaveRequest {\r\n User: IUserBase | ISignupUser;\r\n Reservations: IReservation[];\r\n TermsAccepted: boolean;\r\n}\r\n\r\nexport const isSignUpUser = (user: IUserBase): user is ISignupUser =>\r\n (user as any).Password !== undefined;\r\n\r\nexport interface IReservationModifyRequest {\r\n Reservation: IReservationDetails;\r\n User?: IUser;\r\n ClientKey?: string;\r\n}\r\n\r\n/**\r\n * Type of the @type step value model\r\n * @property displayValue - Visible representation of the selected value in step\r\n */\r\nexport type StepValue = T & {\r\n displayValue: string;\r\n};\r\n\r\nexport interface IDateStepValue {\r\n startTime: string;\r\n endTime: string;\r\n personCount: number;\r\n}\r\nexport interface ITimetableStepValue {\r\n service: IServiceDetails;\r\n schedule: ISchedule;\r\n personCount: number;\r\n}\r\n\r\nexport type ISearchParams = {\r\n -readonly [key in keyof typeof ModuleSearchParam]: 'unset' | string | null;\r\n};\r\n\r\n/**\r\n * Interface for internal booking flow reservation model\r\n */\r\nexport interface IReservationModel {\r\n searchParams?: ISearchParams;\r\n [StepType.Calendar]?: StepValue;\r\n [StepType.Service]?: StepValue;\r\n [StepType.Date]?: StepValue;\r\n [StepType.Timetable]?: StepValue;\r\n [StepType.CustomerData]?: StepValue<{\r\n answers: IAnswer[];\r\n arriveTime: string | null;\r\n }>;\r\n}\r\n\r\nexport interface IReservationRequiredFieldProps {\r\n requiredFieldInfo: IRequiredFieldInfo;\r\n isAuthenticated?: boolean;\r\n}\r\n\r\nexport const isEmailRequired = (props: IReservationRequiredFieldProps) => {\r\n return props.isAuthenticated\r\n ? props.requiredFieldInfo.IsRegEmailRequired\r\n : props.requiredFieldInfo.IsEmailRequired;\r\n};\r\n\r\nexport const isPhoneNumberRequired = (\r\n props: IReservationRequiredFieldProps\r\n) => {\r\n return props.isAuthenticated\r\n ? props.requiredFieldInfo.IsRegPhoneRequired\r\n : props.requiredFieldInfo.IsPhoneRequired;\r\n};\r\n\r\nexport const isNameRequired = (props: IReservationRequiredFieldProps) => {\r\n return props.isAuthenticated\r\n ? props.requiredFieldInfo.IsRegNameRequired\r\n : props.requiredFieldInfo.IsNameRequired;\r\n};\r\n\r\nexport const reservationValueChanged = (\r\n newData: IReservationModel,\r\n data: IReservationModel,\r\n type: 'calendar' | 'service' | 'personCount' | 'date'\r\n) => {\r\n switch (type) {\r\n case 'calendar':\r\n return !isSame(newData[StepType.Calendar], data[StepType.Calendar]);\r\n case 'service':\r\n return !isSame(newData[StepType.Service], data[StepType.Service]);\r\n\r\n case 'personCount':\r\n const newAppointment = newData[StepType.Date];\r\n const appointment = data[StepType.Date];\r\n const newPersonCount = newAppointment && newAppointment.personCount;\r\n const personCount = appointment && appointment.personCount;\r\n return newPersonCount !== personCount;\r\n case 'date':\r\n const newApp = newData[StepType.Date];\r\n const app = data[StepType.Date];\r\n const newDate = newApp && newApp.startTime;\r\n const date = app && app.startTime;\r\n return (\r\n (!newDate && !date) ||\r\n (newDate && date && getDate(date) !== getDate(newDate))\r\n );\r\n }\r\n};\r\n\r\nexport const isWithinModificationPeriod = (\r\n reservation: IReservationDetails\r\n) => {\r\n if (!reservation.Calendar) {\r\n return;\r\n }\r\n\r\n const start = Moment(reservation.StartTime);\r\n const now = Moment();\r\n\r\n const minimumTimeUntilStart = Moment.duration(\r\n reservation.Calendar.MinTimeModify,\r\n 'hours'\r\n ).asMinutes();\r\n const timesUntilStart = Moment.duration(start.diff(now)).asMinutes();\r\n\r\n return timesUntilStart >= minimumTimeUntilStart;\r\n};\r\n\r\nexport const populateReservations = (\r\n reservations: T[],\r\n items: ICalendar[] | IServiceDetails[]\r\n): T[] => {\r\n const isServiceList = (arr: any[]): arr is IServiceDetails[] => {\r\n return arr[0]?.Price !== undefined;\r\n };\r\n\r\n return reservations.map((r) =>\r\n isServiceList(items)\r\n ? {\r\n ...r,\r\n Service: items.find((service) => service.Id === r.ServiceId),\r\n }\r\n : {\r\n ...r,\r\n Calendar: items.find(\r\n (calendar) => calendar.Id === r.CalendarId\r\n ),\r\n }\r\n );\r\n};\r\n\r\nexport const hasSchedule = (reservation: IReservation) =>\r\n !!reservation.ScheduleId;\r\n\r\nexport const getSchedule = async (reservation: IReservationDetails) => {\r\n const { CalendarId, ScheduleId } = reservation;\r\n\r\n if (!CalendarId || !ScheduleId) {\r\n throw new Error(\r\n `The reservation of ID ${reservation.Id} has no CalendarId or ScheduleId`\r\n );\r\n }\r\n\r\n return getScheduleList(\r\n CalendarId,\r\n reservation.StartTime,\r\n reservation.EndTime,\r\n true\r\n )\r\n .then(Object.values)\r\n .then(\r\n (schedules) =>\r\n schedules.flat().find((sch) => sch.Id === ScheduleId) ||\r\n Promise.reject(\r\n new Error(\r\n `The schedule of ID ${ScheduleId} could not be found`\r\n )\r\n )\r\n )\r\n .catch((e) => {\r\n throw handleError(e);\r\n });\r\n};\r\n\r\nexport const reservationModelToServiceSum = (\r\n model: IReservationModel\r\n): IServicePriceData => {\r\n const appointment = model[StepType.Date];\r\n const event = model[StepType.Timetable];\r\n\r\n return appointment\r\n ? {\r\n Price: model.service!.Price,\r\n Currency: model.service!.Currency,\r\n PaymentMethod: model.service!.PaymentMethod,\r\n VatPercentage: model.service!.VatPercentage,\r\n PersonCount: appointment.personCount,\r\n }\r\n : {\r\n Price: event!.service.Price,\r\n Currency: event!.service.Currency,\r\n PaymentMethod: event!.service.PaymentMethod,\r\n VatPercentage: event!.service.VatPercentage,\r\n PersonCount: event!.personCount,\r\n };\r\n};\r\n\r\nexport interface IModifyLocationState {\r\n Reservation: IReservationDetails;\r\n ClientKey?: string;\r\n}\r\n","import { advanceOrFullPrice } from 'src/components/BookingFlow/ReservationEnd/functions/helperFunctions';\r\nimport { IPendingReservation } from './reservation';\r\n\r\nexport interface IService {\r\n Id: number;\r\n Name: string;\r\n Duration: number;\r\n DurationToUser: number;\r\n IsDurationVisible: boolean;\r\n HasArriveTime: boolean;\r\n HasQuestions: boolean;\r\n}\r\n\r\nexport enum PaymentMethod {\r\n NotPayableOnline = 0,\r\n Advance = 1,\r\n FullPrice = 2\r\n}\r\n\r\nexport interface IServiceDetails extends IService {\r\n Description: string | null;\r\n ShortDescription: string | null;\r\n Price: number | null;\r\n Currency: string | null;\r\n DisplayedPrice: string | null;\r\n DisplayedCurrency: string | null;\r\n PictureLink: string | null;\r\n Background: string;\r\n Note: string | null;\r\n PaymentMethod: PaymentMethod;\r\n VatPercentage: number | null;\r\n ItemName: string | null;\r\n Payable: boolean;\r\n}\r\n\r\nexport interface IServiceIntervalRequest {\r\n serviceId: number;\r\n personCount: number;\r\n startDate: string;\r\n pendingReservations: IPendingReservation[];\r\n endDate?: string;\r\n modifiedReservationId?: number\r\n}\r\n\r\nexport interface IServiceArriveTimeRequest {\r\n serviceId: number;\r\n startDate: string;\r\n}\r\n\r\nexport interface IServicePriceData {\r\n Price: number | null;\r\n Currency: string | null;\r\n PaymentMethod: PaymentMethod;\r\n VatPercentage: number | null\r\n PersonCount?: number;\r\n}\r\n\r\nexport interface IServiceSubtotal {\r\n Price: number | null;\r\n Currency: string | null;\r\n}\r\n\r\nexport const fillPayableFields = (services: IServiceDetails[]) => {\r\n return services.map(fillPayableField);\r\n}\r\n\r\nexport const fillPayableField = (service: IServiceDetails) => {\r\n service.Payable = isPayableService(service);\r\n return service;\r\n}\r\n\r\nexport const isPayableService = (service: IServiceDetails) => {\r\n return advanceOrFullPrice(service.PaymentMethod) && service.VatPercentage !== null\r\n && service.ItemName !== null && service.Price !== null && service.Currency !== null;\r\n}\r\n\r\nexport const calculateGrossPriceWithPersonCount = (data: IServicePriceData) => {\r\n const GrossPrice = calculateGrossPrice(data);\r\n return data.PersonCount ? GrossPrice * data.PersonCount : GrossPrice;\r\n}\r\n\r\nexport const calculateGrossPrice = (data: IServicePriceData) => {\r\n if (data.Price && data.Currency) {\r\n const rawPrice = ((data.Price as number) * (1 + (data.VatPercentage as number)));\r\n\r\n return (\r\n advanceOrFullPrice(data.PaymentMethod) ?\r\n (data.Currency === 'EUR' ?\r\n Math.round((rawPrice + Number.EPSILON) * 100) / 100\r\n : Math.round(rawPrice))\r\n : 0\r\n )\r\n }\r\n return 0;\r\n}\r\n\r\nexport const calculateSubtotal = (servicePriceData: IServicePriceData[]): IServiceSubtotal => {\r\n return {\r\n Price: servicePriceData.map((data) => calculateGrossPriceWithPersonCount(data)).reduce((sum, current) => sum + current, 0),\r\n Currency: servicePriceData[0].Currency\r\n }\r\n}","import { handleError } from './errorHandler';\r\nimport { IScheduleResponse, IScheduleLists, ISchedule } from './../../entities/schedule';\r\nimport fetcher from '../fetcher';\r\nimport { IDTO } from 'src/entities/common';\r\nimport isAfter from 'date-fns/isAfter';\r\nimport { IPaymentReservationDetails } from 'src/entities/paymentReservation';\r\n\r\nconst filterPast = (scheduleLists: IScheduleLists): IScheduleLists =>\r\n Object.fromEntries(Object.entries(scheduleLists)\r\n .map(([date, list]) => [date,\r\n list.filter(schedule =>\r\n isAfter(new Date(schedule.Start), new Date())\r\n )]\r\n )\r\n .filter(([list]) =>\r\n list.length > 0\r\n )\r\n );\r\n\r\nexport const getScheduleList = async (calendarId: number, startDate: string, endDate: string, includePast?: true): Promise => {\r\n const params =\r\n new URLSearchParams({\r\n StartDate: startDate,\r\n EndDate: endDate\r\n }).toString();\r\n\r\n return fetcher.get>(`/${calendarId}/Schedules?${params}`)\r\n .then(respJson => respJson.Data.Schedules)\r\n .then(includePast ? data => data : filterPast)\r\n .catch(e => { throw handleError(e) });\r\n};\r\n\r\nexport const getScheduleById = async (paymentReservation: IPaymentReservationDetails): Promise => {\r\n \r\n const { CalendarId, ScheduleId, StartTime, EndTime } = paymentReservation;\r\n\r\n if (!CalendarId) {\r\n return;\r\n }\r\n\r\n return getScheduleList(CalendarId, StartTime, EndTime, true)\r\n .then(Object.values)\r\n .then(schedules =>\r\n schedules.flat().find(sch => sch.Id === ScheduleId)\r\n )\r\n .catch(e => { throw handleError(e) });\r\n};","import Moment from 'moment';\r\nimport MomentTimeZone from 'moment-timezone';\r\nimport { AppLocale } from 'src/models/modules';\r\n\r\nexport const arriveTimeFormat = 'HH:mm:ss';\r\n\r\nexport const setTimeOnDate = (date: string, time: string): string => {\r\n return date.split('T')[0] + 'T' + time + 'Z';\r\n}\r\n\r\nexport const getDate = (dateTime: string): string => {\r\n return dateTime.split('T')[0];\r\n}\r\n\r\nexport const getTime = (dateTime: string): string => {\r\n if (dateTime.includes('T')) {\r\n let time = dateTime.split('T')[1];\r\n if (time && time.includes('+')) {\r\n time = time.split('+')[0];\r\n }\r\n if (time && time.includes('Z')) {\r\n time = time.split('Z')[0];\r\n }\r\n if (time && time.includes('.')) {\r\n time = time.split('.')[0];\r\n }\r\n return time;\r\n }\r\n return ''\r\n}\r\n\r\nexport const getUtcDateTime = (time: string, date?: string): string => {\r\n date = getDate(date || Moment(new Date()).toISOString());\r\n return (Moment(date + 'T' + time).toISOString())\r\n}\r\n\r\nexport const getUtcTime = (time: string): string => {\r\n return getTime(getUtcDateTime(time));\r\n}\r\n\r\nexport const getOffsetString = (timeZone: string) => {\r\n const localOffset = Moment().format('Z');\r\n const offset = MomentTimeZone.tz(timeZone).format('Z');\r\n return localOffset === offset ? '' : ` (GMT${offset})`;\r\n}\r\n\r\nexport const isValidTime = (dateTime: string | null, freeIntervals: string[]): boolean => {\r\n if (!dateTime) {\r\n return false;\r\n }\r\n const time = getTime(dateTime);\r\n return !!(freeIntervals.find(t => time.startsWith(t)));\r\n}\r\n\r\nexport const isValidDate = (dateTime: string, freeDays: string[] | null): boolean => {\r\n const date = getDate(dateTime);\r\n return !!(freeDays && freeDays.find(d => getDate(d) === date));\r\n}\r\n\r\nexport const getYearMonthFormat = (locale: string): string => {\r\n return locale === AppLocale.Hu ? 'yyyy. MMMM' : 'MMMM yyyy';\r\n}"],"names":["getPaymentNeed","isPaymentEnabled","isPayable","getPaymentNeedWithPrice","service","Payable","Price","advanceOrFullPrice","paymentMethod","Advance","FullPrice","getSubtotal","reservations","servicePriceData","filter","reservation","getServiceFromReservation","map","length","isValidSubtotal","subTotal","Service","Timetable","getServicesFromReservations","reservationList","r","isReservationEndUserDirty","reservationEndUser","isDirty","InvoiceDetails","Country","object","Object","values","some","x","undefined","transformResponse","response","result","ReservedReservations","PaymentReservationResponse","constructor","Array","paymentReservationResponse","isSame","e1","e2","Id","TransactionStatus","isPaymentReservationResponse","variableToCheck","PaymentUrl","ReservationStateType","ReservationRequestOrder","isSignUpUser","user","Password","isEmailRequired","props","isAuthenticated","requiredFieldInfo","IsRegEmailRequired","IsEmailRequired","isPhoneNumberRequired","IsRegPhoneRequired","IsPhoneRequired","isNameRequired","IsRegNameRequired","IsNameRequired","reservationValueChanged","newData","data","type","Calendar","newAppointment","Date","appointment","personCount","newApp","app","newDate","startTime","date","isWithinModificationPeriod","start","StartTime","now","minimumTimeUntilStart","MinTimeModify","asMinutes","diff","populateReservations","items","find","ServiceId","calendar","CalendarId","hasSchedule","ScheduleId","getSchedule","Error","EndTime","then","schedules","flat","sch","Promise","reject","catch","e","reservationModelToServiceSum","model","event","Currency","PaymentMethod","VatPercentage","PersonCount","fillPayableFields","services","fillPayableField","isPayableService","ItemName","calculateGrossPriceWithPersonCount","GrossPrice","calculateGrossPrice","rawPrice","Math","round","Number","EPSILON","calculateSubtotal","reduce","sum","current","filterPast","scheduleLists","fromEntries","entries","schedule","Start","getScheduleList","calendarId","startDate","endDate","includePast","params","URLSearchParams","StartDate","EndDate","toString","get","respJson","Data","Schedules","getScheduleById","paymentReservation","arriveTimeFormat","setTimeOnDate","time","split","getDate","dateTime","getTime","includes","getOffsetString","timeZone","localOffset","format","offset","isValidTime","freeIntervals","t","startsWith","isValidDate","freeDays","d","getYearMonthFormat","locale","Hu"],"sourceRoot":""}