import { useMutation } from "react-query"; import { useHttp } from "@/hooks/useHttp"; import { setParametersToStrategyRunner } from "@/libs/helpers/strategy-service.helper"; import { useServerDataCtx } from "@/providers/server-data-provider/server-data-provider"; import type { IHotelValidateParameters } from "./hotel-validate-service.types"; interface IHotelValidateResponse { success: boolean; result: Result2; } interface Result2 { serviceResponse: ServiceResponse; code: string; outputData?: any; type: number; name: string; status: number; } interface ServiceResponse { success: boolean; result: Result; errors: Error[]; } interface Error { code: string; innerExceptionDetail: null; exceptionDetail: string; message: string; source: number; } interface Result { masterPassUserData: MasterPassUserData; masterPassPciDssPaymentRule?: any; transactionKey: string; saleAgreementText: string; preSaleAgreementText: string; } interface MasterPassUserData { countryCode: number; areaCode: number; number: string; userId: string; phone: string; msisdn: string; referenceNumber: string; token: string; macroMerchantId?: any; orderId: string; recurringOrderId: string; payToken?: any; selected: boolean; isLoggedIn: boolean; jollyPhone?: any; isSecurityOTPValidationRequired: boolean; isSecurityOTPValidationDone: boolean; cartId?: any; } export const useHotelValidateMutation = () => { const { strategyKeys } = useServerDataCtx(); const http = useHttp("wl-display-api"); const service = (variables: IHotelValidateParameters) => http.post( "/api/v1/strategy/run", setParametersToStrategyRunner(variables, strategyKeys.hotelValidate), ); return useMutation({ mutationFn: service, mutationKey: "hotelValidate" }); };