import type { ApiResponse } from '@/types/apiResponse';
import type {
  ConfirmEmailOtpRequest,
  ConfirmForgetPassCodeRequest,
  ConfirmOtpResponse,
  ConfirmSmsOtpRequest,
  GetUserStatusByPhoneNumberOrEmailRequest,
  GetUserStatusByPhoneNumberOrEmailResponse,
  LoginOrSignUpWithGoogleRequest,
  LoginOrSignUpWithGoogleResponse,
  LoginRequest,
  LoginResponse,
  PasswordLoginRequest,
  ResetPasswordRequest,
  ResetPasswordResponse,
  SendEmailOtpRequest,
  SendForgetPassCodeRequest,
  SendSmsOtpRequest,
} from '../types/userTypes';
import apiClient from '@/lib/apiClient';

// GetUserStatusByPhoneNumberOrEmail

export const getUserStatusByPhoneNumberOrEmail = async (
  body: GetUserStatusByPhoneNumberOrEmailRequest,
) => {
  return apiClient.post<GetUserStatusByPhoneNumberOrEmailResponse>(
    'User/GetUserStatusByPhoneNumberOrEmail',
    body,
  );
};

export const loginOrSignUpWithOtp = async (body: LoginRequest) => {
  return apiClient.post<LoginResponse>('User/LoginOrSignUpWithOtp', body);
};

export const loginWithPassword = async (body: PasswordLoginRequest) => {
  return apiClient.post<LoginResponse>('User/LoginWithPassword', body);
};

export const sendSmsOtp = async (body: SendSmsOtpRequest) => {
  return apiClient.post<ApiResponse>('User/SendSmsOtp', body);
};

export const sendEmailOtp = async (body: SendEmailOtpRequest) => {
  return apiClient.post<ApiResponse>('User/SendEmailOtp', body);
};

export const confirmSmsOtp = async (body: ConfirmSmsOtpRequest) => {
  return apiClient.post<ConfirmOtpResponse>('User/ConfirmSmsOtp', body);
};

export const confirmEmailOtp = async (body: ConfirmEmailOtpRequest) => {
  return apiClient.post<ConfirmOtpResponse>('User/ConfirmEmailOtp', body);
};

export const resetPassword = async (body: ResetPasswordRequest) => {
  return apiClient.post<ResetPasswordResponse>('User/ResetPassword', body);
};

export const sendForgetPassCode = async (body: SendForgetPassCodeRequest) => {
  return apiClient.post<ApiResponse>('User/SendForgetPassCode', body);
};

export const confirmForgetPassCode = async (
  body: ConfirmForgetPassCodeRequest,
) => {
  return apiClient.post<ConfirmOtpResponse>('User/ConfirmForgetPassCode', body);
};

export const loginOrSignUpWithGoogle = async (
  body: LoginOrSignUpWithGoogleRequest,
) => {
  return apiClient.post<LoginOrSignUpWithGoogleResponse>(
    'User/LoginOrSignUpWithGoogle',
    body,
  );
};

export const logOut = async () => {
  return apiClient.post<ApiResponse>('User/LogOut', {});
};
