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

issue 386 fix #587

Merged
merged 1 commit into from
Jul 25, 2020
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
35 changes: 35 additions & 0 deletions client/src/components/editFiltersPopup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,43 @@ export default function EditFiltersPopup({ onCancel, onDone }) {
onDone(selectedFilters);
}
search.setFilters(searchFilters);
removeDataFromDisabledFilters(searchFilters)
};

const removeDataFromDisabledFilters = (searchFilters) => {
const companyAttrIdsToBeRemoved = []
for (const [key, value] of Object.entries(searchFilters)) {
if(value.group === "General attributes") {
if(!value.active) {
removeGeneralAttr(value.text);
}
} else {
if(!value.active) {
companyAttrIdsToBeRemoved.push(key);
}
}
}
search.clearSelectCompanyAttributes(companyAttrIdsToBeRemoved)
}

const removeGeneralAttr = (text) => {
if (text === "Location") {
search.selectLocations([])
}
if (text === "Skills") {
search.selectSkills([])
}
if (text === "Achievements") {
search.selectAchievements([])
}
if (text === "Availability") {
search.selectAvailability({
isAvailableSelected: false,
isUnavailableSelected: false
})
}
}

const handleFilterValueChanged = (filter, newValue) => {
var index = selectedFilters.indexOf(filter);
if (newValue) {
Expand Down
9 changes: 9 additions & 0 deletions client/src/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ function useProvideSearch() {
});
};

const clearSelectCompanyAttributes = (ids) => {
const selectedCmpAttr = {...selectedCompanyAttributes};
for (let id of ids) {
selectedCmpAttr[id] = [];
}
setSelectedCompanyAttributes(selectedCmpAttr)
}

const getCompanyAttrActiveFilter = () => {
const companyAttrActiveFilters = [];
for (const filter in filters) {
Expand All @@ -120,6 +128,7 @@ function useProvideSearch() {
selectAvailability: setSelectedAvailability,
selectedCompanyAttributes,
selectCompanyAttributes: setSelectedCompanyAttributes,
clearSelectCompanyAttributes,
popupShown,
showPopup,
filters,
Expand Down