send analyses to ai
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { toTitleCase } from '@/lib/utils';
|
||||
@@ -13,10 +15,8 @@ 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';
|
||||
import Loading from '../loading';
|
||||
|
||||
export const generateMetadata = async () => {
|
||||
const i18n = await createI18nServerInstance();
|
||||
@@ -28,21 +28,11 @@ export const generateMetadata = async () => {
|
||||
};
|
||||
|
||||
async function UserHomePage() {
|
||||
console.log('process.env', process.env.OPENAI_API_KEY);
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
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('/');
|
||||
@@ -62,13 +52,9 @@ async function UserHomePage() {
|
||||
/>
|
||||
<PageBody>
|
||||
<Dashboard account={account} bmiThresholds={bmiThresholds} />
|
||||
|
||||
<Recommendations
|
||||
recommended={analyses.filter((analysis) =>
|
||||
analysisRecommendations.includes(analysis.title),
|
||||
)}
|
||||
countryCode={countryCode}
|
||||
/>
|
||||
<Suspense fallback={null}>
|
||||
<Recommendations account={account} />
|
||||
</Suspense>
|
||||
</PageBody>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user