Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 66x 22x 17x 5x 6x 17x | import { notification, message as antdMessage } from 'antd'; import { wrapAsHtml } from "@utils/ComponentUtils"; import React, { CSSProperties, ReactNode } from 'react'; import i18n from "@config/i18n"; import { IssuesCloseOutlined, InfoCircleOutlined, AlertOutlined } from "@ant-design/icons"; import { PrimaryColor } from '@config/base'; import { CloseIcon } from '../components'; import { emptyMethod } from './Constants'; const NotificationDefaultStyle = { bottom: "24px" } as CSSProperties; export function openErrorNotification( description: string | undefined | null | ReactNode, message?: string | undefined | null | ReactNode, ): void { notification.error({ message: message ?? i18n.t("Error message"), duration: 0, //Never auto close error notification description: (typeof description === 'string') ? wrapAsHtml(description) : description, style: NotificationDefaultStyle, closeIcon: (<CloseIcon onClick={emptyMethod} />), placement: "bottomRight" }); } export function openInfoNotification( message: string | undefined | null | ReactNode, ): void { openSuccessMessage(message); } export function openImportantNotification( message: string | undefined | null | ReactNode, description: string | undefined | null | ReactNode, ): void { notification.info({ message: (typeof message === 'string') ? wrapAsHtml(message) : message, description: (typeof description === 'string') ? wrapAsHtml(description) : description, style: NotificationDefaultStyle, duration: 0, //Never auto close important notification icon: (<AlertOutlined style={{ color: "red" }} />), closeIcon: (<CloseIcon onClick={emptyMethod} />), placement: "bottomRight" }); } export function openInfoNotificationWithDuration( message: string | undefined | null | ReactNode, description: string | undefined | null | ReactNode, duration: number, ): void { notification.info({ message: (typeof message === 'string') ? wrapAsHtml(message) : message, description: (typeof description === 'string') ? wrapAsHtml(description) : description, style: NotificationDefaultStyle, duration, icon: (<InfoCircleOutlined style={{ color: "green" }} />), closeIcon: (<CloseIcon onClick={emptyMethod} />), placement: "bottomRight" }); } export function openWarningNotification( message: string | undefined | null | ReactNode, ): void { openWarningNotificationWithDescription(message, undefined); } export function openWarningNotificationWithDescription( message: string | undefined | null | ReactNode, description: string | undefined | null | ReactNode, ): void { notification.warning({ message: (typeof message === 'string') ? wrapAsHtml(message) : message, description: (typeof description === 'string') ? wrapAsHtml(description) : description, style: NotificationDefaultStyle, duration: 0, //Never auto close warning notification icon: (<IssuesCloseOutlined style={{ color: PrimaryColor }} />), closeIcon: (<CloseIcon onClick={emptyMethod} />), placement: "bottomRight" }); } export function openSuccessMessage(message: string | ReactNode): void { antdMessage.success(message).then(() => { // Auto close message after 1 seconds setTimeout(() => { antdMessage.destroy(); }, 1000); }); } |