diff --git a/src/pages/Challanges/Challenges.js b/src/pages/Challanges/Challenges.js
index 38f8b35..fc97b3b 100644
--- a/src/pages/Challanges/Challenges.js
+++ b/src/pages/Challanges/Challenges.js
@@ -31,7 +31,7 @@ const Challenges = () => {
}, []);
React.useEffect(() => {
- statusFilter(status, challengesFromAPI, setChallenges);
+ statusFilter(status, challengesFromAPI, challenges, setChallenges);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [status]);
@@ -82,21 +82,9 @@ const Challenges = () => {
<>
{filtersMenuRender(
filtersMenu ? '0' : '100vw',
- filtersMenu ? '1' : '0'
+ filtersMenu ? '1' : '0',
+ 'flex'
)}
-
Challenges
diff --git a/src/pages/Challanges/statusFilter.js b/src/pages/Challanges/statusFilter.js
index e7058da..7d0a7b0 100644
--- a/src/pages/Challanges/statusFilter.js
+++ b/src/pages/Challanges/statusFilter.js
@@ -19,8 +19,13 @@ const getDeadlineTime = (deadline) => {
}
};
-const statusFilter = (status, challenges, setChallenges) => {
- let result = challenges;
+const statusFilter = (
+ status,
+ challengesAll,
+ challengesToRender,
+ setChallenges
+) => {
+ let result = challengesAll;
const date = new Date();
const currentDate = {
year: date.getFullYear(),
@@ -29,28 +34,30 @@ const statusFilter = (status, challenges, setChallenges) => {
};
switch (status) {
case CHALLENGES_STATUS_FILTER.CLOSED:
- result = challenges.filter((challenge) =>
+ result = challengesAll.filter((challenge) =>
dateIsOlder(
currentDate,
challenge.deadline ? getDeadlineTime(challenge.deadline) : false
)
);
- setChallenges(result);
break;
case CHALLENGES_STATUS_FILTER.ACTIVE:
- result = challenges.filter(
+ result = challengesAll.filter(
(challenge) =>
!dateIsOlder(
currentDate,
- challenge.deadline ? getDeadlineTime(challenge.deadline) : true
+ challenge.deadline ? getDeadlineTime(challenge.deadline) : false
)
);
- setChallenges(result);
break;
default:
- setChallenges(challenges);
+ result = challengesAll;
break;
}
+ // result = result.filter((elem) => {
+ // return !challengesToRender.includes(elem);
+ // });
+ setChallenges(result);
};
export default statusFilter;