Implement the complete message center with: - Database migrations for message_templates, messages, message_subscriptions tables - erp-message crate with entities, DTOs, services, handlers - Message CRUD, send, read/unread tracking, soft delete - Template management with variable interpolation - Subscription preferences with DND support - Frontend: messages page, notification panel, unread count badge - Server integration with module registration and routing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
978 B
TypeScript
41 lines
978 B
TypeScript
import client from './client';
|
|
import type { PaginatedResponse } from './users';
|
|
|
|
export interface MessageTemplateInfo {
|
|
id: string;
|
|
tenant_id: string;
|
|
name: string;
|
|
code: string;
|
|
channel: string;
|
|
title_template: string;
|
|
body_template: string;
|
|
language: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface CreateTemplateRequest {
|
|
name: string;
|
|
code: string;
|
|
channel?: string;
|
|
title_template: string;
|
|
body_template: string;
|
|
language?: string;
|
|
}
|
|
|
|
export async function listTemplates(page = 1, pageSize = 20) {
|
|
const { data } = await client.get<{ success: boolean; data: PaginatedResponse<MessageTemplateInfo> }>(
|
|
'/message-templates',
|
|
{ params: { page, page_size: pageSize } },
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function createTemplate(req: CreateTemplateRequest) {
|
|
const { data } = await client.post<{ success: boolean; data: MessageTemplateInfo }>(
|
|
'/message-templates',
|
|
req,
|
|
);
|
|
return data.data;
|
|
}
|