import { FC, useState } from 'react'; import { LocalizeText, NotificationAlertItem, NotificationAlertType, OpenUrl } from '../../../../api'; import { Button, Column, Flex, LayoutNotificationAlertView, LayoutNotificationAlertViewProps } from '../../../../common'; interface NotificationDefaultAlertViewProps extends LayoutNotificationAlertViewProps { item: NotificationAlertItem; } export const NotificationDefaultAlertView: FC = props => { const { item = null, title = ((props.item && props.item.title) || ''), onClose = null, ...rest } = props; const [ imageFailed, setImageFailed ] = useState(false); const visitUrl = () => { OpenUrl(item.clickUrl); onClose(); }; const hasFrank = (item.alertType === NotificationAlertType.DEFAULT); return ( { hasFrank && !item.imageUrl &&
} { item.imageUrl && !imageFailed && { { setImageFailed(true); } } /> }
{ (item.messages.length > 0) && item.messages.map((message, index) => { const htmlText = message.replace(/\r\n|\r|\n/g, '
'); return
; }) } { item.clickUrl && (item.clickUrl.length > 0) && (item.imageUrl && !imageFailed) && <>
}
{ (!item.imageUrl || (item.imageUrl && imageFailed)) && <>
{ !item.clickUrl && } { item.clickUrl && (item.clickUrl.length > 0) && }
} ); };