import axios, { AxiosInstance, AxiosResponse } from 'axios'; export interface ServiceOptions { headers?: Record; params?: Record; } export interface AssetBrandDropdownOption { _id: string; key: number; name: string; } export interface GetAssetBrandDropdownResponse { data: AssetBrandDropdownOption[]; } export const API = ({ headers = {}, params = {}, }: ServiceOptions = {}): AxiosInstance => { const user = JSON.parse(localStorage.getItem('user') ?? '{}'); const BASE_URL = import.meta.env.VITE_APP_ATTRIBUTES_API; const instance = axios.create({ baseURL: `${BASE_URL}/v2/brands`, headers: { 'Content-type': 'application/json', 'Authorization': `Bearer ${user.token}`, ...headers, }, params, }); return instance; }; const AssetBrandService = { getAssetBrandDropdown: (): Promise< AxiosResponse > => { return API().get('/dropdown'); }, }; export default AssetBrandService;