@@ -184,14 +184,14 @@ export class ProgramCoordinatorService {
184
184
) {
185
185
return response . status ( 200 ) . json ( {
186
186
success : false ,
187
- message : 'User already exists!' ,
188
187
data : { } ,
188
+ message : 'User already exists!' ,
189
189
} ) ;
190
190
} else {
191
191
return response . status ( 200 ) . json ( {
192
192
success : false ,
193
- message : registerUserRes . error . message ,
194
193
data : { } ,
194
+ message : registerUserRes . error . message ,
195
195
} ) ;
196
196
}
197
197
} else if ( registerUserRes . headers . location ) {
@@ -306,13 +306,13 @@ export class ProgramCoordinatorService {
306
306
307
307
return response . status ( 200 ) . send ( {
308
308
success : true ,
309
- message : 'User created successfully' ,
310
309
data : {
311
310
user : result ?. data ,
312
311
keycloak_id : keycloak_id ,
313
312
username : data_to_create_user . username ,
314
313
password : password ,
315
314
} ,
315
+ message : 'User created successfully' ,
316
316
} ) ;
317
317
} else {
318
318
return response . status ( 200 ) . json ( {
@@ -435,21 +435,18 @@ export class ProgramCoordinatorService {
435
435
}
436
436
let userFilter = [ ] ;
437
437
438
- if ( body ?. search ) {
439
- if ( body . search ) {
440
- let first_name = body . search . split ( ' ' ) [ 0 ] ;
441
- let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
442
-
443
- if ( last_name ?. length > 0 ) {
444
- userFilter . push ( `
445
- first_name: { _ilike: "%${ first_name } %" },
446
- last_name: { _ilike: "%${ last_name } %" }
447
- ` ) ;
448
- } else {
449
- userFilter . push (
450
- `first_name: { _ilike: "%${ first_name } %" }` ,
451
- ) ;
452
- }
438
+ if ( body . search && body . search !== '' ) {
439
+ let first_name = body . search . split ( ' ' ) [ 0 ] ;
440
+ let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
441
+ if ( / ^ \d + $ / . test ( body . search ) ) {
442
+ userFilter . push ( `id: {_eq: ${ body . search } }` ) ;
443
+ } else if ( last_name ?. length > 0 ) {
444
+ userFilter . push ( `
445
+ first_name: { _ilike: "%${ first_name } %" },
446
+ last_name: { _ilike: "%${ last_name } %" }
447
+ ` ) ;
448
+ } else {
449
+ userFilter . push ( `first_name: { _ilike: "%${ first_name } %" }` ) ;
453
450
}
454
451
}
455
452
@@ -675,31 +672,28 @@ export class ProgramCoordinatorService {
675
672
}
676
673
let userFilter = [ ] ;
677
674
678
- if ( body ? .search ) {
679
- if ( body . search ) {
680
- let first_name = body . search . split ( ' ' ) [ 0 ] ;
681
- let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
682
-
683
- if ( last_name ?. length > 0 ) {
684
- userFilter . push ( `
675
+ if ( body . search && body . search !== '' ) {
676
+ let first_name = body . search . split ( ' ' ) [ 0 ] ;
677
+ let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
678
+ if ( / ^ \d + $ / . test ( body . search ) ) {
679
+ userFilter . push ( `id: {_eq: ${ body . search } }` ) ;
680
+ } else if ( last_name ?. length > 0 ) {
681
+ userFilter . push ( `
685
682
first_name: { _ilike: "%${ first_name } %" },
686
- last_name: { _ilike: "%${ last_name } %" }
687
- ` ) ;
688
- } else {
689
- userFilter . push (
690
- `first_name: { _ilike: "%${ first_name } %" }` ,
691
- ) ;
692
- }
693
- }
694
- if ( body . district ) {
695
- userFilter . push (
696
- `district: {_in: ${ JSON . stringify ( body ?. district ) } }` ,
697
- ) ;
698
- }
699
- if ( body . block ) {
700
- userFilter . push ( `block: {_in: ${ JSON . stringify ( body ?. block ) } }` ) ;
683
+ last_name: { _ilike: "%${ last_name } %" }
684
+ ` ) ;
685
+ } else {
686
+ userFilter . push ( `first_name: { _ilike: "%${ first_name } %" }` ) ;
701
687
}
702
688
}
689
+ if ( body . district ) {
690
+ userFilter . push (
691
+ `district: {_in: ${ JSON . stringify ( body ?. district ) } }` ,
692
+ ) ;
693
+ }
694
+ if ( body . block ) {
695
+ userFilter . push ( `block: {_in: ${ JSON . stringify ( body ?. block ) } }` ) ;
696
+ }
703
697
704
698
if ( userFilter . length > 0 ) {
705
699
filter . push ( `users: {${ userFilter . join ( ', ' ) } }` ) ;
@@ -841,21 +835,18 @@ export class ProgramCoordinatorService {
841
835
//get list of available prerak list for given cohort.
842
836
let userFilter = [ ] ;
843
837
844
- if ( body ?. search ) {
845
- if ( body . search ) {
846
- let first_name = body . search . split ( ' ' ) [ 0 ] ;
847
- let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
848
-
849
- if ( last_name ?. length > 0 ) {
850
- userFilter . push ( `
851
- first_name: { _ilike: "%${ first_name } %" },
852
- last_name: { _ilike: "%${ last_name } %" }
853
- ` ) ;
854
- } else {
855
- userFilter . push (
856
- `first_name: { _ilike: "%${ first_name } %" }` ,
857
- ) ;
858
- }
838
+ if ( body . search && body . search !== '' ) {
839
+ let first_name = body . search . split ( ' ' ) [ 0 ] ;
840
+ let last_name = body . search . split ( ' ' ) [ 1 ] || '' ;
841
+ if ( / ^ \d + $ / . test ( body . search ) ) {
842
+ userFilter . push ( `id: {_eq: ${ body . search } }` ) ;
843
+ } else if ( last_name ?. length > 0 ) {
844
+ userFilter . push ( `
845
+ first_name: { _ilike: "%${ first_name } %" },
846
+ last_name: { _ilike: "%${ last_name } %" }
847
+ ` ) ;
848
+ } else {
849
+ userFilter . push ( `first_name: { _ilike: "%${ first_name } %" }` ) ;
859
850
}
860
851
}
861
852
if ( body . district ) {
0 commit comments