Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit a65a4d1

Browse files
committed
fixed issue that daterangepicker not editable
fixed issue that prize amount missing 'USD' suffix fixed issue that dropdownTerms missing small size updated lint-fix
1 parent 8177028 commit a65a4d1

File tree

29 files changed

+743
-283
lines changed

29 files changed

+743
-283
lines changed

src/actions/challenges.js

Lines changed: 104 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,69 @@ async function doGetChallenges(filter) {
88
}
99

1010
async function getAllActiveChallenges(filter) {
11-
const activeFilter = {
11+
const BUCKET_ALL_ACTIVE_CHALLENGES = constants.FILTER_BUCKETS[0];
12+
let page;
13+
14+
if (util.isDisplayingBucket(filter, BUCKET_ALL_ACTIVE_CHALLENGES)) {
15+
page = filter.page;
16+
} else {
17+
page = 1;
18+
}
19+
20+
const allActiveFilter = {
1221
...util.createChallengeCriteria(filter),
1322
...util.createAllActiveChallengeCriteria(),
23+
page,
1424
};
15-
return doGetChallenges(activeFilter);
25+
return doGetChallenges(allActiveFilter);
1626
}
1727

1828
async function getOpenForRegistrationChallenges(filter) {
29+
const BUCKET_OPEN_FOR_REGISTRATION = constants.FILTER_BUCKETS[1];
30+
let page;
31+
32+
if (util.isDisplayingBucket(filter, BUCKET_OPEN_FOR_REGISTRATION)) {
33+
page = filter.page;
34+
} else {
35+
page = 1;
36+
}
37+
1938
const openForRegistrationFilter = {
2039
...util.createChallengeCriteria(filter),
2140
...util.createOpenForRegistrationChallengeCriteria(),
41+
page,
2242
};
2343
return doGetChallenges(openForRegistrationFilter);
2444
}
2545

2646
async function getClosedChallenges(filter) {
27-
const pastFilter = {
47+
const BUCKET_CLOSED_CHALLENGES = constants.FILTER_BUCKETS[1];
48+
let page;
49+
50+
if (util.isDisplayingBucket(filter, BUCKET_CLOSED_CHALLENGES)) {
51+
page = filter.page;
52+
} else {
53+
page = 1;
54+
}
55+
56+
const closedFilter = {
2857
...util.createChallengeCriteria(filter),
2958
...util.createClosedChallengeCriteria(),
59+
page,
3060
};
31-
return doGetChallenges(pastFilter);
61+
return doGetChallenges(closedFilter);
3262
}
3363

3464
async function getRecommendedChallenges(filter) {
35-
const result = []
36-
result.meta = { total: 0 }
65+
let result = [];
66+
result.meta = { total: 0 };
67+
68+
if (result.length === 0) {
69+
const failbackFilter = { ...filter };
70+
result = await getOpenForRegistrationChallenges(failbackFilter);
71+
result.loadingRecommendedChallengesError = true;
72+
}
73+
3774
return result;
3875
}
3976

@@ -51,35 +88,58 @@ async function getChallenges(filter, change) {
5188
const FILTER_BUCKETS = constants.FILTER_BUCKETS;
5289
const BUCKET_ALL_ACTIVE_CHALLENGES = FILTER_BUCKETS[0];
5390
const BUCKET_OPEN_FOR_REGISTRATION = FILTER_BUCKETS[1];
54-
const BUCKET_PAST_CHALLENGES = FILTER_BUCKETS[2];
91+
const BUCKET_CLOSED_CHALLENGES = FILTER_BUCKETS[2];
5592
const filterChange = change;
5693
const bucket = filter.bucket;
5794

5895
const getChallengesByBuckets = async (f) => {
5996
return FILTER_BUCKETS.includes(f.bucket)
6097
? Promise.all([
61-
getAllActiveChallenges(f),
62-
f.recommended ? getRecommendedChallenges() : getOpenForRegistrationChallenges(f),
63-
getClosedChallenges(f)
64-
])
65-
: [[], [], []]
98+
getAllActiveChallenges(f),
99+
f.recommended
100+
? getRecommendedChallenges(f)
101+
: getOpenForRegistrationChallenges(f),
102+
getClosedChallenges(f),
103+
])
104+
: [[], [], []];
66105
};
67106

68107
if (!filterChange) {
69-
let [allActiveChallenges, openForRegistrationChallenges, closedChallenges] = await getChallengesByBuckets(filter)
108+
let [
109+
allActiveChallenges,
110+
openForRegistrationChallenges,
111+
closedChallenges,
112+
] = await getChallengesByBuckets(filter);
70113
let challenges;
71114
let openForRegistrationCount;
72115
let total;
116+
let loadingRecommendedChallengesError;
73117

74118
switch (bucket) {
75-
case BUCKET_ALL_ACTIVE_CHALLENGES: challenges = allActiveChallenges; break;
76-
case BUCKET_OPEN_FOR_REGISTRATION: challenges = openForRegistrationChallenges; break;
77-
case BUCKET_PAST_CHALLENGES: challenges = closedChallenges; break;
119+
case BUCKET_ALL_ACTIVE_CHALLENGES:
120+
challenges = allActiveChallenges;
121+
break;
122+
case BUCKET_OPEN_FOR_REGISTRATION:
123+
challenges = openForRegistrationChallenges;
124+
break;
125+
case BUCKET_CLOSED_CHALLENGES:
126+
challenges = closedChallenges;
127+
break;
78128
}
79129
openForRegistrationCount = openForRegistrationChallenges.meta.total;
80130
total = challenges.meta.total;
81-
82-
return { challenges, total, openForRegistrationCount, allActiveChallenges, openForRegistrationChallenges, closedChallenges };
131+
loadingRecommendedChallengesError =
132+
challenges.loadingRecommendedChallengesError;
133+
134+
return {
135+
challenges,
136+
total,
137+
openForRegistrationCount,
138+
loadingRecommendedChallengesError,
139+
allActiveChallenges,
140+
openForRegistrationChallenges,
141+
closedChallenges,
142+
};
83143
}
84144

85145
if (!util.checkRequiredFilterAttributes(filter)) {
@@ -92,26 +152,47 @@ async function getChallenges(filter, change) {
92152
let challenges;
93153
let openForRegistrationCount;
94154
let total;
155+
let loadingRecommendedChallengesError;
95156

96157
if (util.shouldFetchChallenges(filterChange)) {
97-
[allActiveChallenges, openForRegistrationChallenges, closedChallenges] = await getChallengesByBuckets(filter)
158+
[
159+
allActiveChallenges,
160+
openForRegistrationChallenges,
161+
closedChallenges,
162+
] = await getChallengesByBuckets(filter);
98163
switch (bucket) {
99-
case BUCKET_ALL_ACTIVE_CHALLENGES: challenges = allActiveChallenges; break;
100-
case BUCKET_OPEN_FOR_REGISTRATION: challenges = openForRegistrationChallenges; break;
101-
case BUCKET_PAST_CHALLENGES: challenges = closedChallenges; break;
164+
case BUCKET_ALL_ACTIVE_CHALLENGES:
165+
challenges = allActiveChallenges;
166+
break;
167+
case BUCKET_OPEN_FOR_REGISTRATION:
168+
challenges = openForRegistrationChallenges;
169+
break;
170+
case BUCKET_CLOSED_CHALLENGES:
171+
challenges = closedChallenges;
172+
break;
102173
}
103174
}
104175

105176
openForRegistrationCount = openForRegistrationChallenges.meta.total;
106177
total = challenges.meta.total;
178+
loadingRecommendedChallengesError =
179+
challenges.loadingRecommendedChallengesError;
107180

108181
if (util.shouldFilterChallenges(filterChange)) {
109182
challenges = doFilterBySubSommunities(challenges);
110183
challenges = doFilterByPrizeFrom(challenges);
111184
challenges = doFilterByPrizeTo(challenges);
112185
}
113186

114-
return { challenges, total, openForRegistrationCount, allActiveChallenges, openForRegistrationChallenges, closedChallenges };
187+
return {
188+
challenges,
189+
total,
190+
openForRegistrationCount,
191+
loadingRecommendedChallengesError,
192+
allActiveChallenges,
193+
openForRegistrationChallenges,
194+
closedChallenges,
195+
};
115196
}
116197

117198
export default createActions({

src/actions/filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createActions } from "redux-actions";
22

3-
function restoreFilter (filter) {
3+
function restoreFilter(filter) {
44
return filter;
55
}
66

src/components/Button/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ const ButtonIcon = ({ children, onClick }) => (
1818
<button styleName="button-icon" onClick={onClick} type="button">
1919
{children}
2020
</button>
21-
)
21+
);
2222

2323
ButtonIcon.propTypes = {
2424
children: PT.node,
2525
onClick: PT.func,
2626
};
2727

28-
export {
29-
Button,
30-
ButtonIcon,
31-
}
28+
export { Button, ButtonIcon };
3229

3330
export default Button;

src/components/Checkbox/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function Checkbox({ checked, onChange, size, errorMsg }) {
2323
).current;
2424

2525
useEffect(() => {
26-
setCheckedInternal(checked)
27-
}, [checked])
26+
setCheckedInternal(checked);
27+
}, [checked]);
2828

2929
return (
3030
<label styleName={`container ${sizeStyle}`}>

0 commit comments

Comments
 (0)