resolve merge conflict
This commit is contained in:
parent
8677080fb8
commit
94292c75e3
@ -6,9 +6,8 @@ import { H2 } from '../../../utils/fonts';
|
|||||||
import {
|
import {
|
||||||
CALC_PAGES,
|
CALC_PAGES,
|
||||||
EVALUATIONS_FORMAT,
|
EVALUATIONS_FORMAT,
|
||||||
RENDER_WHEN
|
|
||||||
IS_MOBILE,
|
|
||||||
RENDER_WHEN,
|
RENDER_WHEN,
|
||||||
|
IS_MOBILE,
|
||||||
} from '../../../utils/globals';
|
} from '../../../utils/globals';
|
||||||
import Loading from '../../generic/Loading';
|
import Loading from '../../generic/Loading';
|
||||||
import Pager from '../../generic/Pager';
|
import Pager from '../../generic/Pager';
|
||||||
@ -69,8 +68,6 @@ const AllEntries = (props) => {
|
|||||||
allEntriesSearchQueryHandler(event, entriesAll, setPageNr, setEntries);
|
allEntriesSearchQueryHandler(event, entriesAll, setPageNr, setEntries);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const sortByUpdate = (elem, i) => {
|
const sortByUpdate = (elem, i) => {
|
||||||
let newEntries = entries;
|
let newEntries = entries;
|
||||||
switch (elem) {
|
switch (elem) {
|
||||||
@ -171,11 +168,11 @@ const AllEntries = (props) => {
|
|||||||
/>
|
/>
|
||||||
<Pager
|
<Pager
|
||||||
pageNr={pageNr}
|
pageNr={pageNr}
|
||||||
|
elements={entries}
|
||||||
|
setPageNr={setPageNr}
|
||||||
width="48px"
|
width="48px"
|
||||||
borderRadius="64px"
|
borderRadius="64px"
|
||||||
pages={CALC_PAGES(entries)}
|
pages={CALC_PAGES(entries)}
|
||||||
nextPage={nextPage}
|
|
||||||
previousPage={previousPage}
|
|
||||||
number={`${pageNr} / ${CALC_PAGES(entries)}`}
|
number={`${pageNr} / ${CALC_PAGES(entries)}`}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -31,8 +31,9 @@ const Challenges = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
statusFilter(status, challenges, setChallenges);
|
statusFilter(status, challengesFromAPI, setChallenges);
|
||||||
}, [challenges, status]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [status]);
|
||||||
|
|
||||||
const challengesRequest = () => {
|
const challengesRequest = () => {
|
||||||
getChallenges(setChallengesFromAPI);
|
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) => {
|
const statusFilter = (status, challenges, setChallenges) => {
|
||||||
let result = challenges;
|
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;
|
export default statusFilter;
|
||||||
|
Loading…
Reference in New Issue
Block a user