arch(sprint1): decouple backoffice facade from http provider
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user