import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { ConfirmBoxEvokeService } from '@costlydeveloper/ngx-awesome-popup'; import { UserService } from 'app/core/user/user.service'; import { BusinessCategory, TesoBusinessDetail } from 'app/models/businessModel'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { ProfileService } from '../Profile/profile.service'; @Component({ selector: 'app-temp-shop', templateUrl: './temp-shop.component.html', styleUrls: ['./temp-shop.component.scss'] }) export class TempShopComponent implements OnInit { businessCategories: BusinessCategory[] = []; selectedCategory: BusinessCategory; newBusiness: TesoBusinessDetail = { businessId: "", Handle: "", businessName: "", businessEmail: "", businessTin: "", businessDescription: "", businessCategory: "", businessAddress: "", businessContact: "", businessLogo: "", dateOfEst: new Date(), businessDigitalAddress: "", businessLatitude: "", businessLongitude: "", }; private _unsubscribeAll: Subject = new Subject(); constructor(public dialogRef: MatDialogRef, private _profileService: ProfileService, private confirmBoxEvokeService: ConfirmBoxEvokeService, private _userService: UserService) { } ngOnInit(): void { this._profileService.categories$.pipe(takeUntil(this._unsubscribeAll)).subscribe((d) => { this.businessCategories = d; }); } closeDialog() { if (this.newBusiness.businessName != '' && this.newBusiness.businessContact != '' && this.newBusiness.businessDigitalAddress) { this.confirmBoxEvokeService.info("Confirm Action", `Are you sure you would to add this business as a target for yor coupon ?`, "YES", "NO").subscribe(response => { if (response.clickedButtonID == "yes") { this.dialogRef.close(this.newBusiness); } }); }else{ this.confirmBoxEvokeService.info("Action Required", `To continue you should have the Business Name, Business Telephone and the digital address of the busines entered `, "OK") .subscribe(response => { }); } } }