99import { ActivatedRoute , Router } from '@angular/router' ;
1010import { PageHeaderComponent } from '../../../design-system/page-header/page-header' ;
1111import { InputComponent } from '../../../design-system/input/input' ;
12- import { SelectComponent , SelectOption } from '../../../design-system/select/select' ;
12+ import { SelectComponent } from '../../../design-system/select/select' ;
1313import { ButtonComponent } from '../../../design-system/button/button' ;
1414import { ConfirmDialogComponent } from '../../../design-system/dialog/confirm-dialog' ;
1515import { AppIconComponent } from '../../../design-system/icon/app-icon' ;
@@ -29,6 +29,11 @@ import { debounceTime, distinctUntilChanged, Subject, switchMap } from 'rxjs';
2929import { GeneralOptionQuery } from '../../../core/models/generals/general-option-query.model' ;
3030import { ManufacturerOption } from '../../../core/models/manufactureres/manufaturer-options.model' ;
3131import { StatusService } from '../../../core/services/status-service' ;
32+ import {
33+ StatusOption ,
34+ StatusOptionsResponse ,
35+ } from '../../../core/models/status/status-options.model' ;
36+ import { DSelectOption } from '../../../core/models/design-system/select-option.model' ;
3237
3338export type ProductFormMode = 'create' | 'edit' | 'view' | 'duplicate' ;
3439export type FormTab =
@@ -176,21 +181,21 @@ export class ProductFormComponent implements OnInit {
176181 readonly productNotes = signal < ProductNoteItem [ ] > ( [ ] ) ;
177182
178183 readonly categoryLoading = signal ( false ) ;
179- readonly categoryQuery = signal ( '' ) ;
184+ readonly manufacturerLoading = signal ( false ) ;
185+
186+ readonly fetchedStatuses = signal < StatusOption [ ] > ( [ ] ) ;
180187 readonly fetchedCategories = signal < CategoryOption [ ] > ( [ ] ) ;
181188 readonly fetchedManufacturers = signal < ManufacturerOption [ ] > ( [ ] ) ;
182189
183- readonly manufacturerLoading = signal ( false ) ;
190+ readonly statusQuery = signal ( '' ) ;
191+ readonly categoryQuery = signal ( '' ) ;
184192 readonly manufacturerQuery = signal ( '' ) ;
185- // readonly manufacturerQuery = signal<GeneralOptionQuery>({
186- // active: null,
187- // search: '',
188- // limit: 10,
189- // });
190193
191194 private readonly categorySearch$ = new Subject < GeneralOptionQuery > ( ) ;
192195 private readonly manufacturerSearch$ = new Subject < GeneralOptionQuery > ( ) ;
193196
197+ private currentModule = signal < string > ( 'PRODUCT' ) ;
198+
194199 readonly product = signal < ProductResponse > ( {
195200 id : 'p0000000-0002-0000-0000-000000000002' ,
196201 status : {
@@ -266,10 +271,10 @@ export class ProductFormComponent implements OnInit {
266271 } ) ;
267272
268273 readonly manufacturerOptions = computed < AutocompleteOption [ ] > ( ( ) => {
269- const manufacturers = this . fetchedManufacturers ( ) ;
274+ const status = this . fetchedStatuses ( ) ;
270275 const query = this . manufacturerQuery ( ) . trim ( ) . toLowerCase ( ) || '' ;
271276
272- return manufacturers
277+ return status
273278 . filter ( ( m ) => ! query || m . label . toLowerCase ( ) . includes ( query ) )
274279 . map ( ( m ) => ( {
275280 label : m . label ,
@@ -278,14 +283,16 @@ export class ProductFormComponent implements OnInit {
278283 } ) ) ;
279284 } ) ;
280285
281- readonly partOriginOptions : SelectOption [ ] = [
286+ readonly statusOptions = signal < DSelectOption [ ] > ( [ ] ) ;
287+
288+ readonly partOriginOptions : DSelectOption [ ] = [
282289 { label : 'Nacional' , value : 'po-01' } ,
283290 { label : 'Importado Direto' , value : 'po-02' } ,
284291 { label : 'Original OEM' , value : 'po-03' } ,
285292 { label : 'Aftermarket Premium' , value : 'po-04' } ,
286293 ] ;
287294
288- readonly unitOptions : SelectOption [ ] = [
295+ readonly unitOptions : DSelectOption [ ] = [
289296 { label : 'Jogo' , value : 'jogo' } ,
290297 { label : 'Peça' , value : 'peça' } ,
291298 { label : 'Par' , value : 'par' } ,
@@ -297,13 +304,7 @@ export class ProductFormComponent implements OnInit {
297304 { label : 'Conjunto' , value : 'conjunto' } ,
298305 ] ;
299306
300- readonly statusOptions : SelectOption [ ] = [
301- { label : 'Ativo' , value : 'st-01' } ,
302- { label : 'Inativo' , value : 'st-02' } ,
303- { label : 'Em Homologação' , value : 'st-03' } ,
304- ] ;
305-
306- readonly warehouseOptions : SelectOption [ ] = [
307+ readonly warehouseOptions : DSelectOption [ ] = [
307308 { label : 'Depósito Central SP' , value : 'wh-01' } ,
308309 { label : 'Depósito Filial PR' , value : 'wh-02' } ,
309310 { label : 'Depósito Distribuição RJ' , value : 'wh-03' } ,
@@ -384,9 +385,9 @@ export class ProductFormComponent implements OnInit {
384385 } ,
385386 } ) ;
386387
388+ this . onStatusSearch ( ) ;
387389 this . onCategorySearch ( this . queries ( ) ) ;
388390 this . onManufacturerSearch ( this . queries ( ) ) ;
389- this . getStatus ( ) ;
390391
391392 if ( id ) {
392393 this . productById ( id ) ;
@@ -1068,10 +1069,15 @@ export class ProductFormComponent implements OnInit {
10681069 this . manufacturerSearch$ . next ( query ) ;
10691070 }
10701071
1071- getStatus ( ) {
1072- this . statusService . getAll ( ) . subscribe ( {
1072+ onStatusSearch ( limit = null ) {
1073+ this . statusService . getOptions ( this . currentModule ( ) , limit ) . subscribe ( {
10731074 next : ( response ) => {
1074- console . log ( 'Fetched Product Status Options:' , response . data ) ;
1075+ const result = response . data . map ( ( status ) => ( {
1076+ label : status . label ,
1077+ value : status . id ,
1078+ description : status . description ,
1079+ } ) ) ;
1080+ this . statusOptions . set ( result ) ;
10751081 } ,
10761082 error : ( error ) => {
10771083 console . error ( 'Error fetching product status options:' , error ) ;
0 commit comments