Eduardo Santin vor 2 Jahren
Ursprung
Commit
56635b489d
1 geänderte Dateien mit 622 neuen und 12 gelöschten Zeilen
  1. 622
    12
      screens/main/Search.js

+ 622
- 12
screens/main/Search.js Datei anzeigen

@@ -44,7 +44,321 @@ const Tags = [
44 44
 ]
45 45
 
46 46
 
47
+const City = [
48
+  {
49
+      item: 'Adjuntas',
50
+      id: 0,
51
+  },
52
+  {
53
+      item: 'Aguada',
54
+      id: 1,
55
+  },
56
+  {
57
+      item: 'Aguadilla',
58
+      id: 2,
59
+  },
60
+  {
61
+      item: 'Aguas Buenas',
62
+      id: 3,
63
+  },
64
+  {
65
+      item: 'Aibonito',
66
+      id: 4,
67
+  },
68
+  {
69
+      item: 'Arecibo',
70
+      id: 5,
71
+  },
72
+  {
73
+      item: 'Arroyo',
74
+      id: 6,
75
+  },
76
+  {
77
+      item: 'Añasco',
78
+      id: 7,
79
+  },
80
+  {
81
+      item: 'Barceloneta',
82
+      id: 8,
83
+  },
84
+  {
85
+      item: 'Barranquitas',
86
+      id: 9,
87
+  },
88
+  {
89
+      item: 'Bayamón',
90
+      id: 10,
91
+  },
92
+  {
93
+      item: 'Cabo Rojo',
94
+      id: 11,
95
+  },
96
+  {
97
+      item: 'Caguas',
98
+      id: 12,
99
+  },
100
+  {
101
+      item: 'Camuy',
102
+      id: 13,
103
+  },
104
+  {
105
+      item: 'Canóvanas',
106
+      id: 14,
107
+  },
108
+  {
109
+      item: 'Carolina',
110
+      id: 15,
111
+  },
112
+  {
113
+      item: 'Cataño',
114
+      id: 16,
115
+  },
116
+  {
117
+      item: 'Cayey',
118
+      id: 17,
119
+  },
120
+  {
121
+      item: 'Ceiba',
122
+      id: 18,
123
+  },
124
+  {
125
+      item: 'Ciales',
126
+      id: 19,
127
+  },
128
+  {
129
+      item: 'Cidra',
130
+      id: 20,
131
+  },
132
+  {
133
+      item: 'Coamo',
134
+      id: 21,
135
+  },
136
+  {
137
+      item: 'Comerío',
138
+      id: 22,
139
+  },
140
+  {
141
+      item: 'Corozal',
142
+      id: 23,
143
+  },
144
+  {
145
+      item: 'Culebra',
146
+      id: 24,
147
+  },
148
+  {
149
+      item: 'Dorado',
150
+      id: 25,
151
+  },
152
+  {
153
+      item: 'Fajardo',
154
+      id: 26,
155
+  },
156
+  {
157
+      item: 'Florida',
158
+      id: 27,
159
+  },
160
+  {
161
+      item: 'Guayama',
162
+      id: 28,
163
+  },
164
+  {
165
+      item: 'Guayanilla',
166
+      id: 29,
167
+  },
168
+  {
169
+      item: 'Guaynabo',
170
+      id: 30,
171
+  },
172
+  {
173
+      item: 'Gurabo',
174
+      id: 31,
175
+  },
176
+  {
177
+      item: 'Guánica',
178
+      id: 32,
179
+  },
180
+  {
181
+      item: 'Hatillo',
182
+      id: 33,
183
+  },
184
+  {
185
+      item: 'Hormigueros',
186
+      id: 34,
187
+  },
188
+  {
189
+      item: 'Humacao',
190
+      id: 35,
191
+  },
192
+  {
193
+      item: 'Isabela',
194
+      id: 36,
195
+  },
196
+  {
197
+      item: 'Jayuya',
198
+      id: 37,
199
+  },
200
+  {
201
+      item: 'Juana Díaz',
202
+      id: 38,
203
+  },
204
+  {
205
+      item: 'Juncos',
206
+      id: 39,
207
+  },
208
+  {
209
+      item: 'Lajas',
210
+      id: 40,
211
+  },
212
+  {
213
+      item: 'Lares',
214
+      id: 41,
215
+  },
216
+  {
217
+      item: 'Las Marías',
218
+      id: 42,
219
+  },
220
+  {
221
+      item: 'Las Piedras',
222
+      id: 43,
223
+  },
224
+  {
225
+      item: 'Loíza',
226
+      id: 44,
227
+  },
228
+  {
229
+      item: 'Luquillo',
230
+      id: 45,
231
+  },
232
+  {
233
+      item: 'Manatí',
234
+      id: 46,
235
+  },
236
+  {
237
+      item: 'Maricao',
238
+      id: 47,
239
+  },
240
+  {
241
+      item: 'Maunabo',
242
+      id: 48,
243
+  },
244
+  {
245
+      item: 'Mayagüez',
246
+      id: 49,
247
+  },
248
+  {
249
+      item: 'Moca',
250
+      id: 50,
251
+  },
252
+  {
253
+      item: 'Morovis',
254
+      id: 51,
255
+  },
256
+  {
257
+      item: 'Naguabo',
258
+      id: 52,
259
+  },
260
+  {
261
+      item: 'Naranjito',
262
+      id: 53,
263
+  },
264
+  {
265
+      item: 'Orocovis',
266
+      id: 54,
267
+  },
268
+  {
269
+      item: 'Patillas',
270
+      id: 55,
271
+  },
272
+  {
273
+      item: 'Peñuelas',
274
+      id: 56,
275
+  },
276
+  {
277
+      item: 'Ponce',
278
+      id: 57,
279
+  },
280
+  {
281
+      item: 'Quebradillas',
282
+      id: 58,
283
+  },
284
+  {
285
+      item: 'Rincón',
286
+      id: 59,
287
+  },
288
+  {
289
+      item: 'Rio Grande',
290
+      id: 60,
291
+  },
292
+  {
293
+      item: 'Sabana Grande',
294
+      id: 61,
295
+  },
296
+  {
297
+      item: 'Salinas',
298
+      id: 62,
299
+  },
300
+  {
301
+      item: 'San Germán',
302
+      id: 63,
303
+  },
304
+  {
305
+      item: 'San Juan',
306
+      id: 64,
307
+  },
308
+  {
309
+      item: 'San Lorenzo',
310
+      id: 65,
311
+  },
312
+  {
313
+      item: 'San Sebastián',
314
+      id: 66,
315
+  },
316
+  {
317
+      item: 'Santa Isabel',
318
+      id: 67,
319
+  },
320
+  {
321
+      item: 'Toa Alta',
322
+      id: 68,
323
+  },
324
+  {
325
+      item: 'Toa Baja',
326
+      id: 69,
327
+  },
328
+  {
329
+      item: 'Trujillo Alto',
330
+      id: 70,
331
+  },
332
+  {
333
+      item: 'Utuado',
334
+      id: 71,
335
+  },
336
+  {
337
+      item: 'Vega Alta',
338
+      id: 72,
339
+  },
340
+  {
341
+      item: 'Vega Baja',
342
+      id: 73,
343
+  },
344
+  {
345
+      item: 'Vieques',
346
+      id: 74,
347
+  },
348
+  {
349
+      item: 'Villalba',
350
+      id: 75,
351
+  },
352
+  {
353
+      item: 'Yabucoa',
354
+      id: 76,
355
+  },
356
+  {
357
+      item: 'Yauco',
358
+      id: 77,
359
+  },
47 360
 
361
+]
48 362
 
49 363
 
50 364
 function Search({route, navigation }) {
@@ -55,14 +369,16 @@ function Search({route, navigation }) {
55 369
   
56 370
   const [users, setUsers] = useState([])
57 371
   const [selectedTags, setSelectedTags] = useState([])
372
+  const [selectedCity, setSelectedCity] = useState([])
373
+
58 374
 
59 375
   
60
-  const fetchUsers = (tags) => {
376
+  const fetchUsers = (tags, city) => {
61 377
     
62 378
     //if the array that have the interpreter tags
63 379
     //and the day tags are empty we dont send the query seeing as the user
64 380
     //is not searching for anything yet 
65
-    if (tags.length === 0) {
381
+    if (tags.length === 0 && city.length === 0) {
66 382
       return
67 383
     }
68 384
 
@@ -100,6 +416,277 @@ function Search({route, navigation }) {
100 416
         query = query.where('english', '==', true)
101 417
       }
102 418
   }
419
+  for (let i = 0; i < tags.length; i++) {
420
+
421
+    //Reset Flag.
422
+    mapflag = false
423
+
424
+    //check which tags where called in the search 
425
+    if (tags[i].id === 'PL') {
426
+      console.log('Presencial')
427
+      query = query.where('face_to_face', '==', true)
428
+      mapflag = true
429
+    }
430
+    if (tags[i].id == 'ON') {
431
+      query = query.where('virtual', '==', true)
432
+    }
433
+    if (tags[i].id == 'IL') {
434
+      query = query.where('personal', '==', true)
435
+    }
436
+    if (tags[i].id == 'GL') {
437
+      query = query.where('group', '==', true)
438
+    }
439
+    if (tags[i].id == 'ESP') {
440
+      query = query.where('spanish', '==', true)
441
+    }
442
+    if (tags[i].id == 'ING') {
443
+      query = query.where('english', '==', true)
444
+    }
445
+}
446
+  if(city.length > 0){
447
+    switch(city[0].id){
448
+      case 0:
449
+        query = query.where('city', '==', 'Adjuntas')
450
+
451
+
452
+      case 1:
453
+        query = query.where('city', '==', 'Aguada')
454
+
455
+      case 2:
456
+        query = query.where('city', '==', 'Aguadilla')
457
+
458
+      case 3:
459
+        query = query.where('city', '==', 'Aguas Buenas')
460
+      
461
+      case 4:
462
+        query = query.where('city', '==', 'Aibonito')
463
+      
464
+      case 5:
465
+        query = query.where('city', '==', 'Arecibo')
466
+      
467
+      case 6:
468
+        query = query.where('city', '==', 'Arroyo')
469
+      
470
+      case 7:
471
+        query = query.where('city', '==', 'Añasco')
472
+      
473
+      case 8:
474
+        query = query.where('city', '==', 'Barceloneta')
475
+      
476
+      case 9:
477
+        query = query.where('city', '==', 'Barranquitas')
478
+      
479
+      case 10:
480
+        query = query.where('city', '==', 'Bayamón')
481
+      
482
+      case 11:
483
+        query = query.where('city', '==', 'Cabo Rojo')
484
+      
485
+      case 12:
486
+        query = query.where('city', '==', 'Caguas')
487
+      
488
+      case 13:
489
+        query = query.where('city', '==', 'Camuy')
490
+      
491
+      case 14:
492
+        query = query.where('city', '==', 'Canóvanas')
493
+      
494
+      case 15:
495
+        query = query.where('city', '==', 'Carolina')
496
+
497
+      case 16:
498
+        query = query.where('city', '==', 'Cataño')
499
+
500
+      case 17:
501
+        query = query.where('city', '==', 'Cayey')
502
+      
503
+      case 18:
504
+        query = query.where('city', '==', 'Ceiba')
505
+      
506
+      case 19:
507
+        query = query.where('city', '==', 'Ciales')
508
+      
509
+      case 20:
510
+        query = query.where('city', '==', 'Cidra')
511
+
512
+      case 21:
513
+        query = query.where('city', '==', 'Coamo')
514
+
515
+      case 22:
516
+        query = query.where('city', '==', 'Comerío')
517
+
518
+      case 23:
519
+        query = query.where('city', '==', 'Corozal')
520
+
521
+      case 24:
522
+        query = query.where('city', '==', 'Culebra')
523
+      
524
+      case 25:
525
+        query = query.where('city', '==', 'Dorado')
526
+
527
+      case 26:
528
+        query = query.where('city', '==', 'Fajardo')
529
+
530
+      case 27:
531
+        query = query.where('city', '==', 'Florida')
532
+
533
+      case 28:
534
+        query = query.where('city', '==', 'Guánica')
535
+      
536
+      case 29:
537
+        query = query.where('city', '==', 'Guayama')
538
+
539
+      case 30:
540
+        query = query.where('city', '==', 'Guayanilla')
541
+      
542
+      case 31:
543
+        query = query.where('city', '==', 'Guaynabo')
544
+
545
+      case 32:
546
+        query = query.where('city', '==', 'Gurabo')
547
+
548
+      case 33:
549
+        query = query.where('city', '==', 'Hatillo')
550
+
551
+      case 34:
552
+        query = query.where('city', '==', 'Hormigueros')
553
+
554
+      case 35:
555
+        query = query.where('city', '==', 'Humacao')
556
+
557
+      case 36:
558
+        query = query.where('city', '==', 'Isabela')
559
+
560
+      case 37:
561
+        query = query.where('city', '==', 'Jayuya')
562
+
563
+      case 38:
564
+        query = query.where('city', '==', 'Juana Díaz')
565
+      
566
+      case 39:
567
+        query = query.where('city', '==', 'Juncos')
568
+
569
+      case 40:
570
+        query = query.where('city', '==', 'Lajas')
571
+
572
+      case 41:
573
+        query = query.where('city', '==', 'Lares')
574
+
575
+      case 42:
576
+        query = query.where('city', '==', 'Las Marías')
577
+
578
+      case 43:
579
+        query = query.where('city', '==', 'Las Piedras')
580
+
581
+      case 44:
582
+        query = query.where('city', '==', 'Loíza')
583
+
584
+      case 45:
585
+        query = query.where('city', '==', 'Luquillo')
586
+
587
+      case 46:
588
+        query = query.where('city', '==', 'Manatí')
589
+
590
+      case 47:
591
+        query = query.where('city', '==', 'Maricao')
592
+
593
+      case 48:
594
+        query = query.where('city', '==', 'Maunabo')
595
+
596
+      case 49:
597
+        query = query.where('city', '==', 'Mayagüez')
598
+
599
+      case 50:
600
+        query = query.where('city', '==', 'Moca')
601
+
602
+      case 51:
603
+        query = query.where('city', '==', 'Morovis')
604
+
605
+      case 52:
606
+        query = query.where('city', '==', 'Naguabo')
607
+
608
+      case 53:
609
+        query = query.where('city', '==', 'Naranjito')
610
+
611
+      case 54:
612
+        query = query.where('city', '==', 'Orocovis')
613
+
614
+      case 55:
615
+        query = query.where('city', '==', 'Patillas')
616
+
617
+      case 56:
618
+        query = query.where('city', '==', 'Peñuelas')
619
+
620
+      case 57:
621
+        query = query.where('city', '==', 'Ponce')
622
+
623
+      case 58:
624
+        query = query.where('city', '==', 'Quebradillas')
625
+
626
+      case 59:
627
+        query = query.where('city', '==', 'Rincón')
628
+
629
+      case 60:
630
+        query = query.where('city', '==', 'Río Grande')
631
+
632
+      case 61:
633
+        query = query.where('city', '==', 'Sabana Grande')
634
+
635
+      case 62:
636
+        query = query.where('city', '==', 'Salinas')
637
+
638
+      case 63:
639
+        query = query.where('city', '==', 'San Germán')
640
+
641
+      case 64:
642
+        query = query.where('city', '==', 'San Juan')
643
+
644
+      case 65:
645
+        query = query.where('city', '==', 'San Lorenzo')
646
+
647
+      case 66:
648
+        query = query.where('city', '==', 'San Sebastián')
649
+
650
+      case 67:
651
+        query = query.where('city', '==', 'Santa Isabel')
652
+
653
+      case 68:
654
+        query = query.where('city', '==', 'Toa Alta')
655
+
656
+      case 69:
657
+        query = query.where('city', '==', 'Toa Baja')
658
+
659
+      case 70:
660
+        query = query.where('city', '==', 'Trujillo Alto')
661
+
662
+      case 71:
663
+        query = query.where('city', '==', 'Utuado')
664
+
665
+      case 72:
666
+        query = query.where('city', '==', 'Vega Alta')
667
+
668
+      case 73:
669
+        query = query.where('city', '==', 'Vega Baja')
670
+
671
+      case 74:
672
+        query = query.where('city', '==', 'Vieques')
673
+
674
+      case 75:
675
+        query = query.where('city', '==', 'Villalba')
676
+
677
+      case 76:
678
+        query = query.where('city', '==', 'Yabucoa')
679
+
680
+      case 77:
681
+        query = query.where('city', '==', 'Yauco')
682
+
683
+      break;
684
+
685
+    }
686
+
687
+
688
+  }
689
+
103 690
   
104 691
     query.get().then(querySnapshot => {
105 692
       console.log('Total users: ', querySnapshot.size);
@@ -125,10 +712,33 @@ function Search({route, navigation }) {
125 712
     <ScrollView>
126 713
     <View style={{ margin: 30 }}>
127 714
       <View style={{ width: '100%', alignItems: 'center' }}>
128
-        <Text style={{ fontSize: 30, paddingBottom: 20 }}>Busqueda</Text>
715
+        <Text style={{ fontSize: 30, paddingBottom: 20 }}>Search</Text>
129 716
       </View>
130
-      <Text style={{ fontSize: 20, paddingBottom: 10 }}>Filtro de Interpretes</Text>
717
+
718
+      <Text style={{ fontSize: 20, paddingBottom: 10 }}>Interpreter city</Text>
719
+      <SelectBox
720
+        label="Select single"
721
+        options={City}
722
+        value={selectedCity}
723
+        onChange={onChange()}
724
+        hideInputFilter={false}
725
+        arrowIconColor="#E4CD05"
726
+        toggleIconColor='#E4CD05'
727
+        searchIconColor='#E4CD05'
728
+
729
+
730
+      />
731
+      <Text style={{ fontSize: 20, paddingBottom: 10 }}>Interpreter Tags</Text>
732
+
733
+      
734
+
131 735
       <SelectBox
736
+        label="Select multiple"
737
+        options={Tags}
738
+        selectedValues={selectedTags}
739
+        onMultiSelect={onMultiChange()}
740
+        onTapClose={onMultiChange()}
741
+        isMulti
132 742
         arrowIconColor='#E4CD05'
133 743
         toggleIconColor='#E4CD05'
134 744
         searchIconColor='#E4CD05'
@@ -145,16 +755,12 @@ function Search({route, navigation }) {
145 755
           color: '#000000',
146 756
           fontSize: 20,
147 757
         }}
148
-        label="Select multiple"
149
-        options={Tags}
150
-        selectedValues={selectedTags}
151
-        onMultiSelect={onMultiChange()}
152
-        onTapClose={onMultiChange()}
153
-        isMulti
154
-      />
758
+
759
+          />
760
+
155 761
 
156 762
       {/* button that will fetch the users */}
157
-      <Button title='Buscar' onPress={() => fetchUsers(selectedTags)}/>
763
+      <Button title='Buscar' onPress={() => fetchUsers(selectedTags, selectedCity)}/>
158 764
 
159 765
 
160 766
       <FlatList
@@ -183,6 +789,10 @@ function Search({route, navigation }) {
183 789
   function onMultiChange() {
184 790
     return (item) => setSelectedTags(xorBy(selectedTags, [item], 'id'))
185 791
   }
792
+
793
+  function onChange(){
794
+    return (item) => setSelectedCity(item)
795
+  }
186 796
   
187 797
   function dothing(item_id, item_dates, i_token, u_token, I_username) {
188 798
     console.log('This is the item id: ', item_id, "With i_token: ", i_token, " u_token : ", u_token)