import { apiFetch } from './client'; import { API_ENDPOINTS } from './config'; export interface UserResponse { user_id: string; employee_code: string | null; first_name: string; last_name: string; display_name: string | null; email: string; phone: string; profile_image_id: string | null; gender: string | null; dob: string | null; department_id: string; designation_id: string; role_id: string; manager_id: string | null; is_active: boolean; email_verified: boolean; phone_verified: boolean; created_at: string; last_login?: string | null; last_activity?: string | null; } export interface UserCreate { first_name: string; last_name: string; display_name?: string; email: string; phone: string; password: string; gender?: string; dob?: string; department_id: string; designation_id: string; role_id: string; manager_id?: string; } export interface UserUpdate { first_name?: string; last_name?: string; display_name?: string; email?: string; phone?: string; password?: string; gender?: string; dob?: string; department_id?: string; designation_id?: string; role_id?: string; manager_id?: string; profile_image_id?: string; } export const userService = { async getAll(skip = 0, limit = 100): Promise { return apiFetch( `${API_ENDPOINTS.USERS_ALL}?skip=${skip}&limit=${limit}` ); }, async getProfile(userId: string): Promise { return apiFetch(API_ENDPOINTS.USERS_PROFILE(userId)); }, async create(data: UserCreate): Promise { return apiFetch(API_ENDPOINTS.USERS_CREATE, { method: 'POST', body: JSON.stringify(data), }); }, async update(userId: string, data: UserUpdate): Promise { return apiFetch(API_ENDPOINTS.USERS_UPDATE(userId), { method: 'PUT', body: JSON.stringify(data), }); }, async delete(userId: string): Promise<{ detail: string }> { return apiFetch<{ detail: string }>(API_ENDPOINTS.USERS_DELETE(userId), { method: 'DELETE', }); }, };