
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import { baseQuery } from "../baseQuery";

export const authApi = createApi({
  reducerPath: "authApi",
  baseQuery: baseQuery,

  tagTypes: ["profile", "Transaction"],


  endpoints: (builder) => ({
    // Login

    login: builder.mutation({
      query: (credentials) => ({
        url: "/website/send-otp",
        method: "POST",
        body: credentials,
      }),
    }),

    verifyOtp: builder.mutation({
      query: (credentials) => ({
        url: "/website/user/verify-otp",
        method: "POST",
        body: credentials,
      }),
    }),

    register: builder.mutation({
      query: (credentials) => ({
        url: "/website/user/register",
        method: "POST",
        body: credentials,
      }),
    }),

    logoutUser: builder.mutation({
      query: () => ({
        url: "/website/user/logout",
        method: "POST"
      })
    })
  }),
});

export const {
  useLoginMutation,
  useVerifyOtpMutation,
  useRegisterMutation,
  useLogoutUserMutation
} = authApi;