Skip to content

Commit

Permalink
Fix: search home
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamyam-code committed Jan 28, 2024
1 parent c0a7798 commit 6245291
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use '@/sass' as *;

.container {
width: 100%;
height: 100%;

display: flex;
flex-direction: column;
gap: 32px;

overflow: scroll;

padding: 0 20px 24px 20px;
}
34 changes: 34 additions & 0 deletions src/components/SearchFromHome/SearchHome/HotForTrip/HotForTrip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {useEffect, useState} from 'react';

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

import {keywordSearch} from '@/api/search';

import SearchItem from '../../SearchList/SearchItem/SearchItem';

import {ForSearchType, SearchItemType} from '@/types/home';

interface PropsType {
forSearch: ForSearchType;
}

function HotForTrip({forSearch}: PropsType) {
const [data, setData] = useState<SearchItemType[]>();

async function getData() {
const fetchData = await keywordSearch('문화관광축제', '전국', '인기순', 1, 10);
setData(fetchData);
}

useEffect(() => {
getData();
}, []);

return (
<div className={styles.container}>
{data && data.map((data) => <SearchItem data={data} forSearch={forSearch} key={data.id} />)}
</div>
);
}

export default HotForTrip;
29 changes: 21 additions & 8 deletions src/components/SearchFromHome/SearchHome/SearchHome.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import styles from './SearchHome.module.scss';

import AddToCandidateButton from '@/components/ButtonsInAddingCandidate/AddToCandidateButton/AddToCandidateButton';

import HotForTrip from './HotForTrip/HotForTrip';
import HotItems from './HotItems/HotItems';
import SearchKeyword from './SearchKeyword/SearchKeyword';

Expand All @@ -16,14 +19,24 @@ function SearchHome({forSearch}: PropsType) {
<p className={styles.title}>인기 검색 키워드</p>
<SearchKeyword forSearch={forSearch} />
</div>
<div className={styles.column_8px}>
<p className={styles.title}>최근 30일간 인기 장소</p>
<HotItems type={12} />
</div>
<div className={styles.column_8px}>
<p className={styles.title}>최근 30일간 인기 숙소</p>
<HotItems type={32} />
</div>
{forSearch.placeID !== 'undefined' ? (
<div className={styles.column_8px}>
<p className={styles.title}>최근 30일간 인기 장소</p>
<HotForTrip forSearch={forSearch} />
</div>
) : (
<>
<div className={styles.column_8px}>
<p className={styles.title}>최근 30일간 인기 장소</p>
<HotItems type={12} />
</div>
<div className={styles.column_8px}>
<p className={styles.title}>최근 30일간 인기 숙소</p>
<HotItems type={32} />
</div>
</>
)}
{forSearch.placeID !== 'undefined' && <AddToCandidateButton />}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {ForSearchType, SearchItemType} from '@/types/home';
interface PropsType {
forSearch: ForSearchType;
data: SearchItemType;
categoryChange: boolean;
categoryChange?: boolean;
}

function SearchItem({forSearch, data, categoryChange}: PropsType) {
function SearchItem({forSearch, data, categoryChange = undefined}: PropsType) {
const title = titleCaseChange(data.title);
const location = areas.filter((area) => area.areaCode === data.location.areaCode)[0].name;
const category = translateCategoryToStr(data.contentTypeId);
Expand Down

0 comments on commit 6245291

Please sign in to comment.