Sprint 9: add tenant-driven API resolution layer
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable, signal, computed } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Region, GeoIpResponse } from '../models/location.model';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { ApiConfigService } from '../core/config/api-config.service';
|
||||
|
||||
const STORAGE_KEY = 'selected_region';
|
||||
|
||||
@@ -26,16 +26,17 @@ export class LocationService {
|
||||
/** Computed region id for API calls — empty string means global */
|
||||
readonly regionId = computed(() => this.regionSignal()?.id ?? '');
|
||||
|
||||
private readonly apiUrl = environment.apiUrl;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
constructor(
|
||||
private readonly http: HttpClient,
|
||||
private readonly apiConfig: ApiConfigService
|
||||
) {
|
||||
this.loadRegions();
|
||||
this.restoreFromStorage();
|
||||
}
|
||||
|
||||
/** Fetch available regions from backend */
|
||||
loadRegions(): void {
|
||||
this.http.get<Region[]>(`${this.apiUrl}/regions`).subscribe({
|
||||
this.http.get<Region[]>(`${this.apiConfig.getBaseUrl()}/regions`).subscribe({
|
||||
next: (regions) => {
|
||||
this.regionsSignal.set(regions);
|
||||
// If we have a stored region, validate it still exists
|
||||
|
||||
Reference in New Issue
Block a user