ifixkart-admin/New admin panel/ikixkart-dashboard/services/api/notificationTemplateService.ts
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +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 })
});
}
};