@@ -30,6 +30,7 @@ export default class PersonFinderData extends Component {
30
30
autoLoading : PropTypes . bool ,
31
31
boxClassName : PropTypes . string ,
32
32
uacId : PropTypes . number ,
33
+ locationId : PropTypes . number ,
33
34
} ;
34
35
35
36
static defaultProps = {
@@ -43,6 +44,7 @@ export default class PersonFinderData extends Component {
43
44
autoLoading : true ,
44
45
boxClassName : null ,
45
46
uacId : null ,
47
+ locationId : null ,
46
48
} ;
47
49
48
50
resultList = null ;
@@ -163,7 +165,7 @@ export default class PersonFinderData extends Component {
163
165
}
164
166
165
167
const {
166
- persons : enablePersons , sites : enableSites , includeOwn, uacId,
168
+ persons : enablePersons , sites : enableSites , includeOwn, uacId, locationId ,
167
169
} = this . props ;
168
170
169
171
const promises = [ ] ;
@@ -172,7 +174,7 @@ export default class PersonFinderData extends Component {
172
174
const loadSites = enableSites && this . loadMore [ LOCATION_RELATION ] && ( type === ALL_RELATIONS || type === LOCATION_RELATION ) ;
173
175
174
176
if ( uacId ) {
175
- promises . push ( loadPersons ? this . fetchUacPersons ( value , uacId ) : Promise . resolve ( false ) ) ;
177
+ promises . push ( loadPersons ? this . fetchUacPersons ( value , uacId , locationId ) : Promise . resolve ( false ) ) ;
176
178
} else {
177
179
promises . push ( loadPersons ? this . fetchPersonRelations ( value , includeOwn ) : Promise . resolve ( false ) ) ;
178
180
}
@@ -229,7 +231,7 @@ export default class PersonFinderData extends Component {
229
231
}
230
232
231
233
// eslint-disable-next-line class-methods-use-this
232
- async fetchUacPersons ( value , uacId ) {
234
+ async fetchUacPersons ( value , uacId , locationId ) {
233
235
const config = {
234
236
method : 'GET' ,
235
237
headers : {
@@ -238,23 +240,26 @@ export default class PersonFinderData extends Component {
238
240
mode : 'cors' ,
239
241
} ;
240
242
241
- const response = await fetch ( `https://sub50.tobit.com/backend/${ uacId } /usergroup/1/users?filter=${ value } ` , config ) ;
242
- const json = await response . json ( ) ;
243
-
244
- const result = { related : [ ] , unrelated : [ ] , type : PERSON_RELATION } ;
245
- json . forEach ( ( item ) => {
246
- result . related . push ( {
247
- firstName : item . firstname ,
248
- lastName : item . lastname ,
249
- personId : item . personId ,
250
- relationCount : 0 ,
251
- relations : [ ] ,
252
- score : 0 ,
253
- userId : item . id ,
243
+ const response = await fetch ( `https://sub50.tobit.com/backend/${ locationId || chayns . env . site . locationId } /usergroup/${ uacId } /users?filter=${ value } ` , config ) ;
244
+ if ( response . status === 200 ) {
245
+ const json = await response . json ( ) ;
246
+
247
+ const result = { related : [ ] , unrelated : [ ] , type : PERSON_RELATION } ;
248
+ json . forEach ( ( item ) => {
249
+ result . related . push ( {
250
+ firstName : item . firstname ,
251
+ lastName : item . lastname ,
252
+ personId : item . personId ,
253
+ relationCount : 0 ,
254
+ relations : [ ] ,
255
+ score : 0 ,
256
+ userId : item . id ,
257
+ } ) ;
254
258
} ) ;
255
- } ) ;
256
259
257
- return Promise . resolve ( result ) ;
260
+ return Promise . resolve ( result ) ;
261
+ }
262
+ return Promise . resolve ( null ) ;
258
263
}
259
264
260
265
async fetchPersonRelations ( value , canFindOwn = false ) {
0 commit comments