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

changes for #15 #618

Merged
merged 7 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions client/src/components/FiltersSideMenu/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export default function SearchTabFilters({ achievements }) {
};

const addLocationToFilter = (location) => {
const locationFilters = JSON.parse(JSON.stringify(search.selectedLocations));
const locationFilters = JSON.parse(
JSON.stringify(search.selectedLocations)
);

if (locationFilters.findIndex((s) => s.id === location.id) !== -1) {
return;
Expand All @@ -144,7 +146,9 @@ export default function SearchTabFilters({ achievements }) {
};

const removeLocationFromFilter = (location) => {
const locationFilters = JSON.parse(JSON.stringify(search.selectedLocations));
const locationFilters = JSON.parse(
JSON.stringify(search.selectedLocations)
);
const index = locationFilters.findIndex((s) => s.id === location.id);

if (index === -1) {
Expand Down Expand Up @@ -256,7 +260,7 @@ export default function SearchTabFilters({ achievements }) {
placeholder={"Search for a location"}
onSelect={addLocationToFilter}
purpose="locations"
companyAttrId={config.STANDARD_USER_ATTRIBUTES.location}
companyAttrId={search.getAttributeId(FILTERS.LOCATIONS)}
/>
{search.selectedLocations.length > 0 && (
<div className={utilityStyles.mt16}>
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/SuggestionBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import config from "../../config";
import api from "../../services/api";
import style from "./style.module.scss";
import _ from "lodash";
import { useSearch, FILTERS } from "../../lib/search";

const NO_RESULTS_FOUND = "no results found";
const DELAY_SEARCH = 300;
Expand Down Expand Up @@ -95,13 +96,19 @@ export default function SuggestionBox({
placeholder,
onSelect,
}) {
const search = useSearch();
const apiClient = api();
const [suggestions, setSuggestions] = React.useState([]);
const [value, setValue] = React.useState("");

const onChange = (event, { newValue }) => setValue(newValue.trim());

const onSuggestionsFetchRequested = async ({ value }) => {
if (purpose === "locations") {
if (!companyAttrId) {
companyAttrId = search.getAttributeId(FILTERS.LOCATIONS);
}
}
if (purpose === "skills") {
let data = await getSkillsSuggestions(apiClient, value);

Expand Down
3 changes: 3 additions & 0 deletions client/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ export default {
clientId: process.env.REACT_APP_AUTH0_CLIENTID,
audience: process.env.REACT_APP_AUTH0_AUDIENCE,
},

REACT_APP_ATTRIBUTE_ID_LOCATION:
process.env.REACT_APP_ATTRIBUTE_ID_LOCATION || "location",
};
5 changes: 5 additions & 0 deletions client/src/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ function useProvideSearch() {
setPopupShown(true);
};

const getAttributeId = (filter) => {
return filters[filter].id;
};

const isFilterActive = (filter) => {
return filters[filter].active;
};
Expand Down Expand Up @@ -133,6 +137,7 @@ function useProvideSearch() {
showPopup,
filters,
setFilters,
getAttributeId,
isFilterActive,
activateFilter,
deactivateFilter,
Expand Down
13 changes: 9 additions & 4 deletions client/src/pages/Search/Global.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export default function SearchGlobal({ keyword }) {
group: "Company attributes",
active: false,
};
if (companyAttr.name === config.REACT_APP_ATTRIBUTE_ID_LOCATION) {
filtersWithCompanyAttrs[FILTERS.LOCATIONS].id = companyAttr.id;
}
});

if (isSubscribed) {
Expand Down Expand Up @@ -206,10 +209,12 @@ export default function SearchGlobal({ keyword }) {
pageChanged = true;
}

if (_.isEqual(prevCriteria, criteria)
&& prevKeyword === keyword
&& prevOrderBy === orderBy
&& pageChanged === false) {
if (
_.isEqual(prevCriteria, criteria) &&
prevKeyword === keyword &&
prevOrderBy === orderBy &&
pageChanged === false
) {
return;
} else {
setPrevCriteria(criteria);
Expand Down