diff --git a/src/domains/recipe/components/details/BackBtn.tsx b/src/domains/recipe/components/details/BackBtn.tsx index c50c116..1a8fa46 100644 --- a/src/domains/recipe/components/details/BackBtn.tsx +++ b/src/domains/recipe/components/details/BackBtn.tsx @@ -1,13 +1,13 @@ 'use client'; import Back from '@/shared/assets/icons/back_36.svg'; -import { useRouter } from 'next/navigation'; +import Link from 'next/link'; function BackBtn() { - const router = useRouter(); - return ( - ); } diff --git a/src/domains/recipe/details/DetailItem.tsx b/src/domains/recipe/details/DetailItem.tsx index 0eb6023..087ef3f 100644 --- a/src/domains/recipe/details/DetailItem.tsx +++ b/src/domains/recipe/details/DetailItem.tsx @@ -1,8 +1,8 @@ import Image from 'next/image'; -import Short from '@/shared/assets/icons/short_36.svg'; import Label from '@/domains/shared/components/label/Label'; import AbvGraph from '@/domains/shared/components/abv-graph/AbvGraph'; import { labelTitle } from '../utills/labelTitle'; +import useGlass from './hook/useGlass'; interface Props { name: string; @@ -15,6 +15,19 @@ interface Props { function DetailItem({ name, nameKo, story, src, abv, glassType }: Props) { const alcoholTitle = labelTitle(abv); + const abvNum = abv + .replace(/\(([^)]*)\)/g, '$1') + .split(' ') + .reverse() + .slice(0, 1) + .toString(); + const maxAbv = abvNum + .replace(/[~%]/g, ' ') + .split(' ') + .filter((str) => str.trim() !== '') + .map(Number); + + const glassIcon = useGlass(glassType); return (
@@ -37,8 +50,15 @@ function DetailItem({ name, nameKo, story, src, abv, glassType }: Props) {
-
- {`${nameKo}사진`} +
+ {`${nameKo}사진`}
@@ -48,8 +68,8 @@ function DetailItem({ name, nameKo, story, src, abv, glassType }: Props) { |
-

{abv}

- +

{abvNum}

+
@@ -57,9 +77,13 @@ function DetailItem({ name, nameKo, story, src, abv, glassType }: Props) {

글래스 타입

| -
- -

{glassType} 드링크

+
+ {glassIcon} +

+ {glassType == '숏' || glassType == '롱' + ? `${glassType} 드링크` + : `${glassType} 칵테일`} +

diff --git a/src/domains/recipe/details/DetailList.tsx b/src/domains/recipe/details/DetailList.tsx index 355961d..8baabfc 100644 --- a/src/domains/recipe/details/DetailList.tsx +++ b/src/domains/recipe/details/DetailList.tsx @@ -1,17 +1,38 @@ +'use client'; +import { useEffect, useState } from 'react'; import DetailRecommendList from './DetailRecommendList'; +import { getApi } from '@/app/api/config/appConfig'; +import { useParams } from 'next/navigation'; +import { RecommendCocktail } from '../types/types'; +import Link from 'next/link'; function DetailList() { + const { id } = useParams(); + const url = new URL(`${getApi}/cocktails/recommend/related`); + url.searchParams.set('cocktailId', String(id)); + + const [recommendItem, setRecommendItem] = useState([]); + + const recommentFetch = async () => { + const res = await fetch(url.toString()); + const json = await res.json(); + if (!res.ok) throw new Error('데이터 요청 실패'); + + setRecommendItem(json.data); + }; + useEffect(() => { + recommentFetch(); + }, []); + return ( -