-
Notifications
You must be signed in to change notification settings - Fork 490
/
product-mutation.component.ts
43 lines (36 loc) · 1.21 KB
/
product-mutation.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Component } from '@angular/core';
import { TranslationBaseComponent } from '../language-base/translation-base.component';
import { TranslateService } from '@ngx-translate/core';
import { NbDialogRef } from '@nebular/theme';
import { Product } from '@gauzy/models';
import { FormGroup } from '@angular/forms';
import { ProductService } from '../../@core/services/product.service';
@Component({
selector: 'ngx-product-mutation',
templateUrl: './product-mutation.component.html',
styleUrls: ['./product-mutation.component.scss']
})
export class ProductMutationComponent extends TranslationBaseComponent {
form: FormGroup;
productItem: Product;
edit = 'product-variant';
constructor(
readonly translationService: TranslateService,
public dialogRef: NbDialogRef<ProductMutationComponent>,
private productService: ProductService
) {
super(translationService);
}
async onSaveProduct(productRequest: Product) {
let product: Product;
if (!productRequest.id) {
product = await this.productService.create(productRequest);
} else {
product = await this.productService.update(productRequest);
}
this.closeDialog(product);
}
async closeDialog(product?: Product) {
this.dialogRef.close(product);
}
}