tasko/lib/generate-log-message.ts

17 lines
554 B
TypeScript
Raw Permalink Normal View History

2024-02-16 01:49:19 +00:00
import { ACTION, AuditLog } from '@prisma/client';
2024-02-15 02:30:10 +00:00
export const generateLogMessage = (log: AuditLog) => {
const { action, entityTitle, entityType } = log;
switch (action) {
case ACTION.CREATE:
return `Created ${entityType.toLowerCase()} "${entityTitle}"`;
case ACTION.UPDATE:
return `Updated ${entityType.toLowerCase()} "${entityTitle}"`;
case ACTION.DELETE:
return `Deleted ${entityType.toLowerCase()} "${entityTitle}"`;
default:
return `Unknown action ${entityType.toLowerCase()} "${entityTitle}"`;
}
};