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/wallet/wallet.page.ts
import { Component, OnInit } from '@angular/core';
import { StorageService } from '../../services/storage.service';
import { UtilsService } from "../../services/utils.service";
import { WalletService } from "../../services/wallet.service";
import { CityService } from "../../services/city.service";
import { TranslateService } from "@ngx-translate/core";
import { Clipboard } from '@capacitor/clipboard';

@Component({
  selector: 'app-wallet',
  templateUrl: './wallet.page.html',
  styleUrls: ['./wallet.page.scss'],
})
export class WalletPage implements OnInit {
  coupons: any;
  wallet = "coupons";
  emptySettingsSlide: any;
  codeCoupon: any;
  linkCoupon: any;
  isSubscriber: boolean = false;
  constructor(
    private storage: StorageService,
    private utilsService: UtilsService,
    public walletService: WalletService,
    public translateService: TranslateService,
    public cityProvider: CityService
  ) { }

  ngOnInit() {
    this.storage.get("infoUser").then((info) => {
      if (info && info.is_subscriber == 1)
        this.isSubscriber = true;
    });

    this.emptySettingsSlide = {
      showImage: false,
      urlImage: "",
      showText: true,
      text: this.translateService.instant("NOT_WALLET"),
    };

    this.getCoupons();
  }

  validateCoupon(item) {
    let show = true;
    if (item.isSubscriber && !this.isSubscriber) {
      show = false;
    }
    return show;
  }

  getCoupons() {
    this.storage.get("token").then(async (token) => {
      if (token) {
        (await this.walletService.getCoupons(token.access_token)).subscribe(
          (resp: any) => {
            if (!this.coupons) {
              this.coupons = [];
            }
            this.coupons.push(...resp);
          },
          (error) => {
            this.coupons = null;
            console.log("error getCoupons: ", error);
          }
        );
      }
    });
  }

  getCouponCode(codeCoupon) {
    Clipboard.write({
      string: codeCoupon
    });
    this.utilsService.presentToast(3000, "success", "top", this.translateService.instant("COPY_COUPON", {
      code: codeCoupon,
    }));
  }

  openTermsSI(link) {
    this.utilsService.openLink(link);
  }

  openLinkRedeem(link) {
    this.utilsService.openLink(link);
  }

}