diff --git a/apps/web/src/app/analyze/page.layout.tsx b/apps/web/src/app/analyze/page.layout.tsx index dc97cde..8526db9 100644 --- a/apps/web/src/app/analyze/page.layout.tsx +++ b/apps/web/src/app/analyze/page.layout.tsx @@ -4,7 +4,9 @@ import MainLayout from '@/components/MainLayout' import { Meal, MealItem } from '@repo/database' import { IconFileAnalytics, IconUpload } from '@tabler/icons-react' import axios from 'axios' +import { useRouter } from 'next/navigation' import { useEffect, useState } from 'react' +import toast from 'react-hot-toast' interface AnalyzePageLayoutProps { mealId: string @@ -17,6 +19,7 @@ export default function AnalyzePageLayout({ meal, mealItems, }: AnalyzePageLayoutProps) { + const router = useRouter() const [successCount, setSuccessCount] = useState(0) const totalCount = mealItems.length @@ -31,6 +34,9 @@ export default function AnalyzePageLayout({ console.error(error) } } + + toast.success('분석이 완료되었습니다!') + setTimeout(() => router.push(`/meal/${mealId}`), 2000) })() }, [mealItems]) diff --git a/apps/web/src/app/dashboard.page.tsx b/apps/web/src/app/dashboard.page.tsx index 9a12abb..87186df 100644 --- a/apps/web/src/app/dashboard.page.tsx +++ b/apps/web/src/app/dashboard.page.tsx @@ -58,7 +58,7 @@ export default function DashboardPage({ user }: DashboardPageProps) {
- 영양 분석 및 식단 추천 서비스 + AI 기반 영양 분석 및 식단 추천 서비스
logo
@@ -110,7 +110,7 @@ export default function DashboardPage({ user }: DashboardPageProps) {
- 황부연님의 일평균 영양 현황 + {user.name}님의 일평균 영양 현황
@@ -171,7 +171,9 @@ export default function DashboardPage({ user }: DashboardPageProps) {
-
황부연님의 영양섭취량
+
+ {user.name}님의 영양섭취량 +
+
+
+ {meal.date.toLocaleDateString()} {typeStr} +
+
+
+ {mealItems.length}개의 음식 +
+
+ +
+ +
+ 식품별 분석 정보 +
+ +
+ {mealItems.map((mealItem, index) => { + let { mealItemAnalysis } = mealItem + + return ( +
+ + {mealItemAnalysis ? ( +
+
+
+ {mealItemAnalysis?.className} +
+
+ 정확도 {(mealItemAnalysis?.confidence * 100).toFixed(2)} + % +
+
+ +
+
+
칼로리
+
+ {mealItemAnalysis?.kcal.toFixed(2)} kcal +
+
+
+
탄수화물
+
+ {mealItemAnalysis?.carbohydrate.toFixed(2)} g +
+
+
+
당류
+
+ {mealItemAnalysis?.sugar.toFixed(2)} g +
+
+
+
지방
+
+ {mealItemAnalysis?.fat.toFixed(2)} g +
+
+
+
단백질
+
+ {mealItemAnalysis?.protein.toFixed(2)} g +
+
+
+
칼슘
+
+ {mealItemAnalysis?.calcium.toFixed(2)} mg +
+
+
+
+
+ {mealItemAnalysis?.phosphorus.toFixed(2)} mg +
+
+
+
나트륨
+
+ {mealItemAnalysis?.natrium.toFixed(2)} mg +
+
+
+
칼륨
+
+ {mealItemAnalysis?.kalium.toFixed(2)} mg +
+
+
+
마그네슘
+
+ {mealItemAnalysis?.magnesium.toFixed(2)} mg +
+
+
+
철분
+
+ {mealItemAnalysis?.iron.toFixed(2)} mg +
+
+
+
아연
+
+ {mealItemAnalysis?.zinc.toFixed(2)} mg +
+
+
+
콜레스테롤
+
+ {mealItemAnalysis?.cholesterol.toFixed(2)} mg +
+
+
+
트랜스지방
+
+ {mealItemAnalysis?.transfat.toFixed(2)} g +
+
+
+
+ ) : ( +
+
인식 실패
+
+ )} +
+ ) + })} +
+
+ + ) } diff --git a/apps/web/src/app/meal/[mealId]/page.tsx b/apps/web/src/app/meal/[mealId]/page.tsx index fb2fb0f..de49c3e 100644 --- a/apps/web/src/app/meal/[mealId]/page.tsx +++ b/apps/web/src/app/meal/[mealId]/page.tsx @@ -2,6 +2,8 @@ import { getServerSession } from 'next-auth' import { notFound, redirect } from 'next/navigation' import { PrismaClient } from '@repo/database' import MealPageLayout from './page.layout' +import { storage } from '@/lib/firebase/firebaseClient' +import { ref, getDownloadURL } from 'firebase/storage' const prisma = new PrismaClient() @@ -35,7 +37,19 @@ export default async function MealPage({ const mealItems = await prisma.mealItem.findMany({ where: { mealId }, + include: { + mealItemAnalysis: true, + }, }) - return + const imageUrls = await Promise.all( + mealItems.map(async (mealItem) => { + const refPath = ref(storage, `images/${mealItem.imageName}`) + return getDownloadURL(refPath) + }) + ) + + return ( + + ) } diff --git a/apps/web/src/app/my/page.layout.tsx b/apps/web/src/app/my/page.layout.tsx index 179ca8a..e9e512e 100644 --- a/apps/web/src/app/my/page.layout.tsx +++ b/apps/web/src/app/my/page.layout.tsx @@ -102,45 +102,47 @@ export default function MyPageLayout({
- {meals.map((meal) => { - let typeStr = '' + {meals + .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) + .map((meal) => { + let typeStr = '' - switch (meal.type) { - case 'breakfast': - typeStr = '아침' - break - case 'lunch': - typeStr = '점심' - break - case 'dinner': - typeStr = '저녁' - break - case 'snack': - typeStr = '간식' - break - case 'etc': - typeStr = '기타' - break - } + switch (meal.type) { + case 'breakfast': + typeStr = '아침' + break + case 'lunch': + typeStr = '점심' + break + case 'dinner': + typeStr = '저녁' + break + case 'snack': + typeStr = '간식' + break + case 'etc': + typeStr = '기타' + break + } - return ( - -
-
- {meal.date.toLocaleDateString()} {typeStr} + return ( + +
+
+ {meal.date.toLocaleDateString()} {typeStr} +
+
+ {meal.mealItems.length}개 음식 +
-
- {meal.mealItems.length}개 음식 -
-
- - - ) - })} + + + ) + })}
Content 2 diff --git a/apps/web/src/app/upload/page.tsx b/apps/web/src/app/upload/page.tsx index 4ccd573..66669a5 100644 --- a/apps/web/src/app/upload/page.tsx +++ b/apps/web/src/app/upload/page.tsx @@ -107,7 +107,7 @@ export default function UploadPage() { }) .then((res) => { if (res.status === 200) { - toast.success('사진 업르드를 완료했습니다.') + toast.success('사진 업르드를 완료했습니다. 분석을 시작합니다.') let meal = res.data.data as Meal router.push(`/analyze?mealId=${meal.mealId}`) diff --git a/apps/web/src/components/MainNavbar.tsx b/apps/web/src/components/MainNavbar.tsx index e2e1cfe..ddf959d 100644 --- a/apps/web/src/components/MainNavbar.tsx +++ b/apps/web/src/components/MainNavbar.tsx @@ -24,8 +24,8 @@ export default function MainNavbar() {
+ -