import React from 'react'; import { Alert, AlertProps, AlertGroup, AlertActionCloseButton, AlertVariant, InputGroup, InputGroupItem } from '@breakaway/preact-core'; export const AlertGroupSingularDynamic: 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('Success alert', 'success', getUniqueId()); }; const addDangerAlert = () => { addAlert('Danger alert', 'danger', getUniqueId()); }; const addInfoAlert = () => { addAlert('Info alert', 'info', getUniqueId()); }; return ( {alerts.map(({ title, variant, key }) => ( removeAlert(key)} /> } /> ))} ); };