Skip to content

Commit

Permalink
feat: final
Browse files Browse the repository at this point in the history
  • Loading branch information
ArpaAP committed Aug 6, 2024
1 parent 605a329 commit 012e5cb
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 130 deletions.
Binary file added apps/web/public/0.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/public/1.webp
Binary file not shown.
Binary file added apps/web/public/2.webp
Binary file not shown.
Binary file added apps/web/public/3.webp
Binary file not shown.
Binary file added apps/web/public/4.webp
Binary file not shown.
Binary file added apps/web/public/5.webp
Binary file not shown.
66 changes: 47 additions & 19 deletions apps/web/src/app/board/[boardId]/page.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Comment from '@/components/Comment'
import MainLayout from '@/components/MainLayout'
import Nutrient from '@/components/Nutrient'
import { Meal, User } from '@repo/database'
import { Meal, MealItem, MealItemAnalysis, User } from '@repo/database'
import {
IconBookmark,
IconChevronLeft,
Expand All @@ -23,7 +23,9 @@ dayjs.extend(relativeTime)

interface BoardDetailPageProps {
user: User
meal: Meal
meal: Meal & {
mealItems: (MealItem & { mealItemAnalysis: MealItemAnalysis | null })[]
}
imageUrls: string[]
}

Expand All @@ -41,6 +43,23 @@ export default function BoardDetailPageLayout({
else setIndex(imageLength - 1)
}

const totalCarboHydrates = meal.mealItems.reduce(
(acc, mealItem) => acc + (mealItem.mealItemAnalysis?.carbohydrate ?? 0),
0
)
const totalProtein = meal.mealItems.reduce(
(acc, mealItem) => acc + (mealItem.mealItemAnalysis?.protein ?? 0),
0
)
const totalFat = meal.mealItems.reduce(
(acc, mealItem) => acc + (mealItem.mealItemAnalysis?.fat ?? 0),
0
)
const totalSugar = meal.mealItems.reduce(
(acc, mealItem) => acc + (mealItem.mealItemAnalysis?.sugar ?? 0),
0
)

return (
<MainLayout>
<div className="container mx-auto flex items-start gap-5 px-32 py-16">
Expand Down Expand Up @@ -68,7 +87,7 @@ export default function BoardDetailPageLayout({
alt=""
width={512}
height={512}
className="w-[512px] h-[512px] aspect-square object-cover rounded-2xl"
className="w-[512px] h-[512px] aspect-square object-cover rounded-2xl border"
/>
))}
</div>
Expand All @@ -82,12 +101,12 @@ export default function BoardDetailPageLayout({
<IconChevronRight />
</button>
</div>
<div className="flex flex-col flex-grow gap-6 p-6 shadow-2xl shadow-black/10">
<div className="flex flex-col flex-grow gap-6 p-6 rounded-xl border shadow-black/10">
<div className="flex items-center gap-3">
<Image
className="rounded-full"
alt="profile Image"
src="https://picsum.photos/200/200"
src={user.profile ?? ''}
width={32}
height={32}
/>
Expand All @@ -98,7 +117,12 @@ export default function BoardDetailPageLayout({
</div>

<div>
<Nutrient carbs={100} protein={100} fat={100} />
<Nutrient
carbs={totalCarboHydrates}
protein={totalProtein}
fat={totalFat}
sugars={totalSugar}
/>
</div>
<div className="flex flex-row py-5 border rounded-lg justify-evenly ">
<button type="button">
Expand All @@ -111,23 +135,27 @@ export default function BoardDetailPageLayout({
<IconShare />
</button>
</div>
<div className="text-xl">댓글 3개</div>
<div className="text-lg">댓글 1개</div>
<div className="flex flex-col gap-5">
<Comment
profileImage="https://picsum.photos/200/200"
username="username"
content="댓글입니다."
profileImage="https://picsum.photos/200/200?random=2"
username="황부연"
content="멋사 해커톤 화이팅!"
/>
<Comment
profileImage="https://picsum.photos/200/200"
username="username"
content="댓글입니다."
/>
<Comment
profileImage="https://picsum.photos/200/200"
username="username"
content="댓글입니다."
</div>

<div className="flex gap-2">
<input
type="text"
className="grow px-3 py-2 border rounded-xl bg-white"
placeholder="댓글 입력..."
/>
<button
type="button"
className="bg-primary-600 text-sm text-white rounded-xl px-4 py-2"
>
등록
</button>
</div>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/app/board/[boardId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ export default async function BoardDetailPage({
isPublic: true,
},
include: {
mealItems: true,
user: true,
mealItems: {
include: {
mealItemAnalysis: true,
},
},
},
})

Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/app/dashboard.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ export default function DashboardPage({
모두의 건강한 식사를 위한
</div>
<div className="flex items-center gap-4">
<div className="font-bold text-4xl">
AI 기반 영양 분석 및 식단 추천 서비스
</div>
<div className="font-bold text-4xl">AI 기반 영양 분석 서비스</div>
<Image src={logoWhite} alt="logo" width={120} />
</div>
</div>
Expand Down
83 changes: 57 additions & 26 deletions apps/web/src/app/market/page.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,59 @@
import MainLayout from "@/components/MainLayout";
import ProductCard from "@/components/ProductCard";
import MainLayout from '@/components/MainLayout'
import ProductCard from '@/components/ProductCard'

export default function MarketPage() {
return (
<MainLayout>

<div className="flex flex-col items-stretch gap-6 px-32 py-8">
<div className="text-4xl font-bold">
밀로그 마켓
</div>
<div className="text-gray-400 text-gl">
사용자를 위해 건강한 식단을 판매합니다.
</div>
<div className="grid grid-cols-4 gap-6">
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
<ProductCard productImage={""} productId={1} productDetail="영양 만점 도시락!" productName="저당고단백 닭가슴살 도시락" productPrice={10000} />
</div>
</div>


</MainLayout>
)
}
return (
<MainLayout>
<div className="container mx-auto flex flex-col items-stretch gap-6 px-32 py-8">
<div className="text-4xl font-bold">밀로그 마켓</div>
<div className="text-gray-400 text-gl">
사용자를 위해 건강한 식단을 판매합니다.
</div>
<div className="grid grid-cols-4 gap-6">
<ProductCard
productImage={'/0.jpeg'}
productId={1}
productDetail="It's time to wake up!"
productName="체크오 아르타민"
productPrice={12000}
/>
<ProductCard
productImage={'/1.webp'}
productId={1}
productDetail="뉴질랜드산, 2000mg"
productName="비타민C 보충제"
productPrice={12000}
/>
<ProductCard
productImage={'/2.webp'}
productId={1}
productDetail="미국산"
productName="초코맛 단백질 쉐이크"
productPrice={35000}
/>
<ProductCard
productImage={'/3.webp'}
productId={1}
productDetail="캐나다산"
productName="저칼로리 에너지바"
productPrice={3000}
/>
<ProductCard
productImage={'/4.webp'}
productId={1}
productDetail="독일산"
productName="멀티비타민 젤리"
productPrice={15000}
/>
<ProductCard
productImage={'/5.webp'}
productId={1}
productDetail="국산"
productName="저당고단백 닭가슴살 도시락"
productPrice={8500}
/>
</div>
</div>
</MainLayout>
)
}
25 changes: 9 additions & 16 deletions apps/web/src/components/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Image from "next/image";
import Image from 'next/image'

interface CommentProps extends React.HTMLAttributes<HTMLDivElement> {
username: string;
profileImage: string;
content: string;
username: string
profileImage: string
content: string
}

export default function Comment({
Expand All @@ -16,25 +16,18 @@ export default function Comment({
<div {...props} className="flex flex-row items-start gap-2">
<Image
className="rounded-full"
src="https://picsum.photos/200/200"
src={profileImage}
alt="user Profile"
width={48}
height={48}
/>
<div className="flex flex-col">
<div className="flex items-center gap-2">
<div className="text-xl font-bold">
{username}
</div>
<div className="text-base text-gray-500">
1일전
</div>
</div>
<div className="text-base">
{content}
<div className="text-lg font-semibold">{username}</div>
<div className="text-sm text-gray-500">3분 전</div>
</div>
<div className="text-base">{content}</div>
</div>

</div>
)
}
}
3 changes: 3 additions & 0 deletions apps/web/src/components/MainNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default function MainNavbar() {
redirect: false,
}).then(() => {
router.push('/')
if (window.location.pathname === '/') {
window.location.reload()
}
toast.success('로그아웃 되었습니다.', {
duration: 3000,
})
Expand Down
58 changes: 32 additions & 26 deletions apps/web/src/components/Nutrient.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,77 @@
import { IconBaguette, IconDroplet, IconMeat } from "@tabler/icons-react"

import {
IconBaguette,
IconDroplet,
IconLollipop,
IconMeat,
} from '@tabler/icons-react'

interface NutrientProps extends React.HTMLAttributes<HTMLDivElement> {
carbs: number
protein: number
fat: number
sugars: number
}

export default function Nutrient({
carbs,
protein,
fat,
sugars,
...props
}: NutrientProps) {
const totalNutrient = carbs + protein + fat
return (
<div {...props} className="w-full">
<div className="flex flex-row gap-2">
<div className="flex flex-col justify-between gap-3 px-3 py-3 bg-orange-300 rounded-lg" style={{ width: (carbs / totalNutrient * 100) + "%" }}>
<div className="w-full flex flex-col justify-between gap-3 px-3 py-3 bg-primary-500 rounded-lg">
<div className="flex items-center justify-between gap-1">
<IconBaguette size={32} color="white" />
<div className="text-xl font-bold leading-7 text-white">
{(carbs / totalNutrient * 100).toFixed(0)}%
{((carbs / totalNutrient) * 100).toFixed(0)}%
</div>
</div>
<div className="flex flex-wrap items-end justify-between gap-1">
<div className="text-2xl font-bold text-white">
탄수화물
</div>
<div className="text-xl text-white">
{carbs}g
</div>
<div className="text-lg font-bold text-white">탄수화물</div>
<div className="text-white">{carbs.toFixed(1)}g</div>
</div>
</div>
<div className="flex flex-col justify-between gap-3 px-3 py-3 bg-red-600 rounded-lg" style={{ width: (protein / totalNutrient * 100) + "%" }}>
<div className="w-full flex flex-col justify-between gap-3 px-3 py-3 bg-red-600 rounded-lg">
<div className="flex items-center justify-between gap-1">
<IconMeat size={32} color="white" />
<div className="text-xl font-bold leading-7 text-white">
{(protein / totalNutrient * 100).toFixed(0)}%
{((protein / totalNutrient) * 100).toFixed(0)}%
</div>
</div>
<div className="flex flex-wrap items-end justify-between gap-1">
<div className="text-2xl font-bold text-white">
단백질
</div>
<div className="text-xl text-white">
{protein}g
<div className="text-lg font-bold text-white">단백질</div>
<div className="text-white">{protein.toFixed(1)}g</div>
</div>
</div>
<div className="w-full flex flex-col justify-between gap-3 px-3 py-3 bg-pink-500 rounded-lg">
<div className="flex items-center justify-between gap-1">
<IconLollipop size={32} color="white" />
<div className="text-xl font-bold leading-7 text-white">
{((sugars / totalNutrient) * 100).toFixed(0)}%
</div>
</div>
<div className="flex flex-wrap items-end justify-between gap-1">
<div className="text-lg font-bold text-white">당류</div>
<div className="text-white">{sugars.toFixed(1)}g</div>
</div>
</div>
<div className="flex flex-col justify-between gap-3 px-3 py-3 bg-yellow-500 rounded-lg" style={{ width: (fat / totalNutrient * 100) + "%" }}>
<div className="w-full flex flex-col justify-between gap-3 px-3 py-3 bg-yellow-500 rounded-lg">
<div className="flex items-center justify-between gap-1">
<IconDroplet size={32} color="white" />
<div className="text-xl font-bold leading-7 text-white">
{(fat / totalNutrient * 100).toFixed(0)}%
{((fat / totalNutrient) * 100).toFixed(0)}%
</div>
</div>
<div className="flex flex-wrap items-end justify-between gap-1">
<div className="text-2xl font-bold text-white">
지방
</div>
<div className="text-xl text-white">
{fat}g
</div>
<div className="text-lg font-bold text-white">지방</div>
<div className="text-white">{fat.toFixed(1)}g</div>
</div>
</div>
</div>
</div>
)
}
}
Loading

0 comments on commit 012e5cb

Please sign in to comment.