import React, { useState, useEffect } from 'react' import { Icon, IconProps } from '../../Icons' type alertTypesOptions = 'success' | 'warning' | 'danger' | 'info' | 'primary' const alertTypes: Record< alertTypesOptions, { class: string icon: IconProps['icon'] iconClass: string } > = { success: { class: 'bg-success-light border-success', icon: 'checkCircle', iconClass: 'text-success', }, warning: { class: 'bg-warning-light border-warning', icon: 'exclamationTriangle', iconClass: 'text-warning', }, danger: { class: 'bg-danger-light border-danger', icon: 'ban', iconClass: 'text-danger', }, info: { class: 'bg-base-1 border-inverted-2', icon: 'infoCircle', iconClass: 'text-inverted-2', }, primary: { class: 'bg-primary-light border-primary', icon: 'infoCircle', iconClass: 'text-primary', }, } const AlertComponent = ({ type = 'info', isOpen = true, title, subtitle, actions, showClose = false, onClose, hideIcon = false, }: AlertProps) => { const [alertIsOpen, setAlertIsOpen] = useState(isOpen) useEffect(() => { setAlertIsOpen(isOpen) }, [isOpen]) const handleOnClose = () => { setAlertIsOpen(false) onClose?.() } if (!alertIsOpen) return null return (