import axios from 'axios'; import type { User } from '../../share/types.ts'; interface UsersResponse { data: User[]; pagination: { total: number; current: number; pageSize: number; totalPages: number; }; } interface UserResponse { data: User; message?: string; } interface UserCreateResponse { message: string; data: User; } interface UserUpdateResponse { message: string; data: User; } interface UserDeleteResponse { message: string; id: number; } export const UserAPI = { getUsers: async (params?: { page?: number, limit?: number, search?: string }): Promise => { try { const response = await axios.get('/users', { params }); return response.data; } catch (error) { throw error; } }, getUser: async (userId: number): Promise => { try { const response = await axios.get(`/users/${userId}`); return response.data; } catch (error) { throw error; } }, createUser: async (userData: Partial): Promise => { try { const response = await axios.post('/users', userData); return response.data; } catch (error) { throw error; } }, updateUser: async (userId: number, userData: Partial): Promise => { try { const response = await axios.put(`/users/${userId}`, userData); return response.data; } catch (error) { throw error; } }, deleteUser: async (userId: number): Promise => { try { const response = await axios.delete(`/users/${userId}`); return response.data; } catch (error) { throw error; } } };