Skip to content

Commit

Permalink
Merge pull request #215 from Strong-Potato/208-feat-location-utils
Browse files Browse the repository at this point in the history
Feat: add location utils
  • Loading branch information
Yamyam-code authored Jan 26, 2024
2 parents 26b2e1a + 26e83cf commit eee5342
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/components/GlobalNavigationBar/GlobalNavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ function GlobalNavigationBar() {
<AiOutlineHome fontSize='24px' color={!pathname ? '#0086ff' : 'rgba(35, 39, 47, 1)'} />
</Link>

<Link to='/trip/1'>
<Link to='/trip'>
<AiOutlineCarryOut fontSize='24px' color={pathname === 'trip' ? '#0086ff' : 'rgba(35, 39, 47, 1)'} />
</Link>
<Link to='/wishes'>
<FaRegHeart fontSize='24px' color={pathname === 'wishes' ? '#0086ff' : 'rgba(35, 39, 47, 1)'} />

</Link>
<Link to='/user'>
<LuUser2 fontSize='24px' color={pathname === 'user' ? '#0086ff' : 'rgba(35, 39, 47, 1)'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
border: 1px solid $neutral200;
border-radius: 1.6rem;

cursor: pointer;

.img_box {
position: relative;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
border: 1px solid $neutral200;
border-radius: 1.6rem;

cursor: pointer;

.img_box {
position: relative;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/VoteAtHome/VoteAtHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function VoteAtHome() {
<div className={styles.container}>
{userData && data && data.voteResponse.length > 0 ? (
<p className={styles.title}>
<span className={styles.titleNull}>{userData} </span>
<span className={styles.titleNull}>{userData}</span>
<br />
진행 중인 투표가 있어요!
</p>
Expand Down
34 changes: 32 additions & 2 deletions src/pages/Wishes/Wishes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import WishesHeader from '@/components/WishItem/WishesHeader/WishesHeader';

import {getUserWishes} from '@/api/wishes';
import SearchNull from '@/assets/homeIcons/search/searchNull.svg?react';
import {translateLocation} from '@/utils/translateSearchData';

import WishItem from '../../components/WishItem/WishItem';

Expand Down Expand Up @@ -74,6 +75,31 @@ function Wishes() {
getUserWishes(setData);
}, []);

function filterLocation(location: string, data: SearchItemType[]) {
if (location.split(' ')[0] === '전국') {
return data;
}
const currentLocation = translateLocation(location);
const filterData: SearchItemType[] = [];
data.map((data) => {
console.log(
data.location.areaCode,
data.location.sigunguCode,
currentLocation.areaCode,
currentLocation.sigunguCode,
);

if (data.location.areaCode === currentLocation.areaCode) {
if (currentLocation.sigunguCode === 0) {
filterData.push(data);
} else if (data.location.sigunguCode === currentLocation.sigunguCode) {
filterData.push(data);
}
}
});
return filterData;
}

useEffect(() => {
if (data) {
if (filter.category !== 0) {
Expand All @@ -83,12 +109,16 @@ function Wishes() {
} else {
filterData = data.places.filter((data) => data.contentTypeId === filter.category);
}
if (filter.location !== '전국') {
filterData = filterLocation(filter.location, filterData);
}
setFilterData(filterData);
} else {
setFilterData(data.places);
const filterData = filterLocation(filter.location, data.places);
setFilterData(filterData);
}
}
}, [data, filter.category]);
}, [data, filter.category, filter.location]);

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

0 comments on commit eee5342

Please sign in to comment.