Newer
Older
CamaraComercioWeb / src / app / modules / public / discover / discover.component.ts
Fabian VC on 23 Oct 2021 1 KB [fix] styles modal
import { SITES } from './../../../core/mocks/data';
import { Ffilter } from './../../../core/interfaces/utils/forms/filters';
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { faBorderAll } from '@fortawesome/free-solid-svg-icons';
import { Site } from 'src/app/core/interfaces/site/site';
import { ActivatedRoute } from '@angular/router'

@Component({
  templateUrl: './discover.component.html',
  styleUrls: ['./discover.component.scss']
})
export class DiscoverComponent implements OnInit, AfterViewInit {

  @ViewChild('modalSiteComponent') modal: any;

  openModal = false;
  icon_border_all = faBorderAll;
  allyId: number = -1;
  sites: Site[] = SITES;
  search: string = '';
  form: Ffilter = {
    search: '',
    lat: 7.376362792514798,
    lng: -72.65115193327162,
    location: '',
    category: '',
    zoom: 2,
  }

  constructor(private title: Title, private activeRoute: ActivatedRoute) { }

  ngOnInit(): void {
    this.setTitle("Discover | Camara de comercio");
    this.getQueryParams();
  }

  ngAfterViewInit() {

  }

  public setTitle(newTitle: string) {
    this.title.setTitle(newTitle);
  }

  public getQueryParams(){
    this.activeRoute.queryParams.subscribe(
      (data) => {
        if(data.search){
          this.form.search = data.search;
        }
      }
    )
  }

  handlePatternSearch($event: any) {
    this.form.search = $event;
  }

  handlePatternAllyId($event: any) {
    console.log(this.modal as HTMLElement);
    const siteId = $event;

    const site = this.sites.filter((site) => site.id == siteId)[0]
    this.modal.ally = site;
    console.log($event);
    // this.modal.ally = ""
    /* this.modal.switchModal(); */
  }

}