HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/pages/settings/settings.ts
import { DataPolicyService } from './../../services/data-policy.service';
import { AnalyticsService } from './../../services/analytics.service';
import { Component, OnInit } from "@angular/core";
import { TranslateService } from "@ngx-translate/core";
import { AlertController, Platform, NavController } from "@ionic/angular";
import { StorageService } from '../../services/storage.service';
import { Router } from "@angular/router";
import { UserService } from "../../services/user.service";
import { OrderService } from "../../services/order.service";
import { CityService } from "../../services/city.service";
import { CartService } from "../../services/cart.service";
import { ParameterService } from "../../services/parameter.service";
import { SectionService } from "../../services/section.service";
import { UtilsService } from "../../services/utils.service";
import { Browser } from '@capacitor/browser';
import { App } from '@capacitor/app';
import { Share } from '@capacitor/share';
import { Capacitor } from '@capacitor/core';
// import { FacebookLogin } from '@capacitor-community/facebook-login';

@Component({
  selector: "page-settings",
  templateUrl: "settings.html",
  styleUrls: ["./settings.scss"],
})
export class SettingsPage implements OnInit {
  messageText: any;
  versionApp: any;
  parameters: any;
  userInfo: any = {};
  dataSections: any = [];
  dataPolicyUrl;

  constructor(
    public userProvider: UserService,
    public alertCtrl: AlertController,
    private storage: StorageService,
    public translateService: TranslateService,
    public orderProvider: OrderService,
    public cityService: CityService,
    public cartProvider: CartService,
    public platform: Platform,
    private router: Router,
    public navCtrl: NavController,
    public parameterService: ParameterService,
    public sectionService: SectionService,
    public utilsService: UtilsService,
    private analyticsService: AnalyticsService,
    private dataPolicyService: DataPolicyService
  ) {
    this.translateService
      .get(["TITLE_LOGOUT", "TEXT_LOGOUT", "TEXT_SHARING_APP", "TITLE_SHARING_APP", "TITLE_VALIDATE_INVITED", "TEXT_VALIDATE_INVITED", "TITLE_COMPLETE_PROFILE", "TEXT_COMPLETE_PROFILE", "TITLE_DELETE_ACCOUNT", "TEXT_DELETE_ACCOUNT", "TITLE_CONFIRM_DELETE_ACCOUNT", "TEXT_CONFIRM_DELETE_ACCOUNT"])
      .subscribe((values) => {
        this.messageText = {
          titleLogout: values.TITLE_LOGOUT,
          textLogout: values.TEXT_LOGOUT,
          sharingApp: values.TEXT_SHARING_APP,
          titleSharingApp: values.TITLE_SHARING_APP,
          titleValidateInvited: values.TITLE_VALIDATE_INVITED,
          textValidateInvited: values.TEXT_VALIDATE_INVITED,
          titleCompleteProfle: values.TITLE_COMPLETE_PROFILE,
          textCompleteProfle: values.TEXT_COMPLETE_PROFILE,
          titleDeleteAccount: values.TITLE_DELETE_ACCOUNT,
          textDeleteAccount: values.TEXT_DELETE_ACCOUNT,
          titleConfimDeleteAccount: values.TITLE_CONFIRM_DELETE_ACCOUNT,
          textConfimDeleteAccount: values.TEXT_CONFIRM_DELETE_ACCOUNT,
        };
      });
  }

  ngOnInit() {
    setTimeout(() => {
      this.userProvider.getInfoUser();
      this.getSections();
      this.getVersion();
      this.dataPolicyService.get().then((res: any) => {
        this.dataPolicyUrl = res.url;
      })
    }, 500);
  }

  async getVersion() {
    if (Capacitor.isNativePlatform()) {
      this.versionApp = (await App.getInfo()).version;
    }
  }

  ionViewDidEnter() {
    this.loadParametersLocal();
  }

  loadParametersLocal() {
    this.storage.get("parameters").then((p) => {
      this.parameters = p;
    });

    this.storage.get("infoUser").then((u) => {
      this.userInfo = u;
    });
  }

  ionViewWillEnter() { }

  goToEditProfileUser() {
    if (this.userProvider._infoUser.id == 2) {
      this.alertUserInvited();
    } else {
      this.storage.get("token").then((token) => {
        this.userProvider.getDocumentType(token.access_token, { showIn: 'adult' }).then((resp: any) => {
          if (resp["status"] == "success") {
            this.router.navigate(["/user-profile"]);
          }
        });
      });
    }
  }

  goToListAddress() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/address-list"]);
    }
  }

  goToStatistics() {
    this.router.navigate(["/app/tabs/settings/statistics"]);
  }

  goToCoins() {
    if (this.userProvider.validateAlertsUseApp('coins')) {
      this.router.navigate(["/app/tabs/settings/coins"]);
    }
  }

  goToTickets() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/tickets-list"]);
    }
  }

  goToSubscriberCard() {
    if (this.userProvider.validateAlertsUseApp('isSubscriber')) {
      this.router.navigate(["/app/tabs/settings/symbolic-ticket-list"]);
    }
  }

  goToUserOrders() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/user-orders"]);
    }
  }

  goToDorsal() {
    this.router.navigate(["/app/tabs/settings/dorsal"]);
  }

  goToBookcase() {
    this.router.navigate(["/app/tabs/bookcase"]);
  }

  goToVideo() {
    this.router.navigate(["/app/tabs/settings/tv"]);
  }

  goToSocial() {
    this.router.navigate(["/app/tabs/settings/social"]);
  }

  goToRadio() {
    this.router.navigate(["/app/tabs/settings/radio"]);
  }

  goToPlayers() {
    this.router.navigate(["/player"]);
  }

  async buyTickets() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.parameterService.getParameters('activate_flash_ticketing').then((resp: any) => {
        this.parameters = resp.parameters;
        let route = this.parameters && !this.parameters.activate_flash_ticketing ? '/tickets' : '/flash-tickets';
        this.router.navigate([route]);
      });
    }
  }

  goToSuggestionsMailbox() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/suggestions-mailbox"]);
    }
  }

  goToMessages() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/messages"]);
    }
  }

  goToTutorial() {
    this.router.navigate(["/tutorial/settings"]);
  }

  goToListCards() {
    this.router.navigate(["/app/tabs/settings/cards"]);
  }

  goToPolls() {
    this.router.navigate(["/app/tabs/settings/polls-list"]);
  }

  goToTour() {
    let link = "https://my.matterport.com/show/?m=R9qj13J1wPM";
    this.utilsService.openLink(link);
  }

  goToTourPatprimo() {
    let link = "https://www.patprimo.com/tienda-virtual";
    this.utilsService.openLink(link);
  }

  goToReferFriends() {
    this.router.navigate(["/app/tabs/settings/referrals"]);
  }

  goToWallet() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/app/tabs/settings/wallet"]);
    }
  }

  goToAlbum() {
    this.router.navigate(["/app/tabs/settings/album"]);
  }

  goToAcademy() {
    if (this.userProvider.validateAlertsUseApp(/*'comingSoon'*/)) {
      this.router.navigate(["/app/tabs/settings/academy"]);
    }
  }

  goToBusinessDirectory() {
    if (this.userProvider.validateAlertsUseApp(/*'comingSoon'*/)) {
      this.router.navigate(["/business-directory"]);
    }
  }

  goToSubscriber() {
    if (this.userProvider.validateAlertsUseApp(/*'comingSoon'*/)) {     // REMOVER comingSoon SI YA ESTA ACTIVO LA VENTA DE BOLETERÍA
      this.parameterService.getParameters('activate_flash_ticketing').then((resp: any) => {
        this.parameters = resp.parameters;
        let route = this.parameters && !this.parameters.activate_flash_ticketing ? '/tickets' : '/flash-tickets';
        this.router.navigate([route]);
      });
      // this.router.navigate(["/app/tabs/settings/subscriber-tutorial"]);
    }
  }

  shareApp() {
    Share.share({
      text: this.messageText.sharingApp,
      url: this.cityService._urlAdmin + "/store/redirect"
    });
  }

  goAR() {
    this.userInfo;
    const name = `${this.userInfo.first_name} ${this.userInfo.last_name}`;
    const base64name = btoa(name);
    let link = `https://alq-cali.bikenow.co/ar/index.html?name=${base64name}`;
    this.utilsService.openLink(link);
  }

  openUrlPqr() {
    let link = this.parameters.url_pqrs;
    this.utilsService.openLink(link);
  }

  openTermsSI() {
    let link = this.parameters.terms.url;
    this.utilsService.openLink(link);
  }

  openDataPolicy() {
    let link = this.dataPolicyUrl;
    this.utilsService.openLink(link);
  }

  openWhatsapp() {
    if (this.parameters && this.parameters.whatsapp_support && this.parameters.whatsapp_support != "") {
      let editPhone = this.parameters.whatsapp_support;

      let message = this.translateService.instant("MESSAGE_WHATSAPP", {
        name: this.userInfo.first_name + " " + this.userInfo.last_name,
        document: this.userInfo.document ? this.userInfo.document : "N/A",
      });

      let textWhatsapp = "&text=" + message;
      let url = "https://api.whatsapp.com/send?phone=" + editPhone + textWhatsapp;

      Browser.open({ url: url });
    }
  }

  async goToFaq() {
    let baseUrl = (await this.cityService.getAdminUrl());
    let link = baseUrl + '/faq';
    this.utilsService.openLink(link);
  }

  async logout() {
    const confirm = await this.alertCtrl.create({
      header: this.messageText.titleLogout,
      message: this.messageText.textLogout,
      buttons: [
        {
          text: "No",
          handler: () => {
            console.log("Disagree clicked");
          },
        },
        {
          text: "Si",
          handler: () => {
            this.cartProvider.deleteAllProductsCart();
            this.storage.clear();
            this.navCtrl.navigateRoot("/city-connection");
          },
        },
      ],
    });

    await confirm.present();
  }

  async alertUserInvited() {
    const confirm = await this.alertCtrl.create({
      header: this.messageText.titleValidateInvited,
      message: this.messageText.textValidateInvited,
      buttons: [
        {
          text: "Cancelar",
          handler: () => {
            console.log("Disagree clicked");
          },
        },
        {
          text: "Registrarme",
          handler: () => {
            this.storage.remove("token");
            this.storage.remove("infoUser");
            this.navCtrl.navigateRoot("/city-connection");
          },
        },
      ],
    });

    await confirm.present();
  }

  async deleteAccount() {
    this.analyticsService.logEvent('Delete Account Click', this.utilsService.categorySettings);

    const confirm = await this.alertCtrl.create({
      header: this.messageText.titleDeleteAccount,
      message: this.messageText.textDeleteAccount,
      buttons: [
        {
          text: "No",
          handler: () => {
          },
        },
        {
          text: "Si",
          handler: () => {
            this.userProvider.deleteAccount(this.userProvider._infoUser.id)
              .then((resp: any) => {
                if (resp.r) {
                  this.confirmDeleteAccount();
                } else {
                  this.utilsService.presentAlertInfo("¡Alerta!", "", resp.m);
                }
              })
              .catch((error) => {
                console.log("error deleteAccount: ", error);
              });
          },
        },
      ],
    });
    await confirm.present();
  }

  async confirmDeleteAccount() {
    const confirm = await this.alertCtrl.create({
      header: this.messageText.titleConfimDeleteAccount,
      message: this.messageText.textConfimDeleteAccount,
      buttons: [
        {
          text: "Ok",
          handler: () => {
            this.cartProvider.deleteAllProductsCart();
            this.storage.clear();
            this.navCtrl.navigateRoot("/city-connection");
          },
        }
      ],
    });
    await confirm.present();
  }

  goToCardList() {
    if (this.userProvider.validateAlertsUseApp()) {
      this.router.navigate(["/user-cards"]);
    }
  }

  async getSections() {
    await this.sectionService.getSections().then((resp: any) => {
      this.dataSections = resp.data.sort((a: any, b: any) => b.chip_new - a.chip_new || a.button_order - b.button_order).filter(function (item: any) { return item.enable_on_settings });
    });
  }

  goToSection(sectionName: string, url: string, link: any = null) {
    let section: any = this.dataSections.find(function (item: any) { return item.name == sectionName; });
    if (section) {
      this.analyticsService.logEvent(sectionName + ' Click', this.utilsService.categorySettings);

      if (section.validate_data_type && !this.userProvider.validateAlertsUseApp(section.validate_data_type)) {
        return;
      }
      if (!link) {
        this.router.navigate([url]);
      } else {
        this.utilsService.openLink(link);
      }
    }
  }
}