notification-wrapper.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Notification from '@/shared/components/notification'
  2. import { Alert, AlertProps } from 'react-bootstrap'
  3. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  4. import classnames from 'classnames'
  5. type NotificationWrapperProps = React.ComponentProps<typeof Notification> & {
  6. bs3Props?: {
  7. icon: React.ReactElement
  8. className?: string
  9. }
  10. }
  11. function NotificationWrapper(props: NotificationWrapperProps) {
  12. const { bs3Props, ...notificationProps } = props
  13. const alertProps = {
  14. // Map `error` to `danger`
  15. bsStyle:
  16. notificationProps.type === 'error' ? 'danger' : notificationProps.type,
  17. className: classnames(notificationProps.className, bs3Props?.className),
  18. onDismiss: notificationProps.onDismiss,
  19. } as const satisfies AlertProps
  20. return (
  21. <BootstrapVersionSwitcher
  22. bs3={
  23. <Alert {...alertProps}>
  24. {bs3Props?.icon}
  25. {bs3Props?.icon && ' '}
  26. {notificationProps.content}
  27. </Alert>
  28. }
  29. bs5={
  30. <div className="notification-list">
  31. <Notification {...notificationProps} />
  32. </div>
  33. }
  34. />
  35. )
  36. }
  37. export default NotificationWrapper