tasko/lib/generate-log-message.ts
2024-02-15 20:49:19 -05:00

16 lines
554 B
TypeScript

import { ACTION, AuditLog } from '@prisma/client';
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}"`;
}
};