import { AxiosRequestConfig } from "axios";
import axiosInstance from "../http/axiosInstance";
import { UserCreds, UserData } from "../interfaces/auth";
import { BASE_URL } from "../constants";
import { IUser } from "../interfaces/user";

const config: AxiosRequestConfig = {
    baseURL: BASE_URL.auth
}

export default class UserService {
    static async createUser(data: IUser) {
        return await axiosInstance.post(`/auth/user`, data, config)
    }

    static async getCurrentUser(token: string) {
        return await axiosInstance.get(`/auth/get_current_user/${token}`, config)
    }

    static async getUsers() {
        return await axiosInstance.get(`/auth/user`, config)
    }

    // static async deleteUser(id: number) {
    //     return await axiosInstance.delete(`/auth/user/${id}`)
    // }

    static async getUser(id: number) {
        return await axiosInstance.get(`/auth/user/${id}`, config)
    }

    static async updatePassword(data: UserCreds) {
        return await axiosInstance.put(`/auth/user/password_change`, data, config)
    }

    static async updateUser(data: UserData) {
        return await axiosInstance.put(`/auth/user`, data, config)
    }
}