phase-10: add backoffice sandbox with mock business domain management

This commit is contained in:
sdarbinyan
2026-07-03 01:41:37 +04:00
parent af743a3c9f
commit e927a53029
3 changed files with 130 additions and 0 deletions

View 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);
}
});
}
}