resolve merge conflict
This commit is contained in:
parent
8677080fb8
commit
94292c75e3
@ -6,9 +6,8 @@ import { H2 } from '../../../utils/fonts';
|
||||
import {
|
||||
CALC_PAGES,
|
||||
EVALUATIONS_FORMAT,
|
||||
RENDER_WHEN
|
||||
IS_MOBILE,
|
||||
RENDER_WHEN,
|
||||
IS_MOBILE,
|
||||
} from '../../../utils/globals';
|
||||
import Loading from '../../generic/Loading';
|
||||
import Pager from '../../generic/Pager';
|
||||
@ -69,8 +68,6 @@ const AllEntries = (props) => {
|
||||
allEntriesSearchQueryHandler(event, entriesAll, setPageNr, setEntries);
|
||||
};
|
||||
|
||||
|
||||
|
||||
const sortByUpdate = (elem, i) => {
|
||||
let newEntries = entries;
|
||||
switch (elem) {
|
||||
@ -171,11 +168,11 @@ const AllEntries = (props) => {
|
||||
/>
|
||||
<Pager
|
||||
pageNr={pageNr}
|
||||
elements={entries}
|
||||
setPageNr={setPageNr}
|
||||
width="48px"
|
||||
borderRadius="64px"
|
||||
pages={CALC_PAGES(entries)}
|
||||
nextPage={nextPage}
|
||||
previousPage={previousPage}
|
||||
number={`${pageNr} / ${CALC_PAGES(entries)}`}
|
||||
/>
|
||||
</>
|
||||
|
@ -31,8 +31,9 @@ const Challenges = () => {
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
statusFilter(status, challenges, setChallenges);
|
||||
}, [challenges, status]);
|
||||
statusFilter(status, challengesFromAPI, setChallenges);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [status]);
|
||||
|
||||
const challengesRequest = () => {
|
||||
getChallenges(setChallengesFromAPI);
|
||||
|
@ -1,5 +1,56 @@
|
||||
import { CHALLENGES_STATUS_FILTER } from '../../utils/globals';
|
||||
|
||||
const dateIsOlder = (newerDate, olderDate) => {
|
||||
console.log(newerDate);
|
||||
console.log(olderDate);
|
||||
if (newerDate.year > olderDate.year) return true;
|
||||
else if (newerDate.month > olderDate.month) return true;
|
||||
else if (newerDate.day > olderDate.day) return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
const getDeadlineTime = (deadline) => {
|
||||
if (deadline) {
|
||||
return {
|
||||
year: deadline.slice(0, 10).split('-')[0],
|
||||
month: deadline.slice(0, 10).split('-')[1],
|
||||
day: deadline.slice(0, 10).split('-')[2],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const statusFilter = (status, challenges, setChallenges) => {
|
||||
let result = challenges;
|
||||
const date = new Date();
|
||||
const currentDate = {
|
||||
year: date.getFullYear(),
|
||||
month: date.getMonth(),
|
||||
day: date.getDay(),
|
||||
};
|
||||
switch (status) {
|
||||
case CHALLENGES_STATUS_FILTER.CLOSED:
|
||||
result = challenges.filter((challenge) =>
|
||||
dateIsOlder(
|
||||
currentDate,
|
||||
challenge.deadline ? getDeadlineTime(challenge.deadline) : false
|
||||
)
|
||||
);
|
||||
setChallenges(result);
|
||||
break;
|
||||
case CHALLENGES_STATUS_FILTER.ACTIVE:
|
||||
result = challenges.filter(
|
||||
(challenge) =>
|
||||
!dateIsOlder(
|
||||
currentDate,
|
||||
challenge.deadline ? getDeadlineTime(challenge.deadline) : true
|
||||
)
|
||||
);
|
||||
setChallenges(result);
|
||||
break;
|
||||
default:
|
||||
setChallenges(challenges);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export default statusFilter;
|
||||
|
Loading…
Reference in New Issue
Block a user