This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree 5 files changed +31
-7
lines changed 5 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,9 @@ export default function SearchTabFilters({ achievements }) {
134
134
} ;
135
135
136
136
const addLocationToFilter = ( location ) => {
137
- const locationFilters = JSON . parse ( JSON . stringify ( search . selectedLocations ) ) ;
137
+ const locationFilters = JSON . parse (
138
+ JSON . stringify ( search . selectedLocations )
139
+ ) ;
138
140
139
141
if ( locationFilters . findIndex ( ( s ) => s . id === location . id ) !== - 1 ) {
140
142
return ;
@@ -144,7 +146,9 @@ export default function SearchTabFilters({ achievements }) {
144
146
} ;
145
147
146
148
const removeLocationFromFilter = ( location ) => {
147
- const locationFilters = JSON . parse ( JSON . stringify ( search . selectedLocations ) ) ;
149
+ const locationFilters = JSON . parse (
150
+ JSON . stringify ( search . selectedLocations )
151
+ ) ;
148
152
const index = locationFilters . findIndex ( ( s ) => s . id === location . id ) ;
149
153
150
154
if ( index === - 1 ) {
@@ -256,7 +260,7 @@ export default function SearchTabFilters({ achievements }) {
256
260
placeholder = { "Search for a location" }
257
261
onSelect = { addLocationToFilter }
258
262
purpose = "locations"
259
- companyAttrId = { config . STANDARD_USER_ATTRIBUTES . location }
263
+ companyAttrId = { search . getAttributeId ( FILTERS . LOCATIONS ) }
260
264
/>
261
265
{ search . selectedLocations . length > 0 && (
262
266
< div className = { utilityStyles . mt16 } >
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import config from "../../config";
4
4
import api from "../../services/api" ;
5
5
import style from "./style.module.scss" ;
6
6
import _ from "lodash" ;
7
+ import { useSearch , FILTERS } from "../../lib/search" ;
7
8
8
9
const NO_RESULTS_FOUND = "no results found" ;
9
10
const DELAY_SEARCH = 300 ;
@@ -95,13 +96,19 @@ export default function SuggestionBox({
95
96
placeholder,
96
97
onSelect,
97
98
} ) {
99
+ const search = useSearch ( ) ;
98
100
const apiClient = api ( ) ;
99
101
const [ suggestions , setSuggestions ] = React . useState ( [ ] ) ;
100
102
const [ value , setValue ] = React . useState ( "" ) ;
101
103
102
104
const onChange = ( event , { newValue } ) => setValue ( newValue . trim ( ) ) ;
103
105
104
106
const onSuggestionsFetchRequested = async ( { value } ) => {
107
+ if ( purpose === "locations" ) {
108
+ if ( ! companyAttrId ) {
109
+ companyAttrId = search . getAttributeId ( FILTERS . LOCATIONS ) ;
110
+ }
111
+ }
105
112
if ( purpose === "skills" ) {
106
113
let data = await getSkillsSuggestions ( apiClient , value ) ;
107
114
Original file line number Diff line number Diff line change @@ -37,4 +37,7 @@ export default {
37
37
clientId : process . env . REACT_APP_AUTH0_CLIENTID ,
38
38
audience : process . env . REACT_APP_AUTH0_AUDIENCE ,
39
39
} ,
40
+
41
+ REACT_APP_ATTRIBUTE_ID_LOCATION :
42
+ process . env . REACT_APP_ATTRIBUTE_ID_LOCATION || "location" ,
40
43
} ;
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ function useProvideSearch() {
66
66
setPopupShown ( true ) ;
67
67
} ;
68
68
69
+ const getAttributeId = ( filter ) => {
70
+ return filters [ filter ] . id ;
71
+ } ;
72
+
69
73
const isFilterActive = ( filter ) => {
70
74
return filters [ filter ] . active ;
71
75
} ;
@@ -133,6 +137,7 @@ function useProvideSearch() {
133
137
showPopup,
134
138
filters,
135
139
setFilters,
140
+ getAttributeId,
136
141
isFilterActive,
137
142
activateFilter,
138
143
deactivateFilter,
Original file line number Diff line number Diff line change @@ -116,6 +116,9 @@ export default function SearchGlobal({ keyword }) {
116
116
group : "Company attributes" ,
117
117
active : false ,
118
118
} ;
119
+ if ( companyAttr . name === config . REACT_APP_ATTRIBUTE_ID_LOCATION ) {
120
+ filtersWithCompanyAttrs [ FILTERS . LOCATIONS ] . id = companyAttr . id ;
121
+ }
119
122
} ) ;
120
123
121
124
if ( isSubscribed ) {
@@ -206,10 +209,12 @@ export default function SearchGlobal({ keyword }) {
206
209
pageChanged = true ;
207
210
}
208
211
209
- if ( _ . isEqual ( prevCriteria , criteria )
210
- && prevKeyword === keyword
211
- && prevOrderBy === orderBy
212
- && pageChanged === false ) {
212
+ if (
213
+ _ . isEqual ( prevCriteria , criteria ) &&
214
+ prevKeyword === keyword &&
215
+ prevOrderBy === orderBy &&
216
+ pageChanged === false
217
+ ) {
213
218
return ;
214
219
} else {
215
220
setPrevCriteria ( criteria ) ;
You can’t perform that action at this time.
0 commit comments