import { sendOTP } from "@/app/types/ContinueWithPhone";
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

// Define the base URL for the API
const baseURL = process.env.NEXT_PUBLIC_API_URL;

export const sendOtp = createApi({
  reducerPath: "sendOtp",
  baseQuery: fetchBaseQuery({ baseUrl: baseURL }),
  endpoints: (builder) => ({
    // RegisterAccount endpoint as a mutation because it modifies data
    sendOTP: builder.mutation<
      sendOTP,
      sendOTP>       
      //match API request and response structure
      ({
      query: (otpdata) => ({
        url: "send_otp",
        method: "POST",
        body: otpdata,
      }),
    }),
  }),
});

export const { useSendOTPMutation } = sendOtp; //export hook
