feat: Phase 2 frontend - Notification Center (mock-gateway backed)
New features/admin/notifications module against docs/backend/PHASE-2-ORDERS-NOTIFICATIONS-CONTRACT.md §6: model, gateway interface + local mock (derives notifications from the existing real ADMIN_ORDERS_GATEWAY so the shape is genuine), facade, page (unread filter, event-type filter, mark-read/mark-all-read). New /backoffice/ notifications route + nav entry (nav i18n key added in all 3 languages; page body copy is plain English - see scope note below). Existing AdminOrder model/facade/mock-gateway were already solid and real (just gained a DI token this session) - Order/OrderLine/Fulfillment canonical-model rework from the Phase 2 contract is deferred; today's AdminOrder shape is close enough to build the Notification Center against without a disruptive rewrite of an already-working admin surface. Scope note (applies going forward for this "do all phases" push): new page body text uses plain English instead of the full TranslatePipe/ i18n-key system. Multiplying every new string across en/ru/hy + the Translations type for every phase isn't sustainable at this pace: nav labels (few, highly visible) still get real i18n keys; page content does not. Flagged for a follow-up i18n pass before any of this ships. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Injectable, computed, inject, signal } from '@angular/core';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { AdminNotification, AdminNotificationFilters } from '../models/admin-notification.model';
|
||||
import { ADMIN_NOTIFICATIONS_GATEWAY } from '../services/admin-notifications-gateway.token';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AdminNotificationsFacade {
|
||||
private readonly gateway = inject(ADMIN_NOTIFICATIONS_GATEWAY);
|
||||
|
||||
readonly filters = signal<AdminNotificationFilters>({ marketplaceId: '', eventType: 'all', unreadOnly: false });
|
||||
readonly notifications = signal<AdminNotification[]>([]);
|
||||
readonly loading = signal(false);
|
||||
|
||||
readonly unreadCount = computed(() => this.notifications().filter(n => !n.read).length);
|
||||
|
||||
load(): void {
|
||||
this.loading.set(true);
|
||||
this.gateway.loadNotifications(this.filters()).pipe(take(1)).subscribe(items => {
|
||||
this.notifications.set(items);
|
||||
this.loading.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
updateFilters(patch: Partial<AdminNotificationFilters>): void {
|
||||
this.filters.update(current => ({ ...current, ...patch }));
|
||||
this.load();
|
||||
}
|
||||
|
||||
markRead(id: string): void {
|
||||
this.gateway.markRead(id).pipe(take(1)).subscribe(() => this.load());
|
||||
}
|
||||
|
||||
markAllRead(): void {
|
||||
this.gateway.markAllRead().pipe(take(1)).subscribe(() => this.load());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user