arch(sprint1): decouple backoffice facade from http provider

This commit is contained in:
sdarbinyan
2026-07-03 02:01:01 +04:00
parent 95dbea7768
commit ac48799d9a
8 changed files with 75 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
import { Injectable, signal } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ProductCardConfig, CategoryCardConfig } from '../../shared/models/ui';
import { BackofficeDataService } from '../../core/backoffice/backoffice-data.service';
@Injectable({ providedIn: 'root' })
export class BackofficeFacade {
@@ -8,12 +8,12 @@ export class BackofficeFacade {
readonly categories = signal<CategoryCardConfig[]>([]);
readonly loading = signal(false);
constructor(private readonly http: HttpClient) {}
constructor(private readonly backofficeDataService: BackofficeDataService) {}
load(): void {
this.loading.set(true);
this.http.get<ProductCardConfig[]>('/assets/mock/bootstrap/products.json').subscribe({
this.backofficeDataService.loadProducts().subscribe({
next: (products) => {
this.products.set(products ?? []);
this.loadCategories();
@@ -26,7 +26,7 @@ export class BackofficeFacade {
}
private loadCategories(): void {
this.http.get<CategoryCardConfig[]>('/assets/mock/bootstrap/categories.json').subscribe({
this.backofficeDataService.loadCategories().subscribe({
next: (categories) => {
this.categories.set(categories ?? []);
this.loading.set(false);