import { Component, inject } from '@angular/core'; import { RouterLink } from '@angular/router'; import { ButtonComponent, ToastService } from '@africanies/africanies-ui'; import { DemoSectionComponent } from '../shared/demo-section.component'; import { PageHeaderComponent } from '../shared/page-header.component'; import { TOAST_HTTP, TOAST_STACK, TOAST_VARIANTS } from '../snippets'; /** * Toast catalog — timed, persistent error, collapse, HTTP tagging docs. */ @Component({ selector: 'app-toast-page', standalone: true, imports: [ ButtonComponent, PageHeaderComponent, DemoSectionComponent, RouterLink, ], template: `

Short messages in the corner after an action (saved, failed, reminder). Mounted with CDK Overlay. Errors stay until dismissed; warnings linger longer; identical messages collapse into one with a count. Enable with provideAfricaniesToasts().

`, }) export class ToastPage { private readonly toast = inject(ToastService); protected readonly variantsCode = TOAST_VARIANTS; protected readonly stackCode = TOAST_STACK; protected readonly httpCode = TOAST_HTTP; protected showInfo(): void { this.toast.info('Cutoff is in 2 hours for this lane.', 'Reminder'); } protected showSuccess(): void { this.toast.success('Shipment saved', 'Done'); } protected showWarning(): void { this.toast.warning('Rates may be outdated. Refresh before quoting.'); } protected showError(): void { this.toast.error('Could not reach the carrier API.', 'Request failed'); } protected showManyErrors(): void { for (const name of [ 'FedEx', 'UPS', 'DHL', 'USPS', 'OnTrac', 'LaserShip', 'Amazon', 'XPO', ]) { this.toast.error(`Could not reach ${name}.`, 'Request failed'); } } protected clearAll(): void { this.toast.clear(); } protected spamError(): void { this.toast.error('Warehouse offline', 'Sync failed'); } protected simulateOk(): void { this.toast.success('Shipment created'); } protected simulateFail(): void { this.toast.error('Could not create shipment', 'Request failed'); } protected simulateSilentOk(): void { this.toast.info('Finished with withToast({ success: false }) — no success toast.'); } }