feat(MED-105): create audit entry on analysis results view

This commit is contained in:
2025-08-11 09:21:13 +03:00
parent 49fc75b17b
commit 83fff1ffe7
4 changed files with 95 additions and 0 deletions

View File

@@ -15,6 +15,8 @@ import { redirect } from 'next/navigation';
import { getOrders } from '~/lib/services/order.service';
import { AnalysisElement, getAnalysisElements } from '~/lib/services/analysis-element.service';
import type { UserAnalysisElement } from '@kit/accounts/types/accounts';
import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account';
import { createPageViewLog } from '~/lib/services/audit/pageView.service';
export const generateMetadata = async () => {
const i18n = await createI18nServerInstance();
@@ -26,6 +28,11 @@ export const generateMetadata = async () => {
};
async function AnalysisResultsPage() {
const account = await loadCurrentUserAccount()
if (!account) {
throw new Error('Account not found');
}
const analysisList = await loadUserAnalysis();
const orders = await getOrders().catch(() => null);
@@ -35,6 +42,11 @@ async function AnalysisResultsPage() {
redirect(pathsConfig.auth.signIn);
}
await createPageViewLog({
accountId: account.id,
action: 'VIEW_ANALYSIS_RESULTS',
});
const analysisElementIds = [
...new Set(orders?.flatMap((order) => order.analysis_element_ids).filter(Boolean) as number[]),
];