Skip to content

Commit 8c04497

Browse files
authored
Merge branch 'challenges-bug-bash' into issue_143
2 parents 9517217 + 96bdb49 commit 8c04497

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

src/components/DateRangePicker/index.jsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -574,18 +574,29 @@ function DateRangePicker(props) {
574574
preview={preview}
575575
onPreviewChange={onPreviewChange}
576576
/>
577-
<button
578-
type="button"
579-
styleName="reset-button"
580-
onClick={() => {
581-
onDateRangePickerChange({
582-
startDate: null,
583-
endDate: null,
584-
});
585-
}}
586-
>
587-
Reset
588-
</button>
577+
<div styleName="calendar-footer">
578+
<button
579+
type="button"
580+
styleName="calendar-button"
581+
onClick={() => {
582+
onDateRangePickerChange({
583+
startDate: null,
584+
endDate: null,
585+
});
586+
}}
587+
>
588+
Reset
589+
</button>
590+
<button
591+
type="button"
592+
styleName="calendar-button"
593+
onClick={() => {
594+
setIsComponentVisible(false);
595+
}}
596+
>
597+
Close
598+
</button>
599+
</div>
589600
</div>
590601
)}
591602
</div>

src/components/DateRangePicker/style.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ $darkGreen: #0AB88A;;
391391
z-index: 10;
392392

393393
@include phone {
394+
width: 100vw;
394395
position: fixed;
395396
top: 0;
396397
left: 0;
@@ -402,7 +403,15 @@ $darkGreen: #0AB88A;;
402403
border-radius: 0;
403404
}
404405

405-
.reset-button {
406+
.calendar-footer {
407+
width: 100%;
408+
409+
@include phone {
410+
padding: 0 20px;
411+
}
412+
}
413+
414+
.calendar-button {
406415
@include roboto-bold;
407416

408417
width: 71px;
@@ -421,7 +430,7 @@ $darkGreen: #0AB88A;;
421430
height: 26px;
422431
line-height: 27px;
423432
font-size: 12px;
424-
margin: 20px 12px 0;
433+
margin: 0 12px 0;
425434
}
426435
}
427436
}

src/routers/challenge-list/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const App = () => {
4545
return;
4646
}
4747

48-
const params = utils.url.parseUrlQuery(location.search);
48+
let search = location.href.split('?').length ? '?' + location.href.split('?')[1]: ''
49+
const params = utils.url.parseUrlQuery(search);
4950
const toUpdate = utils.challenge.createChallengeFilter(params);
5051

5152
if (!toUpdate.types) toUpdate.types = [];

src/services/challenges.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getService as getSubmissionsService } from "./submissions";
1717
* @return {Array<Object>} challenges
1818
*/
1919
async function getChallenges(filter, cancellationSignal) {
20-
const challengeQuery = util.buildQueryString(filter);
20+
const challengeQuery = util.buildQueryString(filter, true);
2121
return api.get(
2222
`/challenges/${challengeQuery}`,
2323
undefined,

src/utils/url.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import qs from "qs";
1515
* @params {Object<{[key: string]: any}>} params Query string parameters
1616
* @return {String}
1717
*/
18-
export function buildQueryString(params) {
18+
export function buildQueryString(params, disableEncode) {
1919
params = _.omitBy(params, (p) => p == null || p === "" || p.length === 0);
20-
20+
if (!disableEncode) {
21+
params.tags = _.map(params.tags, (t) => encodeURIComponent(t))
22+
}
2123
let queryString = qs.stringify(params, {
2224
encode: false,
2325
arrayFormat: "brackets",
@@ -28,7 +30,11 @@ export function buildQueryString(params) {
2830
}
2931

3032
export function parseUrlQuery(queryString) {
31-
return qs.parse(queryString, { ignoreQueryPrefix: true });
33+
let params = qs.parse(queryString, { ignoreQueryPrefix: true });
34+
if (params.tags) {
35+
params.tags = _.map(params.tags, (t) => decodeURIComponent(t))
36+
}
37+
return params
3238
}
3339

3440
export function updateQuery(params, replace = false) {

0 commit comments

Comments
 (0)