@@ -15,6 +15,8 @@ import { ConfirmDialogComponent } from '../../../design-system/dialog/confirm-di
1515import { AppIconComponent } from '../../../design-system/icon/app-icon' ;
1616import { ToastService } from '../../../core/services/toast' ;
1717import { ShellStateService } from '../../../core/services/shell-state' ;
18+ import { ProductService } from '../../../core/services/product-service' ;
19+ import { ProductResponse } from '../../../core/models/products/product-response.model' ;
1820
1921export type ProductFormMode = 'create' | 'edit' | 'view' | 'duplicate' ;
2022export type FormTab = 'geral' | 'comercial' | 'compatibilidade' | 'midia' | 'administracao' ;
@@ -95,6 +97,7 @@ export class ProductFormComponent implements OnInit {
9597 readonly shellState = inject ( ShellStateService ) ;
9698 private route = inject ( ActivatedRoute ) ;
9799 private router = inject ( Router ) ;
100+ private productService = inject ( ProductService ) ;
98101 private toastService = inject ( ToastService ) ;
99102
100103 readonly mode = signal < ProductFormMode > ( 'create' ) ;
@@ -146,6 +149,66 @@ export class ProductFormComponent implements OnInit {
146149 readonly selectedTagIds = signal < string [ ] > ( [ ] ) ;
147150 readonly productNotes = signal < ProductNoteItem [ ] > ( [ ] ) ;
148151
152+ readonly product = signal < ProductResponse > ( {
153+ id : 'p0000000-0002-0000-0000-000000000002' ,
154+ status : {
155+ id : 's0000000-0001-0000-0000-000000000001' ,
156+ module : 'PRODUCT' ,
157+ code : 'DRAFT' ,
158+ name : 'Rascunho' ,
159+ color : '#64748B' ,
160+ icon : 'file-text' ,
161+ } ,
162+ category : {
163+ id : 'c0000000-0013-0000-0000-000000000013' ,
164+ name : 'Filtros de Óleo' ,
165+ slug : 'filtros-de-oleo' ,
166+ } ,
167+ manufacturer : {
168+ id : 'm0000000-0001-0000-0000-000000000001' ,
169+ name : 'Bosch' ,
170+ slug : 'bosch' ,
171+ } ,
172+ internal_code : 'OF-002' ,
173+ name : 'Filtro de Óleo Bosch OF-002' ,
174+ slug : 'filtro-de-oleo-bosch-of-002' ,
175+ icon : null ,
176+ image : null ,
177+ short_description : 'Filtro de óleo paralelo Bosch' ,
178+ description : 'Filtro de óleo paralelo de alta qualidade para linha VW/Fiat 1.0 e 1.6.' ,
179+ weight : '0.300' ,
180+ height : '10.00' ,
181+ width : '8.00' ,
182+ length : '8.00' ,
183+ featured : false ,
184+ active : 0 ,
185+ is_sellable : false ,
186+ commercial_status : 'ready' ,
187+ pricing : {
188+ regular_price : 35.9 ,
189+ promotional_price : 29.9 ,
190+ current_price : 29.9 ,
191+ is_on_promotion : true ,
192+ promotion_start : '2026-07-01' ,
193+ promotion_end : '2026-12-31' ,
194+ active : true ,
195+ display : {
196+ from : 35.9 ,
197+ to : 29.9 ,
198+ label : 'de R$ 35,90 por R$ 29,90' ,
199+ } ,
200+ } ,
201+ inventory : {
202+ quantity : 50 ,
203+ reserved_quantity : 0 ,
204+ available_quantity : 50 ,
205+ minimum_quantity : 5 ,
206+ maximum_quantity : 300 ,
207+ allow_backorder : true ,
208+ active : true ,
209+ } ,
210+ } ) ;
211+
149212 // Static Dropdown Options
150213 readonly categoryOptions : SelectOption [ ] = [
151214 { label : 'Sistemas de Freios' , value : 'cat-01' } ,
@@ -229,20 +292,39 @@ export class ProductFormComponent implements OnInit {
229292 const url = this . router . url ;
230293 const id = this . route . snapshot . paramMap . get ( 'id' ) ;
231294
295+ if ( id ) {
296+ this . productById ( id ) ;
297+ }
298+
299+ console . log ( '[URL CHEGANDO AQUI]' , url ) ;
300+
232301 if ( url . includes ( '/new' ) ) {
233302 this . mode . set ( 'create' ) ;
234- } else if ( url . includes ( '/edit' ) ) {
235- this . mode . set ( 'edit' ) ;
236- this . loadMockProduct ( id ) ;
237- } else if ( url . includes ( '/view' ) || ( id && ! url . includes ( '/duplicate' ) ) ) {
238- this . mode . set ( 'view' ) ;
239- this . loadMockProduct ( id ) ;
240- } else if ( url . includes ( '/duplicate' ) ) {
241- this . mode . set ( 'duplicate' ) ;
242- this . loadMockProduct ( id ) ;
243- // Backend mandate rule for duplicate: clean internal_code automatically
244- this . formInternalCode . set ( '' ) ;
245303 }
304+ // else if (url.includes('/edit')) {
305+ // this.mode.set('edit');
306+ // this.loadMockProduct(id);
307+ // } else if (url.includes('/view') || (id && !url.includes('/duplicate'))) {
308+ // this.mode.set('view');
309+ // this.loadMockProduct(id);
310+ // } else if (url.includes('/duplicate')) {
311+ // this.mode.set('duplicate');
312+ // this.loadMockProduct(id);
313+ // // Backend mandate rule for duplicate: clean internal_code automatically
314+ // this.formInternalCode.set('');
315+ // }
316+ }
317+
318+ productById ( productId : string ) {
319+ this . productService . getById ( productId ) . subscribe ( {
320+ next : ( response ) => {
321+ console . log ( response ) ;
322+ // this.product = response;
323+ } ,
324+ error : ( error ) => {
325+ console . log ( error ) ;
326+ } ,
327+ } ) ;
246328 }
247329
248330 loadMockProduct ( id : string | null ) : void {
0 commit comments