Skip to content

Commit 5a62e30

Browse files
committed
- updated /?tags[]=<tag> to /?search=<tag>
- fixed date-range-picker calendar missing the close button
1 parent 6248ead commit 5a62e30

File tree

9 files changed

+56
-5
lines changed

9 files changed

+56
-5
lines changed

src/shared/components/DateRangePicker/index.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ function DateRangePicker(props) {
466466
>
467467
Reset
468468
</button>
469+
<button
470+
type="button"
471+
styleName="close-button"
472+
onClick={() => {
473+
setIsComponentVisible(false);
474+
}}
475+
>
476+
&times;
477+
</button>
469478
</div>
470479
)
471480
}

src/shared/components/DateRangePicker/style.scss

+18
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@
392392
margin: 20px 12px 0;
393393
}
394394
}
395+
396+
.close-button {
397+
position: absolute;
398+
top: 0;
399+
right: 0;
400+
display: none;
401+
line-height: 16px;
402+
padding: 15px;
403+
font-size: 36px;
404+
color: $tc-black;
405+
appearance: none;
406+
background: none;
407+
border: 0;
408+
409+
@include phone {
410+
display: block;
411+
}
412+
}
395413
}
396414

397415
.endDate {

src/shared/components/challenge-detail/Header/ChallengeTags.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export default function ChallengeTags(props) {
8888
&& (
8989
<Tag
9090
key={tag}
91-
onClick={() => setImmediate(() => setChallengeListingFilter({ tags: [tag] }))
91+
onClick={() => setImmediate(() => setChallengeListingFilter({ search: tag }))
9292
}
93-
to={`${challengesUrl}?tags[]=${
93+
to={`${challengesUrl}?search=${
9494
encodeURIComponent(tag)}`}
9595
>
9696
{tag}

src/shared/components/challenge-listing/Listing/Bucket/index.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default function Bucket({
4949
activeBucket,
5050
// searchTimestamp,
5151
isLoggedIn,
52+
setSearchText,
5253
}) {
5354
const refs = useRef([]);
5455
refs.current = [];
@@ -128,9 +129,10 @@ export default function Bucket({
128129
onTechTagClicked={(tag) => {
129130
setFilterState({
130131
..._.clone(filterState),
131-
tags: [tag],
132+
search: tag,
132133
types: challengeTypes.map(type => type.abbreviation),
133134
});
135+
setSearchText(tag);
134136
}}
135137
openChallengesInNewTabs={openChallengesInNewTabs}
136138
prizeMode={prizeMode}
@@ -256,4 +258,5 @@ Bucket.propTypes = {
256258
activeBucket: PT.string,
257259
// searchTimestamp: PT.number,
258260
isLoggedIn: PT.bool.isRequired,
261+
setSearchText: PT.func.isRequired,
259262
};

src/shared/components/challenge-listing/Listing/ReviewOpportunityBucket/index.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function ReviewOpportunityBucket({
3333
setSort,
3434
challengeTypes,
3535
sort,
36+
setSearchText,
3637
}) {
3738
if (!opportunities.length && !loadMore) return null;
3839

@@ -59,7 +60,10 @@ export default function ReviewOpportunityBucket({
5960
challengeType={_.find(challengeTypes, { name: item.challenge.type }) || {}}
6061
expandedTags={expandedTags}
6162
expandTag={expandTag}
62-
onTechTagClicked={tag => setFilterState({ tags: [tag] })}
63+
onTechTagClicked={(tag) => {
64+
setFilterState({ search: tag });
65+
setSearchText(tag);
66+
}}
6367
opportunity={item}
6468
key={item.id}
6569
/>
@@ -132,4 +136,5 @@ ReviewOpportunityBucket.propTypes = {
132136
setSort: PT.func.isRequired,
133137
sort: PT.string,
134138
challengeTypes: PT.arrayOf(PT.shape()).isRequired,
139+
setSearchText: PT.func.isRequired,
135140
};

src/shared/components/challenge-listing/Listing/index.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function Listing({
7171
// pastSearchTimestamp,
7272
isLoggedIn,
7373
meta,
74+
setSearchText,
7475
}) {
7576
// const buckets = getBuckets(userChallenges);
7677
// const isChallengesAvailable = (bucket) => {
@@ -159,6 +160,7 @@ function Listing({
159160
sort={sorts[bucket]}
160161
challengeTypes={challengeTypes}
161162
isLoggedIn={isLoggedIn}
163+
setSearchText={setSearchText}
162164
/>
163165
)
164166
: (
@@ -194,6 +196,7 @@ function Listing({
194196
activeBucket={activeBucket}
195197
// searchTimestamp={searchTimestamp}
196198
isLoggedIn={isLoggedIn}
199+
setSearchText={setSearchText}
197200
/>
198201
)
199202
);
@@ -348,6 +351,7 @@ Listing.propTypes = {
348351
// userChallenges: PT.arrayOf(PT.string),
349352
isLoggedIn: PT.bool.isRequired,
350353
meta: PT.shape().isRequired,
354+
setSearchText: PT.func.isRequired,
351355
};
352356

353357
const mapStateToProps = (state) => {

src/shared/components/challenge-listing/index.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default function ChallengeListing(props) {
4949
// isBucketSwitching,
5050
isLoggedIn,
5151
meta,
52+
setSearchText,
5253
} = props;
5354

5455
// const { challenges } = props;
@@ -144,6 +145,7 @@ export default function ChallengeListing(props) {
144145
// userChallenges={props.userChallenges}
145146
isLoggedIn={isLoggedIn}
146147
meta={meta}
148+
setSearchText={setSearchText}
147149
/>
148150
);
149151
// }
@@ -258,4 +260,5 @@ ChallengeListing.propTypes = {
258260
// userChallenges: PT.arrayOf(PT.string),
259261
isLoggedIn: PT.bool.isRequired,
260262
meta: PT.shape().isRequired,
263+
setSearchText: PT.func.isRequired,
261264
};

src/shared/containers/challenge-detail/index.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import pageActions from 'actions/page';
1414
import ChallengeHeader from 'components/challenge-detail/Header';
1515
import challengeListingActions from 'actions/challenge-listing';
1616
import challengeListingSidebarActions from 'actions/challenge-listing/sidebar';
17+
import challengeListingFilterPanelActions from 'actions/challenge-listing/filter-panel';
1718
import Registrants from 'components/challenge-detail/Registrants';
1819
import shortId from 'shortid';
1920
import Submissions from 'components/challenge-detail/Submissions';
@@ -880,13 +881,15 @@ const mapDispatchToProps = (dispatch) => {
880881
setChallengeListingFilter: (filter, stateProps) => {
881882
const cl = challengeListingActions.challengeListing;
882883
const cls = challengeListingSidebarActions.challengeListing.sidebar;
884+
const fp = challengeListingFilterPanelActions.challengeListing.filterPanel;
883885
const newFilter = _.assign(
884886
{},
885-
{ types: stateProps.challengeTypesMap.map(type => type.abbreviation), tags: [] },
887+
{ types: stateProps.challengeTypes.map(type => type.abbreviation), search: '' },
886888
filter,
887889
);
888890
dispatch(cls.selectBucket(BUCKETS.OPEN_FOR_REGISTRATION));
889891
dispatch(cl.setFilter(newFilter));
892+
dispatch(fp.setSearchText(newFilter.search));
890893
},
891894
setSpecsTabState: state => dispatch(pageActions.page.challengeDetails.setSpecsTabState(state)),
892895
unregisterFromChallenge: (auth, challengeId) => {

src/shared/containers/challenge-listing/Listing/index.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { connect } from 'react-redux';
2121
import ChallengeListing from 'components/challenge-listing';
2222
import Banner from 'components/tc-communities/Banner';
2323
import sidebarActions from 'actions/challenge-listing/sidebar';
24+
import filterPanelActions from 'actions/challenge-listing/filter-panel';
2425
import communityActions from 'actions/tc-communities';
2526
// import SORT from 'utils/challenge-listing/sort';
2627
import { BUCKETS, filterChanged, sortChangedBucket } from 'utils/challenge-listing/buckets';
@@ -447,6 +448,7 @@ export class ListingContainer extends React.Component {
447448
// isBucketSwitching,
448449
// userChallenges,
449450
meta,
451+
setSearchText,
450452
} = this.props;
451453

452454
const { tokenV3 } = auth;
@@ -617,6 +619,7 @@ export class ListingContainer extends React.Component {
617619
// userChallenges={[]}
618620
isLoggedIn={isLoggedIn}
619621
meta={meta}
622+
setSearchText={setSearchText}
620623
/>
621624
</div>
622625
);
@@ -741,6 +744,7 @@ ListingContainer.propTypes = {
741744
getTotalChallengesCount: PT.func.isRequired,
742745
// userChallenges: PT.arrayOf(PT.string),
743746
// getUserChallenges: PT.func.isRequired,
747+
setSearchText: PT.func.isRequired,
744748
};
745749

746750
const mapStateToProps = (state, ownProps) => {
@@ -807,6 +811,7 @@ function mapDispatchToProps(dispatch) {
807811
const a = actions.challengeListing;
808812
const ah = headerActions.topcoderHeader;
809813
const sa = sidebarActions.challengeListing.sidebar;
814+
const fp = filterPanelActions.challengeListing.filterPanel;
810815
const ca = communityActions.tcCommunity;
811816
return {
812817
dropChallenges: () => dispatch(a.dropChallenges()),
@@ -880,6 +885,7 @@ function mapDispatchToProps(dispatch) {
880885
// dispatch(a.getUserChallengesInit(uuid));
881886
// dispatch(a.getUserChallengesDone(userId, tokenV3));
882887
// },
888+
setSearchText: text => dispatch(fp.setSearchText(text)),
883889
};
884890
}
885891

0 commit comments

Comments
 (0)