feat(MED-105): create audit entry on analysis results view
This commit is contained in:
@@ -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[]),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user