import { useMutation } from "react-query"; import type { MutationOptions } from "@/@types/types/query.types"; import { useHttp } from "@/hooks/useHttp"; import { getEnvs } from "@/libs/environment/env"; import type { ResendOtpPayload } from "./resend-otp.services.types"; import { ResendOtpResultSerializer } from "./resend-otp-services-serializer"; export const useResendOtpMutation = (options?: MutationOptions) => { const http = useHttp("masterpass-api"); const env = getEnvs(); const service = (variables: ResendOtpPayload) => http .post("/resendOtp", { sendSms: env.masterpassSendSms, dateTime: new Date().toISOString(), // anlık zaman validationRefNo: variables.validationRefNo, // bir önceki istekten dönen token serviceUrl: env.masterpassUrl, clientId: env.masterpassClientId, version: env.masterpassVersion, clientType: env.masterpassClientType, sendSmsLanguage: env.masterpassSendSmsLanguage, clientIp: "", }) .then((res) => ResendOtpResultSerializer(res.data)); return useMutation({ mutationFn: service, mutationKey: "resend-otp-mutation", ...options, }); };