32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { Component, inject } from '@angular/core';
|
|
import { SettingsBaseAddEdit } from '../settings-base-add-edit/settings-base-add-edit';
|
|
import { ProductFormGroup } from '../../pages/settings/products/product-formgroup';
|
|
import { ActionBtn } from '../action-btn/action-btn';
|
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
|
|
import { ProductSettings } from '../../services/product-settings';
|
|
import { Product } from '../../models/Product';
|
|
|
|
@Component({
|
|
selector: 'app-product-add',
|
|
imports: [ActionBtn, TranslatePipe, UpperfirstPipe],
|
|
templateUrl: './../settings-base-add-edit/settings-base-add-edit.html',
|
|
styleUrl: './../settings-base-add-edit/settings-base-add-edit.scss',
|
|
})
|
|
export class ProductAdd extends SettingsBaseAddEdit {
|
|
btnText = 'common.save';
|
|
title = 'settings.product.new_product';
|
|
readonly form = new ProductFormGroup();
|
|
|
|
private readonly productSettings = inject(ProductSettings);
|
|
|
|
async submit() {
|
|
const product = new Product(
|
|
this.form.controls.barcode.value,
|
|
this.form.controls.name.value,
|
|
'',
|
|
);
|
|
await this.productSettings.save(product, this.form.controls.image.value);
|
|
}
|
|
}
|