add analysis recommendation
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { toTitleCase } from '@/lib/utils';
|
||||
import { createUserAnalysesApi } from '@kit/user-analyses/api';
|
||||
import { createUserAnalysesApi } from '@/packages/features/user-analyses/src/server/api';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
|
||||
import { PageBody, PageHeader } from '@kit/ui/page';
|
||||
@@ -13,7 +13,10 @@ import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
import Dashboard from '../_components/dashboard';
|
||||
import DashboardCards from '../_components/dashboard-cards';
|
||||
import Recommendations from '../_components/recommendations';
|
||||
import { loadAnalyses } from '../_lib/server/load-analyses';
|
||||
import { loadRecommendations } from '../_lib/server/load-recommendations';
|
||||
import { loadCurrentUserAccount } from '../_lib/server/load-user-account';
|
||||
import { analysisResponses } from './analysis-results/test/test-responses';
|
||||
|
||||
export const generateMetadata = async () => {
|
||||
const i18n = await createI18nServerInstance();
|
||||
@@ -31,6 +34,15 @@ async function UserHomePage() {
|
||||
const { account } = await loadCurrentUserAccount();
|
||||
const api = createUserAnalysesApi(client);
|
||||
const bmiThresholds = await api.fetchBmiThresholds();
|
||||
const { analyses, countryCode } = await loadAnalyses();
|
||||
|
||||
const analysisRecommendations = await loadRecommendations(
|
||||
analysisResponses,
|
||||
analyses,
|
||||
account,
|
||||
);
|
||||
|
||||
console.log('analysisRecommendations', analysisRecommendations);
|
||||
|
||||
if (!account) {
|
||||
redirect('/');
|
||||
@@ -51,7 +63,12 @@ async function UserHomePage() {
|
||||
<PageBody>
|
||||
<Dashboard account={account} bmiThresholds={bmiThresholds} />
|
||||
|
||||
<Recommendations />
|
||||
<Recommendations
|
||||
recommended={analyses.filter((analysis) =>
|
||||
analysisRecommendations.includes(analysis.title),
|
||||
)}
|
||||
countryCode={countryCode}
|
||||
/>
|
||||
</PageBody>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user