Browse Source

search edited for cities

Eduardo Santin 2 years ago
parent
commit
9d85ee0ae6
1 changed files with 93 additions and 35 deletions
  1. 93
    35
      screens/main/Search.js

+ 93
- 35
screens/main/Search.js View File

@@ -46,6 +46,10 @@ const Tags = [
46 46
 
47 47
 const City = [
48 48
   {
49
+    item: 'None',
50
+    id: -1,
51
+  },
52
+  {
49 53
       item: 'Adjuntas',
50 54
       id: 0,
51 55
   },
@@ -357,6 +361,7 @@ const City = [
357 361
       item: 'Yauco',
358 362
       id: 77,
359 363
   },
364
+  
360 365
 
361 366
 ]
362 367
 
@@ -378,7 +383,9 @@ function Search({route, navigation }) {
378 383
     //if the array that have the interpreter tags
379 384
     //and the day tags are empty we dont send the query seeing as the user
380 385
     //is not searching for anything yet 
381
-    if (tags.length === 0 && city.length === 0) {
386
+    // console.log(tags.length)
387
+    // console.log(city.id)
388
+    if (tags.length === 0 && (typeof city.id ==="undefined" || city.id === -1)) {
382 389
       return
383 390
     }
384 391
 
@@ -416,277 +423,328 @@ function Search({route, navigation }) {
416 423
         query = query.where('english', '==', true)
417 424
       }
418 425
   }
419
-  for (let i = 0; i < tags.length; i++) {
420
-
421
-    //Reset Flag.
422
-    mapflag = false
426
+  
423 427
 
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){
428
+    
429
+    switch(city.id){
448 430
       case 0:
449 431
         query = query.where('city', '==', 'Adjuntas')
432
+        break;
450 433
 
451 434
 
452 435
       case 1:
453 436
         query = query.where('city', '==', 'Aguada')
437
+        break;
454 438
 
455 439
       case 2:
456 440
         query = query.where('city', '==', 'Aguadilla')
441
+        break;
457 442
 
458 443
       case 3:
459 444
         query = query.where('city', '==', 'Aguas Buenas')
445
+        break;
460 446
       
461 447
       case 4:
462 448
         query = query.where('city', '==', 'Aibonito')
449
+        break;
463 450
       
464 451
       case 5:
465 452
         query = query.where('city', '==', 'Arecibo')
453
+        break;
466 454
       
467 455
       case 6:
468 456
         query = query.where('city', '==', 'Arroyo')
457
+        break;
469 458
       
470 459
       case 7:
471 460
         query = query.where('city', '==', 'Añasco')
461
+        break;
472 462
       
473 463
       case 8:
474 464
         query = query.where('city', '==', 'Barceloneta')
465
+        break;
475 466
       
476 467
       case 9:
477 468
         query = query.where('city', '==', 'Barranquitas')
469
+        break;
478 470
       
479 471
       case 10:
480 472
         query = query.where('city', '==', 'Bayamón')
473
+        break;
481 474
       
482 475
       case 11:
483 476
         query = query.where('city', '==', 'Cabo Rojo')
477
+        break;
484 478
       
485 479
       case 12:
486 480
         query = query.where('city', '==', 'Caguas')
481
+        break;
487 482
       
488 483
       case 13:
489 484
         query = query.where('city', '==', 'Camuy')
485
+        break;
490 486
       
491 487
       case 14:
492 488
         query = query.where('city', '==', 'Canóvanas')
489
+        break;
493 490
       
494 491
       case 15:
495 492
         query = query.where('city', '==', 'Carolina')
493
+        break;
496 494
 
497 495
       case 16:
498 496
         query = query.where('city', '==', 'Cataño')
497
+        break;
499 498
 
500 499
       case 17:
501 500
         query = query.where('city', '==', 'Cayey')
502
-      
501
+        break;
502
+
503 503
       case 18:
504 504
         query = query.where('city', '==', 'Ceiba')
505
-      
505
+        break;
506
+
506 507
       case 19:
507 508
         query = query.where('city', '==', 'Ciales')
509
+        break;
508 510
       
509 511
       case 20:
510 512
         query = query.where('city', '==', 'Cidra')
513
+        break;
511 514
 
512 515
       case 21:
513 516
         query = query.where('city', '==', 'Coamo')
517
+        break;
514 518
 
515 519
       case 22:
516 520
         query = query.where('city', '==', 'Comerío')
521
+        break;
517 522
 
518 523
       case 23:
519 524
         query = query.where('city', '==', 'Corozal')
525
+        break;
520 526
 
521 527
       case 24:
522 528
         query = query.where('city', '==', 'Culebra')
529
+        break;
523 530
       
524 531
       case 25:
525 532
         query = query.where('city', '==', 'Dorado')
533
+        break;
526 534
 
527 535
       case 26:
528 536
         query = query.where('city', '==', 'Fajardo')
537
+        break;
529 538
 
530 539
       case 27:
531 540
         query = query.where('city', '==', 'Florida')
541
+        break;
532 542
 
533 543
       case 28:
534 544
         query = query.where('city', '==', 'Guánica')
545
+        break;
535 546
       
536 547
       case 29:
537 548
         query = query.where('city', '==', 'Guayama')
549
+        break;
538 550
 
539 551
       case 30:
540 552
         query = query.where('city', '==', 'Guayanilla')
553
+        break;
541 554
       
542 555
       case 31:
543 556
         query = query.where('city', '==', 'Guaynabo')
557
+        break;
544 558
 
545 559
       case 32:
546 560
         query = query.where('city', '==', 'Gurabo')
561
+        break;
547 562
 
548 563
       case 33:
549 564
         query = query.where('city', '==', 'Hatillo')
565
+        break;
550 566
 
551 567
       case 34:
552 568
         query = query.where('city', '==', 'Hormigueros')
569
+        break;
553 570
 
554 571
       case 35:
555 572
         query = query.where('city', '==', 'Humacao')
573
+        break;
556 574
 
557 575
       case 36:
558 576
         query = query.where('city', '==', 'Isabela')
577
+        break;
559 578
 
560 579
       case 37:
561 580
         query = query.where('city', '==', 'Jayuya')
581
+        break;
562 582
 
563 583
       case 38:
564 584
         query = query.where('city', '==', 'Juana Díaz')
585
+        break;
565 586
       
566 587
       case 39:
567 588
         query = query.where('city', '==', 'Juncos')
589
+        break;
568 590
 
569 591
       case 40:
570 592
         query = query.where('city', '==', 'Lajas')
593
+        break;
571 594
 
572 595
       case 41:
573 596
         query = query.where('city', '==', 'Lares')
597
+        break;
574 598
 
575 599
       case 42:
576 600
         query = query.where('city', '==', 'Las Marías')
601
+        break;
577 602
 
578 603
       case 43:
579 604
         query = query.where('city', '==', 'Las Piedras')
605
+        break;
580 606
 
581 607
       case 44:
582 608
         query = query.where('city', '==', 'Loíza')
609
+        break;
583 610
 
584 611
       case 45:
585 612
         query = query.where('city', '==', 'Luquillo')
613
+        break;
586 614
 
587 615
       case 46:
588 616
         query = query.where('city', '==', 'Manatí')
617
+        break;
589 618
 
590 619
       case 47:
591 620
         query = query.where('city', '==', 'Maricao')
621
+        break;
592 622
 
593 623
       case 48:
594 624
         query = query.where('city', '==', 'Maunabo')
625
+        break;
595 626
 
596 627
       case 49:
597 628
         query = query.where('city', '==', 'Mayagüez')
629
+        break;
598 630
 
599 631
       case 50:
600 632
         query = query.where('city', '==', 'Moca')
633
+        break;
601 634
 
602 635
       case 51:
603 636
         query = query.where('city', '==', 'Morovis')
637
+        break;
604 638
 
605 639
       case 52:
606 640
         query = query.where('city', '==', 'Naguabo')
641
+        break;
607 642
 
608 643
       case 53:
609 644
         query = query.where('city', '==', 'Naranjito')
645
+        break;
610 646
 
611 647
       case 54:
612 648
         query = query.where('city', '==', 'Orocovis')
649
+        break;
613 650
 
614 651
       case 55:
615 652
         query = query.where('city', '==', 'Patillas')
653
+        break;
616 654
 
617 655
       case 56:
618 656
         query = query.where('city', '==', 'Peñuelas')
657
+        break;
619 658
 
620 659
       case 57:
621 660
         query = query.where('city', '==', 'Ponce')
661
+        break;
622 662
 
623 663
       case 58:
624 664
         query = query.where('city', '==', 'Quebradillas')
665
+        break;
625 666
 
626 667
       case 59:
627 668
         query = query.where('city', '==', 'Rincón')
669
+        break;
628 670
 
629 671
       case 60:
630 672
         query = query.where('city', '==', 'Río Grande')
673
+        break;
631 674
 
632 675
       case 61:
633 676
         query = query.where('city', '==', 'Sabana Grande')
677
+        break;
634 678
 
635 679
       case 62:
636 680
         query = query.where('city', '==', 'Salinas')
681
+        break;
637 682
 
638 683
       case 63:
639 684
         query = query.where('city', '==', 'San Germán')
685
+        break;
640 686
 
641 687
       case 64:
642 688
         query = query.where('city', '==', 'San Juan')
689
+        break;
690
+        
643 691
 
644 692
       case 65:
645 693
         query = query.where('city', '==', 'San Lorenzo')
694
+        break;
646 695
 
647 696
       case 66:
648 697
         query = query.where('city', '==', 'San Sebastián')
698
+        break;
649 699
 
650 700
       case 67:
651 701
         query = query.where('city', '==', 'Santa Isabel')
702
+        break;
652 703
 
653 704
       case 68:
654 705
         query = query.where('city', '==', 'Toa Alta')
706
+        break;
655 707
 
656 708
       case 69:
657 709
         query = query.where('city', '==', 'Toa Baja')
710
+        break;
658 711
 
659 712
       case 70:
660 713
         query = query.where('city', '==', 'Trujillo Alto')
714
+        break;
661 715
 
662 716
       case 71:
663 717
         query = query.where('city', '==', 'Utuado')
718
+        break;
664 719
 
665 720
       case 72:
666 721
         query = query.where('city', '==', 'Vega Alta')
722
+        break;
667 723
 
668 724
       case 73:
669 725
         query = query.where('city', '==', 'Vega Baja')
726
+        break;
670 727
 
671 728
       case 74:
672 729
         query = query.where('city', '==', 'Vieques')
730
+        break;
673 731
 
674 732
       case 75:
675 733
         query = query.where('city', '==', 'Villalba')
734
+        break;
676 735
 
677 736
       case 76:
678 737
         query = query.where('city', '==', 'Yabucoa')
738
+        break;
679 739
 
680 740
       case 77:
681 741
         query = query.where('city', '==', 'Yauco')
742
+        break;
682 743
 
683
-      break;
744
+      default:
684 745
 
685 746
     }
686 747
 
687
-
688
-  }
689
-
690 748
   
691 749
     query.get().then(querySnapshot => {
692 750
       console.log('Total users: ', querySnapshot.size);