import { CompanyRegisterData } from "../..";
import { AuthFormData, AuthMethod } from "../../types/auth";
import { useApiInterceptor } from "./useApiInterceptor";

export const useCompanyRegister = async ( {
    companyName,
    companyEmail,
    companyPhone,
    companyPassword,
    loginMethod=AuthMethod.Email
}: CompanyRegisterData ) => {
    try {
        const response: any = await useApiInterceptor().post(
          `/register-company`,
          {
            email: companyEmail,
            password: companyPassword,
            name: companyName,
            contactPhone: companyPhone,
            loginMethod,
          }
        );
        if(response.status === 201){
            return {
                message: response.data.message,
                status: response.status
            }
        }
    } catch (error:any) {
        console.error('Error fetching API POST (Register Company):', error);
        return {
            message: error.response.data,
            status: error.response.status
        }
    }
}

  