feat(product): add crate and edit ops in settings

This commit is contained in:
2026-02-22 23:35:30 -03:00
parent f89a27320f
commit 82dd3c607a
30 changed files with 668 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProductAdd } from './product-add';
import { ProductSettings } from '../../services/product-settings';
import { provideTranslateService } from '@ngx-translate/core';
describe('ProductAdd', () => {
let component: ProductAdd;
let fixture: ComponentFixture<ProductAdd>;
let productSettings: Partial<ProductSettings>;
beforeEach(async () => {
productSettings = {
save: vi.fn(),
};
await TestBed.configureTestingModule({
imports: [ProductAdd],
providers: [{ provide: ProductSettings, useValue: productSettings }, provideTranslateService()],
}).compileComponents();
fixture = TestBed.createComponent(ProductAdd);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,31 @@
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);
}
}