change recommendations to update through doctor
This commit is contained in:
@@ -3,7 +3,11 @@ import { cache } from 'react';
|
||||
import { AccountWithParams } from '@/packages/features/accounts/src/types/accounts';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
|
||||
import { ILifeStyleResponse, PROMPT_NAME } from '../../_components/ai/types';
|
||||
import {
|
||||
AnalysisResponses,
|
||||
ILifeStyleResponse,
|
||||
PROMPT_NAME,
|
||||
} from '../../_components/ai/types';
|
||||
import { updateLifeStyle } from './ai-actions';
|
||||
|
||||
const failedResponse = {
|
||||
@@ -13,17 +17,12 @@ const failedResponse = {
|
||||
|
||||
async function lifeStyleLoader(
|
||||
account: AccountWithParams,
|
||||
analysisResponses?: AnalysisResponses,
|
||||
): Promise<ILifeStyleResponse> {
|
||||
if (!account?.personal_code) {
|
||||
return failedResponse;
|
||||
}
|
||||
|
||||
const lifeStylePromptId = process.env.PROMPT_ID_LIFE_STYLE;
|
||||
|
||||
if (!lifeStylePromptId) {
|
||||
return failedResponse;
|
||||
}
|
||||
|
||||
const supabaseClient = getSupabaseServerClient();
|
||||
const { data, error } = await supabaseClient
|
||||
.schema('medreport')
|
||||
@@ -43,7 +42,7 @@ async function lifeStyleLoader(
|
||||
if (data?.response) {
|
||||
return JSON.parse(data.response as string);
|
||||
} else {
|
||||
return await updateLifeStyle({ account });
|
||||
return await updateLifeStyle({ account, analysisResponses });
|
||||
}
|
||||
}
|
||||
export const loadLifeStyle = cache(lifeStyleLoader);
|
||||
|
||||
Reference in New Issue
Block a user