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

// Define the base URL for the API
const baseURL = "https://handyman.theprimocys.com/api/";

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

export const { useRegisterAccountMutation } = RegisterUser; //export hook
