Skip to content

Commit acc53b3

Browse files
committed
Merge branch 'issue-212' into develop
2 parents 4809a95 + 5cef506 commit acc53b3

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/shared/reducers/challenge-listing/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import logger from 'utils/logger';
88
import { handleActions } from 'redux-actions';
99
import { combine, resolveReducers } from 'utils/redux';
1010
import { updateQuery } from 'utils/url';
11+
import moment from 'moment';
1112

1213
import filterPanel from '../challenge-listing/filter-panel';
1314
import sidebar, { factory as sidebarFactory } from '../challenge-listing/sidebar';
@@ -272,6 +273,21 @@ export function factory(req) {
272273

273274
if (req) {
274275
state.filter = req.query.filter;
276+
277+
/* TODO: OK, fine, this validation of dates does the server-side part of
278+
* the trick, while the frontend part (removing them from URL) is done
279+
* elsewhere (/src/shared/routes/Topcoder/ChallengeListing), but it should
280+
* be changed that everything is handled here in the reducer code (only
281+
* this way we can ensure that it works all around, including community
282+
* challenge listings). */
283+
if (!!state.filter && !!state.filter.startDate
284+
&& moment(state.filter.startDate).isValid() === false) {
285+
delete state.filter.startDate;
286+
}
287+
if (!!state.filter && !!state.filter.endDate
288+
&& moment(state.filter.endDate).isValid() === false) {
289+
delete state.filter.endDate;
290+
}
275291
state.selectedCommunityId = req.query.communityId;
276292
}
277293

src/shared/routes/Topcoder/ChallengeListing.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import _ from 'lodash';
77
import LoadingIndicator from 'components/LoadingIndicator';
88
import qs from 'qs';
99
import React from 'react';
10+
import moment from 'moment';
1011
import { SplitRoute } from 'utils/router';
12+
import { updateQuery } from 'utils/url';
1113

1214
export default function ChallengeListingRoute() {
1315
return (
@@ -21,6 +23,20 @@ export default function ChallengeListingRoute() {
2123
).then(({ default: ChallengeListing }) => {
2224
const query = renderProps.location.search ?
2325
qs.parse(renderProps.location.search.slice(1)) : null;
26+
27+
/* TODO: This validation of start and end dates from query params
28+
* does the trick of removing invalid dates from URL at the client
29+
* side, but it actually should be done in the reducer as well. */
30+
if (query.filter && query.filter.startDate
31+
&& !moment(query.filter.startDate).isValid()) {
32+
delete query.filter.startDate;
33+
}
34+
if (query.filter && query.filter.endDate
35+
&& !moment(query.filter.endDate).isValid()) {
36+
delete query.filter.endDate;
37+
}
38+
updateQuery({ filter: query.filter });
39+
2440
const currencyFromUrl = _.get(query, 'currency');
2541
const prizeMode = currencyFromUrl && `money-${currencyFromUrl}`;
2642
return (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1504026000,"base":"USD","rates":{"AED":3.672895,"AFN":68.45,"ALL":110.85,"AMD":478.425,"ANG":1.779836,"AOA":165.9205,"ARS":17.3527,"AUD":1.255331,"AWG":1.796245,"AZN":1.7,"BAM":1.6265,"BBD":2,"BDT":81.223201,"BGN":1.62681,"BHD":0.37709,"BIF":1741,"BMD":1,"BND":1.352182,"BOB":6.910011,"BRL":3.169787,"BSD":1,"BTC":0.000218050697,"BTN":63.905066,"BWP":10.105259,"BYN":1.925664,"BZD":2.015536,"CAD":1.252664,"CDF":1550.480769,"CHF":0.95053,"CLF":0.02322,"CLP":624.8,"CNH":6.602839,"CNY":6.59344,"COP":2936.12,"CRC":576.32,"CUC":1,"CUP":25.5,"CVE":92.1,"CZK":21.723593,"DJF":178.77,"DKK":6.191242,"DOP":47.27,"DZD":110.105,"EGP":17.6423,"ERN":15.336727,"ETB":23.55,"EUR":0.832198,"FJD":2.026996,"FKP":0.773554,"GBP":0.773554,"GEL":2.4171,"GGP":0.773554,"GHS":4.435,"GIP":0.773554,"GMD":46.1,"GNF":8975,"GTQ":7.282729,"GYD":206.253019,"HKD":7.824735,"HNL":23.384421,"HRK":6.1704,"HTG":66.28528,"HUF":254.5222,"IDR":13335.343435,"ILS":3.56927,"IMP":0.773554,"INR":63.95,"IQD":1183,"IRR":32919,"ISK":104.59177,"JEP":0.773554,"JMD":127.9521,"JOD":0.708997,"JPY":109.15853571,"KES":103.235,"KGS":68.606942,"KHR":4050,"KMF":409.725,"KPW":900,"KRW":1125.73,"KWD":0.301302,"KYD":0.833249,"KZT":335.345,"LAK":8305,"LBP":1507.5,"LKR":152.844139,"LRD":115.088085,"LSL":12.975,"LYD":1.36,"MAD":9.3093,"MDL":17.769968,"MGA":2955,"MKD":51.2405,"MMK":1350.35,"MNT":2429.735065,"MOP":8.058874,"MRO":364,"MUR":32.633,"MVR":15.460011,"MWK":725.5,"MXN":17.899417,"MYR":4.266577,"MZN":60.994761,"NAD":12.95125,"NGN":359.5,"NIO":29.915,"NOK":7.735323,"NPR":102.428065,"NZD":1.377157,"OMR":0.38496,"PAB":1,"PEN":3.240494,"PGK":3.2465,"PHP":51.095,"PKR":105.225,"PLN":3.551703,"PYG":5642.9,"QAR":3.683509,"RON":3.824395,"RSD":99.196723,"RUB":58.7728,"RWF":830,"SAR":3.75015,"SBD":7.79659,"SCR":13.630238,"SDG":6.685,"SEK":7.911019,"SGD":1.352602,"SHP":0.773554,"SLL":7553.652075,"SOS":590,"SRD":7.438,"SSP":125.5349,"STD":20495.223096,"SVC":8.74962,"SYP":515,"SZL":13.0125,"THB":33.183,"TJS":8.813642,"TMT":3.5,"TND":2.416402,"TOP":2.2143,"TRY":3.446721,"TTD":6.749017,"TWD":30.084123,"TZS":2241,"UAH":25.456,"UGX":3618.483069,"USD":1,"UYU":28.731928,"UZS":4180,"VEF":10.122439,"VND":22686.807359,"VUV":104.863461,"WST":2.493173,"XAF":545.88604,"XAG":0.05720824,"XAU":0.00076113,"XCD":2.70255,"XDR":0.702778,"XOF":545.88604,"XPD":0.00105601,"XPF":99.307626,"XPT":0.00099992,"YER":250.25,"ZAR":12.986425,"ZMW":9.05095,"ZWL":322.355011}}
1+
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1504094400,"base":"USD","rates":{"AED":3.672993,"AFN":68.434,"ALL":111.7,"AMD":478.037813,"ANG":1.78016,"AOA":165.9205,"ARS":17.3759,"AUD":1.258944,"AWG":1.794996,"AZN":1.7,"BAM":1.637155,"BBD":2,"BDT":81.301229,"BGN":1.638412,"BHD":0.377064,"BIF":1740.480974,"BMD":1,"BND":1.356099,"BOB":6.975584,"BRL":3.1658,"BSD":1,"BTC":0.000218893995,"BTN":63.98413,"BWP":10.117236,"BYN":1.93245,"BZD":2.015866,"CAD":1.254589,"CDF":1550.480769,"CHF":0.957745,"CLF":0.02327,"CLP":627.53,"CNH":6.596306,"CNY":6.591954,"COP":2935,"CRC":576.356761,"CUC":1,"CUP":25.5,"CVE":92.05,"CZK":21.833487,"DJF":178.97,"DKK":6.237503,"DOP":47.058472,"DZD":110.6425,"EGP":17.66,"ERN":15.335471,"ETB":23.213765,"EUR":0.83845,"FJD":2.012549,"FKP":0.773864,"GBP":0.773864,"GEL":2.421275,"GGP":0.773864,"GHS":4.435686,"GIP":0.773864,"GMD":46.075,"GNF":8889.35,"GTQ":7.287002,"GYD":207.92,"HKD":7.826275,"HNL":23.401272,"HRK":6.2166,"HTG":66.655042,"HUF":256.291667,"IDR":13343.842125,"ILS":3.579785,"IMP":0.773864,"INR":64.019,"IQD":1165.259957,"IRR":33062.267348,"ISK":105.3,"JEP":0.773864,"JMD":128.066489,"JOD":0.7085,"JPY":110.0806875,"KES":103.18375,"KGS":68.664403,"KHR":4049.4,"KMF":411.5,"KPW":900,"KRW":1123.12,"KWD":0.3014,"KYD":0.833499,"KZT":335.490293,"LAK":8290.15,"LBP":1509.108296,"LKR":152.844139,"LRD":115.088085,"LSL":13.025862,"LYD":1.362745,"MAD":9.35832,"MDL":17.812983,"MGA":2965.35,"MKD":51.63,"MMK":1366.36006,"MNT":2429.908099,"MOP":8.061282,"MRO":365.04565,"MUR":32.5505,"MVR":15.450233,"MWK":725.545,"MXN":17.84641,"MYR":4.268763,"MZN":61.41,"NAD":13.026223,"NGN":359.680566,"NIO":29.857062,"NOK":7.785542,"NPR":102.333153,"NZD":1.381965,"OMR":0.384981,"PAB":1,"PEN":3.239626,"PGK":3.184651,"PHP":51.228,"PKR":105.230492,"PLN":3.572052,"PYG":5648,"QAR":3.685006,"RON":3.8514,"RSD":99.862,"RUB":58.59465,"RWF":834.09,"SAR":3.750268,"SBD":7.795825,"SCR":13.7225,"SDG":6.677632,"SEK":7.976799,"SGD":1.356863,"SHP":0.773864,"SLL":7550.184032,"SOS":579.49834,"SRD":7.438,"SSP":124.9444,"STD":20471.6023,"SVC":8.75092,"SYP":515,"SZL":13.036105,"THB":33.2195,"TJS":8.816192,"TMT":3.504979,"TND":2.4306,"TOP":2.193576,"TRY":3.454709,"TTD":6.726398,"TWD":30.143104,"TZS":2242.2,"UAH":25.599924,"UGX":3600.55,"USD":1,"UYU":28.727472,"UZS":4182.7,"VEF":10.12298,"VND":22724.55232,"VUV":103.823289,"WST":2.483105,"XAF":549.987151,"XAG":0.05747127,"XAU":0.00076348,"XCD":2.70255,"XDR":0.702778,"XOF":549.987151,"XPD":0.00106217,"XPF":100.0537,"XPT":0.00100758,"YER":250.275,"ZAR":13.041288,"ZMW":9.036057,"ZWL":322.355011}}

src/shared/utils/url.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function updateQuery(update) {
2828
if (_.isUndefined(value)) delete query[key];
2929
else query[key] = value;
3030
});
31-
3231
query = `?${qs.stringify(query, { encode: false })}`;
3332
window.history.replaceState(window.history.state, '', query);
3433
}

0 commit comments

Comments
 (0)