Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 2252d9d

Browse files
authored
✨ Feat: 성분명 검색 백엔드 연동 (#23)
1 parent 933afb8 commit 2252d9d

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

src/app/drugs/[id]/page.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use client';
22

33
import { useEffect, useState } from 'react';
4-
import { useParams } from 'next/navigation';
4+
import { useParams, useRouter } from 'next/navigation';
55
import Header from '@/components/Header';
66
import Footer from '@/components/Footer';
77
import NoImage from '@/components/NoImage';
8+
import Link from 'next/link';
89

910
export default function DrugDetailPage() {
1011
const params = useParams();
@@ -111,7 +112,7 @@ export default function DrugDetailPage() {
111112
</div>
112113
<div className="flex items-center">
113114
<span className="w-24 text-sm font-medium text-gray-500">의약품 구분</span>
114-
<span className="text-gray-700">{getEtcOtcName(drug.isGeneral)} / {drug.isHerbal ? '한약' : '양약'}</span>
115+
<span className="text-gray-700">{getEtcOtcName(drug.isGeneral)}</span>
115116
</div>
116117
</div>
117118
<div className="space-y-2">
@@ -157,17 +158,22 @@ export default function DrugDetailPage() {
157158
<th className="px-4 py-2 bg-gray-50 text-left text-sm font-medium text-gray-500">분량</th>
158159
<th className="px-4 py-2 bg-gray-50 text-left text-sm font-medium text-gray-500">단위</th>
159160
<th className="px-4 py-2 bg-gray-50 text-left text-sm font-medium text-gray-500">총량</th>
160-
<th className="px-4 py-2 bg-gray-50 text-left text-sm font-medium text-gray-500">규격</th>
161161
</tr>
162162
</thead>
163163
<tbody className="bg-white divide-y divide-gray-200">
164164
{drug.materialInfo.map((material, index) => (
165165
<tr key={index}>
166-
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">{material.성분명}</td>
166+
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">
167+
<Link
168+
href={`/search/material?q=${encodeURIComponent(material.성분명)}&mode=keyword&type=material`}
169+
className="text-blue-600 hover:text-blue-800 hover:underline"
170+
>
171+
{material.성분명}
172+
</Link>
173+
</td>
167174
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">{material.분량}</td>
168175
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">{material.단위}</td>
169176
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">{material.총량}</td>
170-
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-700">{material.규격}</td>
171177
</tr>
172178
))}
173179
</tbody>

src/app/search/material/page.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client';
2+
3+
import { Suspense } from 'react';
4+
import SearchPage from '../../../components/SearchPage';
5+
6+
export default function Page() {
7+
return (
8+
<Suspense fallback={<div>Loading...</div>}>
9+
<SearchPage searchType="material" />
10+
</Suspense>
11+
);
12+
}

src/components/SearchBar.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const updateCache = (prevCache, key, value) => {
6767

6868
const searchTypes = {
6969
symptom: '증상',
70-
company: '제조사',
70+
material: '성분명',
7171
name: '약품명'
7272
};
7373

@@ -79,8 +79,8 @@ const updateCache = (prevCache, key, value) => {
7979
switch (searchType) {
8080
case 'symptom':
8181
return '증상을 입력하세요';
82-
case 'company':
83-
return '제조사를 입력하세요';
82+
case 'material':
83+
return '성분명을 입력하세요';
8484
case 'name':
8585
return '약품명을 입력하세요';
8686
default:
@@ -206,8 +206,9 @@ const updateCache = (prevCache, key, value) => {
206206
saveRecentSearch(searchQuery, searchMode, searchType);
207207
router.push(`/search/symptom?q=${encodeURIComponent(searchQuery)}&mode=${searchMode}&type=${searchType}`);
208208
break;
209-
case 'company':
210-
// 추후 구현
209+
case 'material':
210+
saveRecentSearch(searchQuery, searchMode, searchType);
211+
router.push(`/search/material?q=${encodeURIComponent(searchQuery)}&mode=${searchMode}&type=${searchType}`);
211212
break;
212213
case 'name':
213214
saveRecentSearch(searchQuery, searchMode, searchType);

0 commit comments

Comments
 (0)