import apiClient from "@/lib/axiosClient";
import { API_ENDPOINTS } from "@/lib/apiEndpoints";
import { LoginPayload, RegisterPayload } from "@/types/auth";

export const authService = {
  login: (payload: LoginPayload) =>
    apiClient.post(API_ENDPOINTS.AUTH.LOGIN, payload).then((r) => r.data),

  register: (payload: RegisterPayload) =>
    apiClient.post(API_ENDPOINTS.AUTH.REGISTER, payload).then((r) => r.data),

  logout: (deviceToken?: string) =>
    apiClient
      .post(API_ENDPOINTS.AUTH.LOGOUT, deviceToken ? { device_token: deviceToken, device_type: "5" } : {})
      .then((r) => r.data),

  forgotPassword: (email: string) =>
    apiClient
      .post(API_ENDPOINTS.AUTH.FORGOT_PASSWORD, { email })
      .then((r) => r.data),

  resetPassword: (
    token: string,
    password: string,
    password_confirmation: string,
  ) =>
    apiClient
      .post(API_ENDPOINTS.AUTH.RESET_PASSWORD, { token, password, password_confirmation })
      .then((r) => r.data),
};
