fix: refactor notification display logic and add format function
This commit is contained in:
25
apps/admin/src/utils/notification-display.ts
Normal file
25
apps/admin/src/utils/notification-display.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export const notificationTypeLabels: Record<string, string> = {
|
||||
bill_generated: '账单',
|
||||
bill_paid: '账单',
|
||||
check_in: '入住',
|
||||
check_out: '退宿',
|
||||
deposit_due: '押金',
|
||||
deposit_refunded: '押金',
|
||||
class_change: '班级',
|
||||
schedule_conflict: '排课',
|
||||
announcement: '公告',
|
||||
};
|
||||
|
||||
const teacherRoleLabels: Record<string, string> = {
|
||||
subject_teacher: '任课老师',
|
||||
head_teacher: '班主任',
|
||||
life_teacher: '生活老师',
|
||||
academic_teacher: '学服老师',
|
||||
};
|
||||
|
||||
export function formatNotificationText(text: string): string {
|
||||
return Object.entries(teacherRoleLabels).reduce(
|
||||
(result, [roleType, label]) => result.replaceAll(roleType, label),
|
||||
text,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user