import axiosClient from "./axiosClient";
import { AuthResponse } from "../types/user";

export const authApi = {
  login: async (username: string, password: string): Promise<AuthResponse & { requires2FA?: boolean; message?: string }> => {
    const { data } = await axiosClient.post("/login", { username, password });
    return data;
  },

  register: async (
    username: string,
    password: string,
    confirmPassword: string
  ) => {
    const { data } = await axiosClient.post("/register", {
      username,
      password,
      confirmPassword,
    });
    return data;
  },

  checkStatus: async (): Promise<AuthResponse> => {
    const { data } = await axiosClient.get<AuthResponse>("/auth/status");
    return data;
  },

  logout: async () => {
    await axiosClient.post("/logout");
  },
};
