Skip to content

Commit

Permalink
Merge pull request #19 from icssc/dang-bug-fixes
Browse files Browse the repository at this point in the history
fixed returned item in filter doesn't work
  • Loading branch information
NwinNwin authored May 21, 2024
2 parents 3b99c06 + b52e590 commit bb27d2c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
23 changes: 10 additions & 13 deletions packages/web/src/components/Filter/Filter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,31 @@ export default function Filter({ findFilter, setFindFilter, onClose, isOpen }) {
setFindFilter((prev) => ({
...prev,
isFound: !prev.isFound,
}))
}, [])
}));
}, []);

const handleIsShowReturned = useCallback(() => {
console.log("isShowReturned");
setFindFilter((prev) => ({
...prev,
isShowReturned: !prev.isShowReturned,
}));
}, [])
}, []);

const handleIsYourPosts = useCallback(() => {
setFindFilter((prev) => ({
...prev,
isYourPosts: !prev.isYourPosts,
}));
}, [])
}, []);

const handleUploadDate = useCallback((e) => {
setFindFilter((prev) => ({
...prev,
uploadDate: e.target.value,
}));
})
});

const handleCancel = useCallback(() => {
setFindFilter({
type: "everything",
Expand All @@ -74,8 +75,8 @@ export default function Filter({ findFilter, setFindFilter, onClose, isOpen }) {
isShowReturned: true,
});
onClose();
}, [])
}, []);

return (
<>
<Drawer isOpen={isOpen} placement="left" onClose={onClose}>
Expand Down Expand Up @@ -189,11 +190,7 @@ export default function Filter({ findFilter, setFindFilter, onClose, isOpen }) {
</DrawerBody>

<DrawerFooter>
<Button
variant="outline"
mr={3}
onClick={handleCancel}
>
<Button variant="outline" mr={3} onClick={handleCancel}>
Cancel
</Button>
<Button colorScheme="blue" onClick={onClose}>
Expand Down
26 changes: 14 additions & 12 deletions packages/web/src/utils/Utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Define callback function to return filtered items (filtered according to search bar and filter markers)
const filterItem = (item, findFilter, user) => {
return (((findFilter.islost && item.islost) ||
(findFilter.isFound && !item.islost)) &&
(findFilter.type === "everything" || findFilter.type === item.type) &&
(findFilter.uploadDate === "" ||
(item.itemDate && item.itemDate.includes(findFilter.uploadDate))) &&
(!findFilter.isYourPosts || item.email === user.email) &&
(findFilter.isShowReturned || !item.isResolved)
);
};
// Define callback function to return filtered items (filtered according to search bar and filter markers)
const filterItem = (item, findFilter, user) => {
console.log(item);
return (
((findFilter.islost && item.islost) ||
(findFilter.isFound && !item.islost)) &&
(findFilter.type === "everything" || findFilter.type === item.type) &&
(findFilter.uploadDate === "" ||
(item.itemDate && item.itemDate.includes(findFilter.uploadDate))) &&
(!findFilter.isYourPosts || item.email === user.email) &&
(findFilter.isShowReturned || !item.isresolved)
);
};

export { filterItem };
export { filterItem };

0 comments on commit bb27d2c

Please sign in to comment.