56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import { patchNotification } from '../../api/documentRevision';
|
|
|
|
export type DocNotificationItem = {
|
|
id: number;
|
|
type: string;
|
|
title: string;
|
|
body: string;
|
|
status: string;
|
|
created_at?: string;
|
|
};
|
|
|
|
export function DocumentNotificationList(props: {
|
|
items: DocNotificationItem[];
|
|
onChanged?: () => void;
|
|
}) {
|
|
return (
|
|
<ul aria-label="文档变更通知" style={{ listStyle: 'none', padding: 0, margin: 0 }}>
|
|
{props.items.map((n) => (
|
|
<li key={n.id} style={{ borderBottom: '1px solid #eee', padding: '8px 0' }}>
|
|
<div><strong>{n.title}</strong></div>
|
|
<div style={{ fontSize: 13 }}>{n.body}</div>
|
|
<div style={{ display: 'flex', gap: 6, marginTop: 4 }}>
|
|
<button
|
|
type="button"
|
|
onClick={async () => {
|
|
await patchNotification(n.id, 'read');
|
|
props.onChanged?.();
|
|
}}
|
|
>
|
|
已读
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={async () => {
|
|
await patchNotification(n.id, 'acted');
|
|
props.onChanged?.();
|
|
}}
|
|
>
|
|
已处理
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={async () => {
|
|
await patchNotification(n.id, 'dismissed');
|
|
props.onChanged?.();
|
|
}}
|
|
>
|
|
忽略
|
|
</button>
|
|
</div>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
);
|
|
}
|