import { Injectable, inject } from '@angular/core'; import { map, Observable, of } from 'rxjs'; import { HttpService } from '../http-request/http.service'; import { CallActivityPoint, CallOutcomeShare, HourlyCallPoint, WallboardKpis, WallboardView, } from './wallboard.types'; import { MOCK_CALL_ACTIVITY, MOCK_CALL_OUTCOMES, MOCK_HOURLY_CALLS, MOCK_WALLBOARD_KPIS, } from './wallboard.mock'; /** * Call center wallboard data source. The dashboard is read-only, so every * endpoint is a plain GET that returns a ready-to-render view. While no * wallboard endpoints exist on the backend, deterministic mock data keeps the * dashboard fully explorable; flip `useMockData` to false (and align the * endpoint paths) to consume the real API without touching the page. */ @Injectable({ providedIn: 'root', }) export class WallboardService { private readonly http = inject(HttpService); /** Flip to false once the backend wallboard endpoints are deployed. */ private readonly useMockData = true; getKpis(): Observable { return this.request('wallboard/kpis', {}, MOCK_WALLBOARD_KPIS); } /** سهم روش‌های پاسخ‌گویی: هوش مصنوعی در مقابل کارشناس. */ getOutcomes(): Observable { return this.request('wallboard/call-outcomes', {}, MOCK_CALL_OUTCOMES); } getActivity(days = 14): Observable { return this.request( 'wallboard/call-activity', { days }, MOCK_CALL_ACTIVITY, ); } getHourlyDistribution(): Observable { return this.request( 'wallboard/hourly-distribution', {}, MOCK_HOURLY_CALLS, ); } getOverview(): Observable { return this.request('wallboard/overview', {}, { kpis: MOCK_WALLBOARD_KPIS, outcomes: MOCK_CALL_OUTCOMES, activity: MOCK_CALL_ACTIVITY, hourly: MOCK_HOURLY_CALLS, }); } private request(endpoint: string, params: Record, fallback: T): Observable { if (this.useMockData) { return of(fallback); } return this.http .get(endpoint, { params, skipToast: true, skipHasErrorCheck: true }) .pipe(map((response) => response.result)); } }