Parcourir la source

Merge branch 'search_edit' into Freehand

Eduardo Santin il y a 2 ans
Parent
révision
5b40c23cd4
1 fichiers modifiés avec 680 ajouts et 12 suppressions
  1. 680
    12
      screens/main/Search.js

+ 680
- 12
screens/main/Search.js Voir le fichier

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