phase-10: add backoffice sandbox with mock business domain management
This commit is contained in:
40
src/app/facades/backoffice/backoffice.facade.ts
Normal file
40
src/app/facades/backoffice/backoffice.facade.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ProductCardConfig, CategoryCardConfig } from '../../shared/models/ui';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BackofficeFacade {
|
||||
readonly products = signal<ProductCardConfig[]>([]);
|
||||
readonly categories = signal<CategoryCardConfig[]>([]);
|
||||
readonly loading = signal(false);
|
||||
|
||||
constructor(private readonly http: HttpClient) {}
|
||||
|
||||
load(): void {
|
||||
this.loading.set(true);
|
||||
|
||||
this.http.get<ProductCardConfig[]>('/assets/mock/bootstrap/products.json').subscribe({
|
||||
next: (products) => {
|
||||
this.products.set(products ?? []);
|
||||
this.loadCategories();
|
||||
},
|
||||
error: () => {
|
||||
this.products.set([]);
|
||||
this.loadCategories();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadCategories(): void {
|
||||
this.http.get<CategoryCardConfig[]>('/assets/mock/bootstrap/categories.json').subscribe({
|
||||
next: (categories) => {
|
||||
this.categories.set(categories ?? []);
|
||||
this.loading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.categories.set([]);
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user