Teso Business 2.0 angular source code https://bacwaredev.barhendev.com/teso
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.3 KiB

import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ConfirmBoxEvokeService } from '@costlydeveloper/ngx-awesome-popup';
import { tesoMediaWatcherService } from '@teso/services/media-watcher';
import { CouponsType, CouponsModel } from 'app/models/couponsModel';
import { ProductsModel } from 'app/models/productsModel';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { ProductsService } from '../../Products/products.service';
import { CouponsService } from '../coupons.service';
import { NewCouponsComponent } from '../NewCoupons/new-coupons.component';
@Component({
selector: 'app-details-dialog',
templateUrl: './details-dialog.component.html',
styleUrls: ['./details-dialog.component.scss']
})
export class DetailsDialogComponent implements OnInit {
products: ProductsModel[] = [];
selectedProduct: ProductsModel = {
productName: '',
businessID: '',
productDesc: '',
productID: '',
categoryID: '',
unitPrice: 0,
productImage: '',
images: []
};
selectedType: any = {};
isLoading: boolean = false;
couponTypes: CouponsType[] = [];
fromWorth: number;
toWorth: number;
isScreenSmall: boolean;
newCoupon: CouponsModel = {
couponID: '',
businessID: '',
targetProduct: '',
type: '',
quantity: 0,
lower: 0,
condition: '',
upper: 0,
numberClaimed: 0,
status: '',
expiration: new Date(),
};
expiryDate: Date = new Date();
expiryTime: Date = new Date();
private _unsubscribeAll: Subject<any> = new Subject<any>();
constructor(
public dialog: MatDialog, private _productService: ProductsService,
private _couponService: CouponsService, private _tesoMediaWatcherService: tesoMediaWatcherService,
public dialogRef: MatDialogRef<DetailsDialogComponent>,@Inject(MAT_DIALOG_DATA) public data: { coupon: CouponsModel },
private confirmBoxEvokeService: ConfirmBoxEvokeService,) {
this.newCoupon = data.coupon;
this._productService.data$.pipe(takeUntil(this._unsubscribeAll)).subscribe((d) => {
this.products = d;
this.selectedProduct = this.products.find((p)=> p.productName == this.newCoupon.targetProduct);
});
console.log(this.newCoupon)
}
ngOnInit(): void {
}
}