Skip to content

Commit

Permalink
Merge pull request #104 from delicious-algorithme/dev
Browse files Browse the repository at this point in the history
bug: �fix filtering and sorting bug
  • Loading branch information
Songhyejeong authored Nov 25, 2024
2 parents e5ea554 + 658261e commit 8a11375
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/components/common/filtering/Filtering.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const Filtering = ({ category }) => {
return isEqual(filterParams, initialParams);
}, [filterParams, initialParams]);

//필터링 하나만 되게 하는 조건

useEffect(() => {
const isInit = isInitFilterParams();
if (isInit) {
Expand Down Expand Up @@ -208,9 +210,13 @@ const Filtering = ({ category }) => {
};

const CategoryClickHandler = (categoryId) => {
let newSelectState = [...selectState];
newSelectState[categoryId] = !selectState[categoryId];
setSelectState(newSelectState);
let allSelectState = [...selectState];

setSelectState(() => {
allSelectState = new Array(selectState.length).fill(false);
allSelectState[categoryId] = true;
return allSelectState;
});
};

useEffect(() => {
Expand Down
24 changes: 18 additions & 6 deletions src/components/common/store/StoreList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,27 @@ const StoreList = () => {
};

const sortReviewClickHandler = (sortBy) => {
setFilterParams({ ...filterParams, orderByRating: sortBy, orderByPositiveRatio: null });
setOrderByRating(sortBy);
setorderByPositiveRatio(null);
if (!orderByRating) {
setFilterParams({ ...filterParams, orderByRating: sortBy, orderByPositiveRatio: null });
setOrderByRating(sortBy);
setorderByPositiveRatio(null);
} else {
setFilterParams({ ...filterParams, orderByRating: null, orderByPositiveRatio: null });
setOrderByRating(null);
setorderByPositiveRatio(null);
}
};

const sortPositiveClickHandler = (sortBy) => {
setFilterParams({ ...filterParams, orderByRating: null, orderByPositiveRatio: sortBy });
setorderByPositiveRatio(sortBy);
setOrderByRating(null);
if (!orderByPositiveRatio) {
setFilterParams({ ...filterParams, orderByRating: null, orderByPositiveRatio: sortBy });
setorderByPositiveRatio(sortBy);
setOrderByRating(null);
} else {
setFilterParams({ ...filterParams, orderByRating: null, orderByPositiveRatio: null });
setorderByPositiveRatio(null);
setOrderByRating(null);
}
};

if (isLoading)
Expand Down

0 comments on commit 8a11375

Please sign in to comment.