import apiClient from '@/api/client'; import toast from 'react-hot-toast'; export interface Department { departmentId: string; name: string; image?: string; para1: string; para2: string; para3: string; facilities: string; services: string; isActive?: boolean; sortOrder?: number; } export const getDepartmentsApi = async () => { const res = await apiClient.get('/departments/getAll?admin=true'); return res.data; }; export const createDepartmentApi = async (data: { departmentId: string; name: string; para1?: string; para2?: string; para3?: string; facilities?: string; services?: string; }) => { try { const res = await apiClient.post('/departments', data); toast.success('Department created successfully'); return res.data; } catch (error: any) { toast.error(error?.response?.data?.message || 'Failed to create department'); throw error; } }; export const updateDepartmentApi = async ( departmentId: string, data: { name?: string; para1?: string; para2?: string; para3?: string; facilities?: string; services?: string; } ) => { try { const res = await apiClient.put(`/departments/${departmentId}`, data); toast.success('Department updated successfully'); return res.data; } catch (error: any) { toast.error(error?.response?.data?.message || 'Failed to update department'); throw error; } }; export const deleteDepartmentApi = async (departmentId: string) => { try { const res = await apiClient.delete(`/departments/${departmentId}`); toast.success('Department deleted successfully'); return res.data; } catch (error: any) { toast.error(error?.response?.data?.message || 'Failed to delete department'); throw error; } };