ifixkart-admin/services/api/roleNotificationSettingsService.ts

47 lines
1.3 KiB
TypeScript

import { apiFetch } from './client';
export interface RoleNotificationSetting {
setting_id: string;
role_name: string;
event_type: string;
channel_email: boolean;
channel_whatsapp: boolean;
}
export interface RoleNotificationSettingCreate {
role_name: string;
event_type: string;
channel_email?: boolean;
channel_whatsapp?: boolean;
}
export interface RoleNotificationSettingUpdate {
channel_email?: boolean;
channel_whatsapp?: boolean;
}
export const roleNotificationSettingsService = {
getSettings: async () => {
return apiFetch<RoleNotificationSetting[]>('/api/v1/settings/notifications/');
},
createSetting: async (payload: RoleNotificationSettingCreate) => {
return apiFetch<RoleNotificationSetting>('/api/v1/settings/notifications/', {
method: 'POST',
body: JSON.stringify(payload),
});
},
updateSetting: async (settingId: string, payload: RoleNotificationSettingUpdate) => {
return apiFetch<RoleNotificationSetting>(`/api/v1/settings/notifications/${settingId}`, {
method: 'PUT',
body: JSON.stringify(payload),
});
},
deleteSetting: async (settingId: string) => {
return apiFetch(`/api/v1/settings/notifications/${settingId}`, {
method: 'DELETE',
});
}
};