new voucher system
This commit is contained in:
@@ -8,30 +8,29 @@ import { QuotaService } from './../../../services/quota.service';
|
||||
@Component({
|
||||
selector: 'app-account-voucher',
|
||||
templateUrl: './voucher.component.html',
|
||||
styleUrls: ['./voucher.component.scss']
|
||||
styleUrls: [ './voucher.component.scss' ]
|
||||
})
|
||||
export class VoucherComponent implements OnInit {
|
||||
|
||||
public hasRegistration: boolean = false;
|
||||
model: any = {};
|
||||
available = [];
|
||||
vouchers = [];
|
||||
voucherSource = new MatTableDataSource<any>();
|
||||
voucherColumns = ['type', 'code'];
|
||||
voucherColumns = [ 'type', 'code' ];
|
||||
|
||||
constructor(private voucherService: VoucherService, private quotaService: QuotaService, public dialog: MatDialog) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.voucherSource.data = this.vouchers;
|
||||
this.quotaService.quotas().subscribe((data: any) => {
|
||||
this.hasRegistration = data && data.some(function (quota) {
|
||||
return quota.name == "registration_vouchers" && quota.value > 0;
|
||||
})
|
||||
this.voucherService.get().subscribe((data: any) => {
|
||||
this.available = data;
|
||||
})
|
||||
}
|
||||
|
||||
registration() {
|
||||
this.voucherService.registration().toPromise().then(data => {
|
||||
this.model.type = "registration";
|
||||
create(name: string) {
|
||||
this.voucherService.create(name).toPromise().then(data => {
|
||||
this.model.type = name;
|
||||
this.model.code = data;
|
||||
this.vouchers.push(this.model);
|
||||
this.voucherSource.data = this.vouchers;
|
||||
@@ -45,28 +44,13 @@ export class VoucherComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
addon() {
|
||||
this.voucherService.addon().subscribe((data: any) => {
|
||||
this.model.type = "add-on";
|
||||
this.model.code = data;
|
||||
this.vouchers.push(this.model);
|
||||
this.voucherSource.data = this.vouchers;
|
||||
const dialogRef = this.dialog.open(VoucherDialog, {
|
||||
closeOnNavigation: false,
|
||||
disableClose: true,
|
||||
data: this.model
|
||||
});
|
||||
}, error => {
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-voucher-dialog',
|
||||
templateUrl: 'voucher.dialog.html',
|
||||
styleUrls: ['./voucher.dialog.scss']
|
||||
styleUrls: [ './voucher.dialog.scss' ]
|
||||
})
|
||||
export class VoucherDialog {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user