- Fix audit_log handler multi-tenant bug: use Extension<TenantContext>
instead of hardcoded default_tenant_id
- Fix sendMessage route mismatch: frontend /messages/send → /messages
- Add POST /users/{id}/roles backend route for role assignment
- Add task.completed event payload: started_by + instance_id for
notification delivery
- Add audit log viewer frontend page (AuditLogViewer.tsx)
- Add language management frontend page (LanguageManager.tsx)
- Add api/auditLogs.ts and api/languages.ts modules
89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
import client from './client';
|
|
import type { PaginatedResponse } from './users';
|
|
|
|
export interface MessageInfo {
|
|
id: string;
|
|
tenant_id: string;
|
|
template_id?: string;
|
|
sender_id?: string;
|
|
sender_type: string;
|
|
recipient_id: string;
|
|
recipient_type: string;
|
|
title: string;
|
|
body: string;
|
|
priority: string;
|
|
business_type?: string;
|
|
business_id?: string;
|
|
is_read: boolean;
|
|
read_at?: string;
|
|
is_archived: boolean;
|
|
status: string;
|
|
sent_at?: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface SendMessageRequest {
|
|
title: string;
|
|
body: string;
|
|
recipient_id: string;
|
|
recipient_type?: string;
|
|
priority?: string;
|
|
template_id?: string;
|
|
business_type?: string;
|
|
business_id?: string;
|
|
}
|
|
|
|
export interface MessageQuery {
|
|
page?: number;
|
|
page_size?: number;
|
|
is_read?: boolean;
|
|
priority?: string;
|
|
business_type?: string;
|
|
status?: string;
|
|
}
|
|
|
|
export async function listMessages(query: MessageQuery = {}) {
|
|
const { data } = await client.get<{ success: boolean; data: PaginatedResponse<MessageInfo> }>(
|
|
'/messages',
|
|
{ params: { page: query.page ?? 1, page_size: query.page_size ?? 20, ...query } },
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function getUnreadCount() {
|
|
const { data } = await client.get<{ success: boolean; data: { count: number } }>(
|
|
'/messages/unread-count',
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
export async function markRead(id: string) {
|
|
const { data } = await client.put<{ success: boolean }>(
|
|
`/messages/${id}/read`,
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function markAllRead() {
|
|
const { data } = await client.put<{ success: boolean }>(
|
|
'/messages/read-all',
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function deleteMessage(id: string) {
|
|
const { data } = await client.delete<{ success: boolean }>(
|
|
`/messages/${id}`,
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function sendMessage(req: SendMessageRequest) {
|
|
const { data } = await client.post<{ success: boolean; data: MessageInfo }>(
|
|
'/messages',
|
|
req,
|
|
);
|
|
return data.data;
|
|
}
|