Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@ export const routes: Routes = [
{
path: 'catalog/products/new',
loadComponent: () =>
import('./features/catalog/product-create/product-create').then((m) => m.ProductCreateComponent),
import('./features/catalog/products/product-create/product-create').then(
(m) => m.ProductCreateComponent,
),
},
{
path: 'catalog/products/:id/edit',
loadComponent: () =>
import('./features/catalog/product-workspace/product-workspace').then(
import('./features/catalog/products/product-workspace/product-workspace').then(
(m) => m.ProductWorkspaceComponent,
),
},
{
path: 'catalog/products/:id/view',
loadComponent: () =>
import('./features/catalog/product-workspace/product-workspace').then(
import('./features/catalog/products/product-workspace/product-workspace').then(
(m) => m.ProductWorkspaceComponent,
),
},
{
path: 'catalog/products/:id',
loadComponent: () =>
import('./features/catalog/product-workspace/product-workspace').then(
import('./features/catalog/products/product-workspace/product-workspace').then(
(m) => m.ProductWorkspaceComponent,
),
},
Expand Down
13 changes: 11 additions & 2 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { afterNextRender, ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { AppShellComponent } from './components/app-shell/app-shell';
import { AppInitializerService } from './core/initialization/app-initializer.service';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -9,4 +10,12 @@ import { AppShellComponent } from './components/app-shell/app-shell';
templateUrl: './app.html',
styleUrl: './app.css',
})
export class App {}
export class App {
private readonly initializer = inject(AppInitializerService);

constructor() {
afterNextRender(() => {
void this.initializer.initialize();
});
}
}
33 changes: 33 additions & 0 deletions src/app/core/initialization/app-initializer.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { inject, Injectable } from '@angular/core';
import { CategoryStore } from '../store/category-store/category-store';
import { ManufacturerStore } from '../store/manufacturer-store/manufacturer-store';
import { OemCodeStore } from '../store/oem-code-store/oem-code-store';
import { StatusStore } from '../store/status-store/status-store';
import { UnitSaleStore } from '../store/unit-sale/unit-sale-store';
import { WarehouseStore } from '../store/warehouse/warehouse-store';
import { PartOriginStore } from '../store/part-origin/part-origin-store';

@Injectable({
providedIn: 'root',
})
export class AppInitializerService {
private readonly statusStore = inject(StatusStore);
private readonly oemCodeStore = inject(OemCodeStore);
private readonly categoryStore = inject(CategoryStore);
private readonly unitSaleStore = inject(UnitSaleStore);
private readonly warehouseStore = inject(WarehouseStore);
private readonly partOriginStore = inject(PartOriginStore);
private readonly manufacturerStore = inject(ManufacturerStore);

async initialize(): Promise<void> {
await Promise.all([
this.oemCodeStore.loadInitial(),
this.statusStore.hydrate(),
this.unitSaleStore.hydrate(),
this.categoryStore.hydrate(),
this.warehouseStore.hydrate(),
this.partOriginStore.hydrate(),
this.manufacturerStore.hydrate(),
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ProductAdditionalCodeSummary {
id: string;
code: string;
active: boolean;
type: string; // remover possivelmente
}
12 changes: 3 additions & 9 deletions src/app/core/models/catetories/category-options.model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
export interface CategoryOptionsResponse {
success: boolean;
message: string;
data: CategoryOption[];
}
import { GeneralOption } from '../generals/general-options-response.model';

export interface CategoryOption {
id: string;
label: string;
description: string;
export interface CategoryOption extends GeneralOption {
icon: string;
description: string;
}
8 changes: 8 additions & 0 deletions src/app/core/models/catetories/category-query-cache.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AutocompleteOption } from '../design-system/auto-complete.model';
import { getAllResponse } from '../generals/general-responses-list.model';
import { GeneralOptionQuery } from '../generals/general-option-query.model';

export interface CategoryQueryCache {
query: GeneralOptionQuery;
response: getAllResponse<AutocompleteOption[]>;
}
7 changes: 7 additions & 0 deletions src/app/core/models/design-system/auto-complete.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { GeneralOption } from '../generals/general-options-response.model';

export interface AutocompleteOption extends GeneralOption {
icon: string;
disabled: boolean;
description: string;
}
8 changes: 4 additions & 4 deletions src/app/core/models/design-system/select-option.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface DSelectOption {
label: string;
value: string | number;
disabled?: boolean;
import { GeneralOption } from '../generals/general-options-response.model';

export interface SelectOption extends GeneralOption {
disabled: boolean;
}
9 changes: 9 additions & 0 deletions src/app/core/models/equivalent/equivalent-products.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EntityReference } from '../generals/entity-reference';

export interface ProductEquivalent {
id: string;
observation: string | null;
product: EntityReference;
equivalent_product: EntityReference;
status?: boolean; // remover após produtos equivalentes
}
6 changes: 6 additions & 0 deletions src/app/core/models/generals/entity-reference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface EntityReference {
id: string;
name: string;
slug?: string;
icon?: string;
}
4 changes: 3 additions & 1 deletion src/app/core/models/generals/general-option-query.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export interface GeneralOptionQuery {
search: string | null;
active: boolean | null;
limit: number | null;
per_page: number | null;
page: number | null;
manufacturer_id: string | null;
}

// ALTERNATIVA PRA PAGINAÇÃO
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface GeneralOption {
value: string;
label: string;
sublabel: string;
}
8 changes: 8 additions & 0 deletions src/app/core/models/generals/table-inventory.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface TableHeaderOption {
key: string;
label: string;
align?: 'left' | 'center' | 'right';
minWidth?: string;
width?: string;
showInReadOnly?: boolean;
}
11 changes: 11 additions & 0 deletions src/app/core/models/indexed-db/indexed-db.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface CacheEntry<T> {
data: T;
cachedAt: number;
expiresAt: number;
version: number;
}

export interface CacheChangedEvent {
type: 'updated' | 'removed';
key: string;
}
15 changes: 15 additions & 0 deletions src/app/core/models/inventories/inventories-product.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface ProductInventory {
id: string;
quantity: number;
reserved_quantity: number;
available_quantity?: number;
minimum_quantity: number;
maximum_quantity: number;
allow_backorder: boolean;
active: boolean;
warehouse: {
id: string;
name: string;
code: string | null;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getAllResponse } from '../generals/general-responses-list.model';
import { GeneralOptionQuery } from '../generals/general-option-query.model';
import { AutocompleteOption } from '../design-system/auto-complete.model';

export interface ManufacturerQueryCache {
query: GeneralOptionQuery;
response: getAllResponse<AutocompleteOption[]>;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export interface ManufacturerOptionsResponse {
success: boolean;
message: string;
data: ManufacturerOption[];
}

export interface ManufacturerOption {
id: string;
label: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ManufacturerSummaryResponse {
id: string;
name: string;
slug: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ManufacturerOptionsQuery {
search: string | null;
page: number | null;
per_page: number | null;
manufacturer_id: string | null;
}
12 changes: 12 additions & 0 deletions src/app/core/models/notes/notes.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface ProductNote {
id: string;
note: string;
type: string;
active: boolean;
description: string;
date: string;
author: string;
status: string;
created_at: string;
updated_at: string;
}
8 changes: 8 additions & 0 deletions src/app/core/models/oem-codes/oem-codes-product.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EntityReference } from '../generals/entity-reference';

export interface ProductOemCode {
id: string;
oem_code: string;
manufacturer: EntityReference;
product: EntityReference;
}
10 changes: 10 additions & 0 deletions src/app/core/models/oem-codes/oem-codes-query-cache.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// oem-code-query-cache.model.ts

import { GeneralOptionQuery } from '../generals/general-option-query.model';
import { PaginatedResponse } from '../pagination/pagination.model';
import { OemCode } from './oem-codes.model';

export interface OemCodeQueryCache {
query: GeneralOptionQuery;
response: PaginatedResponse<OemCode>;
}
9 changes: 9 additions & 0 deletions src/app/core/models/oem-codes/oem-codes.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ManufacturerSummaryResponse } from '../manufactureres/manufaturer-summary-response.model';

export interface OemCode {
id: string;
oem_code: string;
manufacturer: ManufacturerSummaryResponse;
created_at: string;
updated_at: string;
}
9 changes: 9 additions & 0 deletions src/app/core/models/part-origin/part-origin-product.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface ProductPartOrigin {
id: string;
name: string;
description: string | null;
display_order: number;
active: boolean;
created_at: string;
updated_at: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SelectOption } from '../design-system/select-option.model';
import { GeneralOptionQuery } from '../generals/general-option-query.model';
import { getAllResponse } from '../generals/general-responses-list.model';

export interface PartOriginQueryCache {
query: GeneralOptionQuery;
response: getAllResponse<SelectOption[]>;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export interface PartOriginResponse {
id: string;
name: string;
abbreviation: string;
active: boolean;
description: string;
display_order: number;
active: boolean;
}
9 changes: 9 additions & 0 deletions src/app/core/models/pricing/pricing-product-model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface ProductPricing {
regular_price: number;
promotional_price: number | null;
current_price: number;
is_on_promotion: boolean;
promotion_start: string | null;
promotion_end: string | null;
active: boolean;
}
15 changes: 7 additions & 8 deletions src/app/core/models/products/product-create.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AutocompleteOption } from '../../../design-system/autocomplete-select/autocomplete-select';
import { DSelectOption } from '../design-system/select-option.model';
import { AutocompleteOption } from '../design-system/auto-complete.model';
import { SelectOption } from '../design-system/select-option.model';

/** Estado interno do formulário de criação (campos do POST) */
export interface ProductCreateFormState {
Expand Down Expand Up @@ -87,14 +87,12 @@ export interface ProductGeneralFormData {
}

export interface ProductGeneralFormOptions {
unitOptions: SelectOption[];
statusOptions: SelectOption[];
warehouseOptions: SelectOption[];
partOriginOptions: SelectOption[];
categoryOptions: AutocompleteOption[];
categoryLoading: boolean;
manufacturerOptions: AutocompleteOption[];
manufacturerLoading: boolean;
partOriginOptions: DSelectOption[];
unitOptions: DSelectOption[];
statusOptions: DSelectOption[];
warehouseOptions: DSelectOption[];
}

export interface ProductGeneralFormSource {
Expand Down Expand Up @@ -140,6 +138,7 @@ export function toProductGeneralFormData(source: ProductGeneralFormSource): Prod
}

export function toCreateProductPayload(source: ProductGeneralFormSource): CreateProductPayload {
console.log('[CHEGAMOS AQUI PAYLOAD]', source);
return {
category_id: source.category_id,
manufacturer_id: source.manufacturer_id,
Expand Down
Loading