admin/lib/toast.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

35 lines
955 B
TypeScript

import type { ReactNode } from 'react'
import { toast } from '@heroui/react'
type LegacyToastColor = 'default' | 'success' | 'warning' | 'danger'
export interface AddToastOptions {
title: ReactNode
description?: ReactNode
color?: LegacyToastColor
timeout?: number
onClose?: () => void
}
/**
* Compatibility adapter for the HeroUI v2 `addToast` API.
*
* Keeping application call sites behind this module decouples business logic
* from HeroUI's queue API and makes future notification-library changes local.
*/
export function addToast({ title, description, color = 'default', timeout, onClose }: AddToastOptions): string {
const options = { description, timeout, onClose }
switch (color) {
case 'success':
return toast.success(title, options)
case 'warning':
return toast.warning(title, options)
case 'danger':
return toast.danger(title, options)
default:
return toast(title, options)
}
}