@@ -8,7 +8,7 @@ import { useQuery } from '@tanstack/react-query';
88import Category from './components/Category' ;
99import DetailMediumCard from './components/DetailMediumCard' ;
1010import DetailSmallCard from './components/DetailSmallCard' ;
11- import SkeletonLayout from './components/skeletonLayout ' ;
11+ import SkeletonLayout from './components/SkeletonLayout ' ;
1212
1313const SearchPage = ( ) => {
1414 const [ searchData , setSearchData ] = useState ( [ ] ) ;
@@ -158,82 +158,64 @@ const SearchPage = () => {
158158 setLayout ( layouticon ) ;
159159 } ;
160160
161+ const handleCardClick = contentId => {
162+ navigate ( `/detail/${ contentId } ` ) ; // 상세 페이지로 이동
163+ window . scrollTo ( 0 , 0 ) ;
164+ } ;
165+
161166 const renderCard = item => {
162167 switch ( layout ) {
163168 case 'large-layout' :
164169 return (
165- < button
166- className = "w-full"
167- onClick = { ( ) => {
168- const contentId = item . contentsid ;
169- window . location . href = `/detail/${ contentId } ` ;
170- } }
171- key = { item . contentsid }
172- >
173- < DetailCard
174- key = { item . id }
175- title = { item . title || '제목이 없습니다' }
176- city = { item . region1cd ?. label || '도시' }
177- street = {
178- item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
179- ? '제주시내'
180- : item . region2cd ?. label
181- }
182- description = { item . introduction || '설명이 없습니다.' }
183- img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
184- contentid = { item ?. contentsid }
185- />
186- </ button >
170+ < DetailCard
171+ key = { item . id }
172+ onClick = { ( ) => handleCardClick ( item . contentsid ) }
173+ title = { item . title || '제목이 없습니다' }
174+ city = { item . region1cd ?. label || '도시' }
175+ street = {
176+ item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
177+ ? '제주시내'
178+ : item . region2cd ?. label
179+ }
180+ description = { item . introduction || '설명이 없습니다.' }
181+ img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
182+ contentid = { item }
183+ />
187184 ) ;
188185 case 'medium-layout' :
189186 return (
190- < button
191- className = " mr-10 [&:nth-child(3n)]:mr-0"
192- onClick = { ( ) => {
193- const contentId = item . contentsid ;
194- window . location . href = `/detail/${ contentId } ` ;
195- } }
196- key = { item . contentsid }
197- >
198- < DetailMediumCard
199- key = { item . id }
200- title = { item . title || '제목이 없습니다' }
201- city = { item . region1cd ?. label || '도시' }
202- street = {
203- item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
204- ? '제주시내'
205- : item . region2cd ?. label
206- }
207- img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
208- category = { item . contentscd ?. value }
209- contentid = { item ?. contentsid }
210- />
211- </ button >
187+ < DetailMediumCard
188+ key = { item . id }
189+ onClick = { ( ) => handleCardClick ( item . contentsid ) }
190+ title = { item . title || '제목이 없습니다' }
191+ city = { item . region1cd ?. label || '도시' }
192+ street = {
193+ item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
194+ ? '제주시내'
195+ : item . region2cd ?. label
196+ }
197+ img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
198+ category = { item . contentscd ?. value }
199+ contentid = { item }
200+ />
212201 ) ;
213202 case 'small-layout' :
214203 return (
215- < button
216- onClick = { ( ) => {
217- const contentId = item . contentsid ;
218- window . location . href = `/detail/${ contentId } ` ;
219- } }
220- key = { item . contentsid || '' }
221- >
222- < DetailSmallCard
223- key = { item . id }
224- title = { item . title || '제목이 없습니다' }
225- city = { item . region1cd ?. label || '도시' }
226- street = {
227- item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
228- ? '제주시내'
229- : item . region2cd ?. label
230- }
231- description = { item . introduction || '설명이 없습니다.' }
232- img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
233- category = { item . contentscd ?. value }
234- contentid = { item ?. contentsid }
235- />
236- </ button >
204+ < DetailSmallCard
205+ key = { item . id }
206+ onClick = { ( ) => handleCardClick ( item . contentsid ) }
207+ title = { item . title || '제목이 없습니다' }
208+ city = { item . region1cd ?. label || '도시' }
209+ street = {
210+ item . region2cd ?. label == 'region>' || item . region2cd ?. label == undefined
211+ ? '제주시내'
212+ : item . region2cd ?. label
213+ }
214+ description = { item . introduction || '설명이 없습니다.' }
215+ img = { item . repPhoto ?. photoid ?. thumbnailpath || '/images/no_image.svg' }
216+ category = { item . contentscd ?. value }
217+ contentid = { item }
218+ />
237219 ) ;
238220 default :
239221 return null ;
0 commit comments