40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
const categoryLabels: Record<string, string> = {
|
|
SYSTEM: '系统通知',
|
|
SYSTEM_NOTICE: '系统通知',
|
|
BUSINESS: '业务提醒',
|
|
BUSINESS_REMINDER: '业务提醒',
|
|
ALERT: '异常告警',
|
|
EXCEPTION_ALERT: '异常告警',
|
|
WARNING: '异常告警',
|
|
TASK: '任务待办',
|
|
TASK_TODO: '任务待办',
|
|
ORDER: '订单消息',
|
|
INBOUND: '入库消息',
|
|
FINANCE: '财务消息',
|
|
CUSTOMS: '报关消息',
|
|
ACCEPTANCE: '验收消息',
|
|
CLIENT_ACCEPTANCE: '验收消息',
|
|
}
|
|
|
|
const appLabels: Record<string, string> = {
|
|
PLATFORM: '管理后台',
|
|
ADMIN: '管理后台',
|
|
MERCHANT: '企业客户端',
|
|
}
|
|
|
|
const recipientStatusLabels: Record<string, string> = {
|
|
RESOLVED: '待投递',
|
|
DELIVERED: '已送达',
|
|
FAILED: '投递失败',
|
|
}
|
|
|
|
function mappedLabel(value: string | null | undefined, labels: Record<string, string>) {
|
|
const code = value?.trim()
|
|
if (!code) return '—'
|
|
return labels[code.toUpperCase()] ?? code
|
|
}
|
|
|
|
export const notificationCategoryLabel = (value?: string | null) => mappedLabel(value, categoryLabels)
|
|
export const notificationAppLabel = (value?: string | null) => mappedLabel(value, appLabels)
|
|
export const notificationRecipientStatusLabel = (value?: string | null) => mappedLabel(value, recipientStatusLabels)
|