import type { AlertLevelType } from '@ringcentral-integration/commons/modules/Alert/alertLevels'; import { emptyArray, emptyFn } from '@ringcentral-integration/utils'; import clsx from 'clsx'; import type { FunctionComponent } from 'react'; import React from 'react'; import Message from '../Message'; import styles from './styles.scss'; export type AlertDisplayProps = { className?: string; messages?: { id: string; level: AlertLevelType; message: string; payload?: any; animation?: string; duration?: string; // ttl: number; // timestamp: number; }[]; getRenderer?: (...args: any[]) => any; dismiss: (...args: any[]) => any; currentLocale: string; brand?: string; component?: (...args: any[]) => any; // animation?: string; // duration?: number; }; const AlertDisplay: FunctionComponent = ({ getRenderer = emptyFn, brand = 'RingCentral', component: RendererMessage = Message, className, messages = emptyArray, dismiss, currentLocale, }) => { return (
{messages.map((message) => { const Renderer = getRenderer(message); if (!Renderer) return null; return ( } onDismiss={() => { dismiss(message.id); }} /> ); })}
); }; export default AlertDisplay;