ifixkart-admin/services/api/notificationTemplateService.ts
adithiyan b5837073e7 feat: add warranties, refunds, notification templates, user POS analytics, credit & delivery services
New pages:
- app/(admin)/warranties/ — full warranty management with claims
- app/(admin)/refunds/ — refund management
- app/(admin)/notification-templates/ — email/SMS template editor
- app/(admin)/user-pos-analytics/ — per-user POS analytics

New components:
- components/quotations/ — quotation components
- components/ui/PartNumbersModal.tsx — part numbers selection

New services:
- creditService.ts, deliverySettingsService.ts
- notificationTemplateService.ts, roleNotificationSettingsService.ts

Updated:
- Sidebar navigation, dashboard, orders, POS sessions, products
- Bulk quotations, CRM leads/quotations, notifications gateway
- settings, service invoices, quotes, technician, users pages
- adminService, billingFinanceService, catalogService, client
- inventoryPosService, notificationGatewayService, openwaService, userService
- Removed pos-sync page (merged into POS sessions)
2026-10-13 22:05:55 +05:30

84 lines
2.3 KiB
TypeScript

import { apiFetch } from './client';
export interface EventVariable {
name: string;
description: string;
example: string;
}
export interface EventRegistry {
event_key: string;
description: string;
variables: EventVariable[];
}
export interface NotificationTemplate {
template_id: string;
tenant_id: string;
event_key: string;
name: string;
channel: string;
subject?: string;
body_content: string;
variables: string[];
is_active: boolean;
created_at: string;
updated_at: string;
}
export interface NotificationTemplateCreate {
event_key: string;
name: string;
channel: string;
subject?: string;
body_content: string;
is_active: boolean;
}
export interface NotificationTemplateUpdate {
name?: string;
subject?: string;
body_content?: string;
is_active?: boolean;
}
export const notificationTemplateService = {
getEvents: async (): Promise<EventRegistry[]> => {
return apiFetch<EventRegistry[]>('/api/v1/notification-templates/events');
},
getTemplates: async (): Promise<NotificationTemplate[]> => {
return apiFetch<NotificationTemplate[]>('/api/v1/notification-templates');
},
createTemplate: async (data: NotificationTemplateCreate): Promise<NotificationTemplate> => {
return apiFetch<NotificationTemplate>('/api/v1/notification-templates', {
method: 'POST',
body: JSON.stringify(data)
});
},
updateTemplate: async (id: string, data: NotificationTemplateUpdate): Promise<NotificationTemplate> => {
return apiFetch<NotificationTemplate>(`/api/v1/notification-templates/${id}`, {
method: 'PUT',
body: JSON.stringify(data)
});
},
toggleActivation: async (id: string, isActive: boolean): Promise<NotificationTemplate> => {
return apiFetch<NotificationTemplate>(`/api/v1/notification-templates/${id}/${isActive ? 'activate' : 'deactivate'}`, {
method: 'PATCH'
});
},
previewTemplateRaw: async (body_content: string, context: Record<string, any>, subject?: string): Promise<{ subject: string; body: string }> => {
const params = new URLSearchParams();
params.append('body_content', body_content);
if (subject) params.append('subject', subject);
return apiFetch<{ subject: string; body: string }>(`/api/v1/notification-templates/preview?${params.toString()}`, {
method: 'POST',
body: JSON.stringify({ context })
});
}
};