Merge branch 'main' into MED-85
This commit is contained in:
35
lib/services/audit/notificationEntries.service.ts
Normal file
35
lib/services/audit/notificationEntries.service.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Database } from '@kit/supabase/database';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
export enum NotificationAction {
|
||||
DOCTOR_FEEDBACK_RECEIVED = 'DOCTOR_FEEDBACK_RECEIVED',
|
||||
}
|
||||
|
||||
export const createNotificationLog = async ({
|
||||
action,
|
||||
status,
|
||||
comment,
|
||||
relatedRecordId,
|
||||
}: {
|
||||
action: NotificationAction;
|
||||
status: Database['audit']['Enums']['action_status'];
|
||||
comment?: string;
|
||||
relatedRecordId?: string | number;
|
||||
}) => {
|
||||
try {
|
||||
const supabase = getSupabaseServerClient();
|
||||
|
||||
await supabase
|
||||
.schema('audit')
|
||||
.from('notification_entries')
|
||||
.insert({
|
||||
action,
|
||||
status,
|
||||
comment,
|
||||
related_record_key: relatedRecordId?.toString(),
|
||||
})
|
||||
.throwOnError();
|
||||
} catch (error) {
|
||||
console.error('Failed to insert doctor page view log', error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user