import React from 'react'; import { Alert, AlertProps, AlertGroup, AlertActionCloseButton, AlertVariant, InputGroup, InputGroupItem } from '@breakaway/preact-core'; export const AlertGroupToast: React.FunctionComponent = () => { const [alerts, setAlerts] = React.useState[]>([]); const addAlert = (title: string, variant: AlertProps['variant'], key: React.Key) => { setAlerts((prevAlerts) => [...prevAlerts, { title, variant, key }]); }; const removeAlert = (key: React.Key) => { setAlerts((prevAlerts) => [...prevAlerts.filter((alert) => alert.key !== key)]); }; const btnClasses = ['pf-v5-c-button', 'pf-m-secondary'].join(' '); const getUniqueId = () => new Date().getTime(); const addSuccessAlert = () => { addAlert('Toast success alert', 'success', getUniqueId()); }; const addDangerAlert = () => { addAlert('Toast danger alert', 'danger', getUniqueId()); }; const addInfoAlert = () => { addAlert('Toast info alert', 'info', getUniqueId()); }; return ( {alerts.map(({ key, variant, title }) => ( removeAlert(key)} /> } key={key} /> ))} ); };