ifixkart-admin/services/api/notificationGatewayService.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

88 lines
2.3 KiB
TypeScript

import { apiFetch } from './client';
export interface WhatsAppStatus {
session_id: string;
tenant_id: string;
session_name: string;
status: string;
battery_level?: number;
last_ping_at?: string;
}
export interface WhatsAppQR {
session_id: string;
session_name: string;
status: string;
qr_code_base64?: string;
}
export interface NotificationLog {
notification_id: string;
tenant_id: string;
recipient: string;
channel: string;
status: string;
subject?: string;
message_body: string;
created_at: string;
}
export interface DeadLetterLog {
dlq_id: string;
tenant_id: string;
notification_id: string;
reason: string;
failed_at: string;
is_resolved: boolean;
}
export const notificationGatewayService = {
getWhatsAppStatus: async () => {
return apiFetch<WhatsAppStatus>('/api/v1/notifications/whatsapp-gateway/status');
},
getWhatsAppQR: async () => {
return apiFetch<WhatsAppQR>('/api/v1/notifications/whatsapp-gateway/qr');
},
getWhatsAppPairingCode: async (phoneNumber: string) => {
return apiFetch<{ session_id: string; phone_number: string; pairing_code: string; status: string }>(
`/api/v1/notifications/whatsapp-gateway/pairing-code?phoneNumber=${encodeURIComponent(phoneNumber)}`,
{ method: 'POST' }
);
},
getNotificationLogs: async () => {
return apiFetch<NotificationLog[]>('/api/v1/notifications/logs');
},
getDlqLogs: async () => {
return apiFetch<DeadLetterLog[]>('/api/v1/notifications/dlq');
},
resolveDlq: async (dlqId: string) => {
return apiFetch(`/api/v1/notifications/dlq/${dlqId}/resolve`, {
method: 'POST',
});
},
dispatch: async (payload: { recipient: string; channel: string; subject?: string; message_body: string }) => {
return apiFetch('/api/v1/notifications/dispatch', {
method: 'POST',
body: JSON.stringify(payload),
});
},
dispatchEntity: async (payload: {
channel: 'EMAIL' | 'WHATSAPP' | 'BOTH';
notification_type: 'QUOTATION' | 'INVOICE' | 'REPAIR_TICKET' | 'LEAD_QUALIFIED';
entity_id: string;
idempotency_key?: string;
custom_note?: string;
}) => {
return apiFetch<NotificationLog[]>('/api/v1/notifications/dispatch-entity', {
method: 'POST',
body: JSON.stringify(payload),
});
}
};