Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: search hot items detail link #278

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/SearchFromHome/MapHeader/MapHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function MapHeader({forSearch, setForSearch}: PropsType) {

function offMap() {
if (forSearch.placeID !== 'undefined') {
history.back();
navigate(`/trip/${forSearch.placeID}`);
} else {
const before = forSearch;
before.map = 'false';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from 'react-router-dom';
import {Link, useSearchParams} from 'react-router-dom';

import styles from './HotItem.module.scss';

Expand All @@ -18,9 +18,17 @@ function HotItem({data}: PropsData) {
const category = translateCategoryToStr(data.contentTypeId);
const title = titleCaseChange(data.title);
const imgSrc = data.thumbnail ? data.thumbnail : nullImg;
const [searchPrams] = useSearchParams();
const tripId = searchPrams.get('placeID');
const journyId = searchPrams.get('tripDate')?.split(' ')[1];
const path = searchPrams.get('tripDate')?.split(' ')[0];
const detailLink =
path === 'trip'
? `/detail/${data.id} ${data.contentTypeId}?title=${data.title}&tripId=${tripId}&journyId=${journyId}`
: `/detail/${data.id} ${data.contentTypeId}?title=${data.title}`;

return (
<Link to={`/detail/${data.id} ${data.contentTypeId}?title=${data.title}`} className={styles.container}>
<Link to={detailLink} className={styles.container}>
<img src={imgSrc} alt={`${data.title}의 사진`} style={{padding: data.thumbnail ? 0 : '30px'}} />
<p className={styles.text_box}>
<span className={styles.title}>{title}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function SearchItem({forSearch, data, categoryChange}: PropsType) {
path === 'trip'
? `/detail/${data.id} ${data.contentTypeId}?title=${data.title}&tripId=${tripId}&journyId=${journyId}`
: `/detail/${data.id} ${data.contentTypeId}?title=${data.title}`;
console.log(path);

return (
<Link to={detailLink} className={styles.container}>
Expand Down
4 changes: 0 additions & 4 deletions src/pages/SearchFromHome/SearchFromHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ function SearchFromHome() {
}
}, [searchParams]);

useEffect(() => {
console.log(forSearch);
}, [forSearch]);

return (
<div
className={styles.container}
Expand Down
Loading