2024-04-15 04:21:52 -04:00
|
|
|
import Notification from '@/shared/components/notification'
|
|
|
|
import { Alert, AlertProps } from 'react-bootstrap'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
import classnames from 'classnames'
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
type OLNotificationProps = React.ComponentProps<typeof Notification> & {
|
2024-04-15 04:21:52 -04:00
|
|
|
bs3Props?: {
|
2024-04-23 06:25:05 -04:00
|
|
|
icon?: React.ReactElement
|
2024-04-15 04:21:52 -04:00
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
function OLNotification(props: OLNotificationProps) {
|
2024-04-15 04:21:52 -04:00
|
|
|
const { bs3Props, ...notificationProps } = props
|
|
|
|
|
|
|
|
const alertProps = {
|
|
|
|
// Map `error` to `danger`
|
|
|
|
bsStyle:
|
|
|
|
notificationProps.type === 'error' ? 'danger' : notificationProps.type,
|
|
|
|
className: classnames(notificationProps.className, bs3Props?.className),
|
|
|
|
onDismiss: notificationProps.onDismiss,
|
|
|
|
} as const satisfies AlertProps
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={
|
|
|
|
<Alert {...alertProps}>
|
|
|
|
{bs3Props?.icon}
|
|
|
|
{bs3Props?.icon && ' '}
|
|
|
|
{notificationProps.content}
|
|
|
|
</Alert>
|
|
|
|
}
|
|
|
|
bs5={
|
|
|
|
<div className="notification-list">
|
|
|
|
<Notification {...notificationProps} />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
export default OLNotification
|