feat: insurance crud
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import apiClient from '@/api/client';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
export interface InsurancePartner {
|
||||
id?: number;
|
||||
name: string;
|
||||
logo: string;
|
||||
websiteUrl?: string;
|
||||
sortOrder: number;
|
||||
isActive: boolean;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export const getInsurancePartnersApi = async () => {
|
||||
const res = await apiClient.get('/insurance-partners/getAll');
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const getInsurancePartnerApi = async (id: number) => {
|
||||
const res = await apiClient.get(`/insurance-partners/${id}`);
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const getActiveInsurancePartnersApi = async () => {
|
||||
const res = await apiClient.get('/insurance-partners/active');
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const createInsurancePartnerApi = async (data: Partial<InsurancePartner>) => {
|
||||
try {
|
||||
const res = await apiClient.post('/insurance-partners', data);
|
||||
toast.success('Insurance partner created successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to create insurance partner');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateInsurancePartnerApi = async (id: number, data: Partial<InsurancePartner>) => {
|
||||
try {
|
||||
const res = await apiClient.put(`/insurance-partners/${id}`, data);
|
||||
toast.success('Insurance partner updated successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to update insurance partner');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteInsurancePartnerApi = async (id: number) => {
|
||||
try {
|
||||
const res = await apiClient.delete(`/insurance-partners/${id}`);
|
||||
toast.success('Insurance partner deleted successfully');
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
toast.error(error?.response?.data?.message || 'Failed to delete insurance partner');
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user