import React from 'react'; import { Alert, AlertGroup, AlertVariant, InputGroup } from '@breakaway/preact-core'; interface AlertInfo { title: string; variant: AlertVariant; key: number; } export const DynamicLiveRegionAlert: React.FunctionComponent = () => { const [alerts, setAlerts] = React.useState([]); const getUniqueId: () => number = () => new Date().getTime(); const btnClasses = ['pf-v5-c-button', 'pf-m-secondary'].join(' '); const addAlert = (alertInfo: AlertInfo) => { setAlerts((prevAlertInfo) => [...prevAlertInfo, alertInfo]); }; const addSuccessAlert = () => { addAlert({ title: 'Single success alert', variant: AlertVariant.success, key: getUniqueId() }); }; const addInfoAlert = () => { addAlert({ title: 'Single info alert', variant: AlertVariant.info, key: getUniqueId() }); }; const addDangerAlert = () => { addAlert({ title: 'Single danger alert', variant: AlertVariant.danger, key: getUniqueId() }); }; return ( {alerts.map(({ title, variant, key }) => ( ))} ); };