lifestyle development
This commit is contained in:
@@ -18,14 +18,14 @@ const AIBlocks = async ({ account }: { account: AccountWithParams }) => {
|
||||
return <OrderAnalysesPackageCard />;
|
||||
}
|
||||
|
||||
const { analyses, countryCode } = await loadAnalyses();
|
||||
const { analyses } = await loadAnalyses();
|
||||
|
||||
if (analyses.length === 0) {
|
||||
return (
|
||||
<>
|
||||
<OrderAnalysesPackageCard />
|
||||
<Suspense fallback={<RecommendationsSkeleton />}>
|
||||
<LifeStyleCard />
|
||||
<Suspense fallback={<RecommendationsSkeleton amount={1} />}>
|
||||
<LifeStyleCard account={account} />
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
@@ -33,7 +33,7 @@ const AIBlocks = async ({ account }: { account: AccountWithParams }) => {
|
||||
|
||||
return (
|
||||
<Suspense fallback={<RecommendationsSkeleton />}>
|
||||
<LifeStyleCard />
|
||||
<LifeStyleCard account={account} />
|
||||
<Recommendations account={account} />
|
||||
</Suspense>
|
||||
);
|
||||
|
||||
@@ -2,16 +2,34 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { Card } from '@kit/ui/shadcn/card';
|
||||
import Link from 'next/link';
|
||||
|
||||
import { AccountWithParams } from '@/packages/features/accounts/src/types/accounts';
|
||||
import { pathsConfig } from '@/packages/shared/src/config';
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
|
||||
import { Trans } from '@kit/ui/makerkit/trans';
|
||||
import { Button } from '@kit/ui/shadcn/button';
|
||||
import { Card, CardHeader } from '@kit/ui/shadcn/card';
|
||||
|
||||
import { loadLifeStyle } from '../../_lib/server/load-life-style';
|
||||
|
||||
const LifeStyleCard = async () => {
|
||||
const data = await loadLifeStyle();
|
||||
const LifeStyleCard = async ({ account }: { account: AccountWithParams }) => {
|
||||
const data = await loadLifeStyle(account);
|
||||
|
||||
return (
|
||||
<Card variant="gradient-success" className="flex flex-col justify-between">
|
||||
Test
|
||||
<CardHeader className="flex-row justify-between">
|
||||
<h5>
|
||||
<Trans i18nKey="dashboard:heroCard.lifeStyle.title" />
|
||||
</h5>
|
||||
<Link href={pathsConfig.app.lifeStyle}>
|
||||
<Button size="icon" variant="outline" className="px-2 text-black">
|
||||
<ChevronRight className="size-4 stroke-2" />
|
||||
</Button>
|
||||
</Link>
|
||||
</CardHeader>
|
||||
<span className="text-primary p-4 text-sm">{data.summary}</span>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@kit/ui/shadcn/card';
|
||||
import { Skeleton } from '@kit/ui/skeleton';
|
||||
|
||||
const RecommendationsSkeleton = () => {
|
||||
const RecommendationsSkeleton = ({ amount = 2 }: { amount?: number }) => {
|
||||
const emptyData = [
|
||||
{
|
||||
title: '1',
|
||||
@@ -20,55 +20,48 @@ const RecommendationsSkeleton = () => {
|
||||
variant: { id: '' },
|
||||
price: 1,
|
||||
},
|
||||
{
|
||||
title: '2',
|
||||
description: '',
|
||||
subtitle: '',
|
||||
variant: { id: '' },
|
||||
price: 1,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<div className="xs:grid-cols-3 mt-4 grid gap-6">
|
||||
{emptyData.map(({ title, description, subtitle }) => (
|
||||
<Skeleton key={title}>
|
||||
<Card>
|
||||
<CardHeader className="flex-row">
|
||||
<div
|
||||
className={
|
||||
'mb-6 flex size-8 items-center-safe justify-center-safe'
|
||||
}
|
||||
/>
|
||||
<div className="ml-auto flex size-8 items-center-safe justify-center-safe">
|
||||
<Button size="icon" className="px-2" />
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardFooter className="flex">
|
||||
<div className="flex flex-1 flex-col items-start">
|
||||
<h5>
|
||||
{title}
|
||||
{description && (
|
||||
<>
|
||||
{' '}
|
||||
<InfoTooltip
|
||||
content={
|
||||
<div className="flex flex-col gap-2">
|
||||
<span>{description}</span>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</h5>
|
||||
{subtitle && <CardDescription>{subtitle}</CardDescription>}
|
||||
</div>
|
||||
<div className="flex flex-col items-end gap-2 self-end text-sm"></div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Skeleton>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
return Array.from({ length: amount }, (_, index) => {
|
||||
const { title, description, subtitle } = emptyData[0]!;
|
||||
|
||||
return (
|
||||
<Skeleton key={title + index}>
|
||||
<Card>
|
||||
<CardHeader className="flex-row">
|
||||
<div
|
||||
className={
|
||||
'mb-6 flex size-8 items-center-safe justify-center-safe'
|
||||
}
|
||||
/>
|
||||
<div className="ml-auto flex size-8 items-center-safe justify-center-safe">
|
||||
<Button size="icon" className="px-2" />
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardFooter className="flex">
|
||||
<div className="flex flex-1 flex-col items-start">
|
||||
<h5>
|
||||
{title}
|
||||
{description && (
|
||||
<>
|
||||
{' '}
|
||||
<InfoTooltip
|
||||
content={
|
||||
<div className="flex flex-col gap-2">
|
||||
<span>{description}</span>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</h5>
|
||||
{subtitle && <CardDescription>{subtitle}</CardDescription>}
|
||||
</div>
|
||||
<div className="flex flex-col items-end gap-2 self-end text-sm"></div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Skeleton>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export default RecommendationsSkeleton;
|
||||
|
||||
18
app/home/(user)/_components/ai/types.ts
Normal file
18
app/home/(user)/_components/ai/types.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Database } from '@/packages/supabase/src/database.types';
|
||||
|
||||
export interface ILifeStyleResponse {
|
||||
lifestyle: {
|
||||
title: string;
|
||||
description: string;
|
||||
score: 0 | 1 | 2;
|
||||
}[];
|
||||
summary: string | null;
|
||||
}
|
||||
|
||||
export enum PROMPT_NAME {
|
||||
LIFE_STYLE = 'Life Style',
|
||||
ANALYSIS_RECOMMENDATIONS = 'Analysis Recommendations',
|
||||
}
|
||||
|
||||
export type AnalysisResponses =
|
||||
Database['medreport']['Functions']['get_latest_analysis_response_elements_for_current_user']['Returns'];
|
||||
Reference in New Issue
Block a user