"use serve"

/* eslint-disable @typescript-eslint/no-explicit-any */
import { AccountInput, RoleInput, UpdateAccountInput } from "@/lib/features/admin/account/type";


import axiosInstance from "@/lib/constant";
import { AxiosResponse } from "axios";


export const createAccount = async (body: AccountInput): Promise<AxiosResponse<AccountInput, any>> => {
   return await axiosInstance.post<AccountInput>('/user/add-user', body);
};

export const getAccounts = () => {
   return axiosInstance.get(`user/users`);
}

export const geOneAccount = (accountId: number) => {
   return axiosInstance.get(`user/view-user?u=${accountId}`);
}

export const updateAccount = async (body: UpdateAccountInput): Promise<AxiosResponse<UpdateAccountInput, any>> => {
   return await axiosInstance.post<UpdateAccountInput>('/user/update-user', body);
};


export const getRoles = () => {
   return axiosInstance.get(`user/roles`);
}


export const createRole = async (body: RoleInput): Promise<AxiosResponse<RoleInput, any>> => {
   return await axiosInstance.post<RoleInput>('/user/add-role', body);
};





