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

fix: issue #47 #69

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/containers/Challenges/Listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Listing = ({
startDateEnd,
updateFilter,
bucket,
tags,
getChallenges,
}) => {
const sortByOptions = utils.createDropdownOptions(
Expand Down Expand Up @@ -106,7 +107,7 @@ const Listing = ({
<ChallengeItem
challenge={challenge}
onClickTag={(tag) => {
const filterChange = { search: tag };
const filterChange = { tags: [...tags, tag] };
updateFilter(filterChange);
getChallenges(filterChange);
}}
Expand Down
4 changes: 4 additions & 0 deletions src/containers/Challenges/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Challenges = ({
getChallenges,
updateFilter,
bucket,
tags,
}) => {
const [initialized, setInitialized] = useState(false);

Expand All @@ -40,6 +41,7 @@ const Challenges = ({
startDateEnd={startDateEnd}
updateFilter={updateFilter}
bucket={bucket}
tags={tags}
getChallenges={getChallenges}
/>
)}
Expand All @@ -58,6 +60,7 @@ Challenges.propTypes = {
getChallenges: PT.func,
updateFilter: PT.func,
bucket: PT.string,
tags: PT.arrayOf(PT.string),
};

const mapStateToProps = (state) => ({
Expand All @@ -70,6 +73,7 @@ const mapStateToProps = (state) => ({
startDateEnd: state.filter.challenge.startDateEnd,
challenges: state.challenges.challengesFiltered,
bucket: state.filter.challenge.bucket,
tags: state.filter.challenge.tags,
});

const mapDispatchToProps = {
Expand Down
9 changes: 5 additions & 4 deletions src/containers/Filter/ChallengeFilter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ChallengeFilter = ({
saveFilter,
clearFilter,
}) => {
const tagOptions = utils.createDropdownTermOptions(challengeTags);
const tagOptions = utils.createDropdownTermOptions(challengeTags, tags);
const bucketOptions = utils.createRadioOptions(challengeBuckets, bucket);

const [filter, setFilter] = useState(
Expand All @@ -42,7 +42,6 @@ const ChallengeFilter = ({
})
);

utils.setSelectedDropdownTermOptions(tagOptions, filter.tags);

return (
<div styleName="filter">
Expand Down Expand Up @@ -110,10 +109,12 @@ const ChallengeFilter = ({
const selectedTagOptions = utils.getSelectedDropdownTermsOptions(
newTagOptions
);
setFilter({
const filterChange = {
...filter,
tags: selectedTagOptions.map((tagOption) => tagOption.label),
});
}
setFilter(filterChange);
saveFilter(filterChange);
}}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function setSelectedDropdownOptions(options, selectedValues) {
export function createDropdownTermOptions(values, selectedValues) {
return values.map((value) => ({
label: `${value}`,
selected: !!selectedValues && selectedValues.includes[value],
selected: !!selectedValues && selectedValues.includes(value),
}));
}

Expand Down