diff --git a/src/app/pages/account/voucher/voucher.component.html b/src/app/pages/account/voucher/voucher.component.html
index 5cf515a..a801fee 100644
--- a/src/app/pages/account/voucher/voucher.component.html
+++ b/src/app/pages/account/voucher/voucher.component.html
@@ -3,11 +3,8 @@
{{'vouchers.info' | i18n}}
-
-
diff --git a/src/app/pages/account/voucher/voucher.component.ts b/src/app/pages/account/voucher/voucher.component.ts
index db62b5f..b3207ee 100644
--- a/src/app/pages/account/voucher/voucher.component.ts
+++ b/src/app/pages/account/voucher/voucher.component.ts
@@ -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();
- 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 {
diff --git a/src/app/services/voucher.service.ts b/src/app/services/voucher.service.ts
index 27105de..e6be6e8 100644
--- a/src/app/services/voucher.service.ts
+++ b/src/app/services/voucher.service.ts
@@ -11,11 +11,11 @@ export class VoucherService {
constructor(private http: HttpClient) {
}
- registration() {
- return this.http.post(environment.apiUrl + "/vouchers/registration", {});
+ get() {
+ return this.http.get(environment.apiUrl + "/vouchers");
}
- addon() {
- return this.http.post(environment.apiUrl + "/vouchers/addon", {});
+ create(name: string) {
+ return this.http.post(environment.apiUrl + "/vouchers/" + name, {});
}
}
\ No newline at end of file