{"version":3,"sources":["app/Layout/FrontendLayout/components/Snackbar/Actions/index.tsx","app/Layout/FrontendLayout/components/Snackbar/index.tsx"],"names":["RefreshTableButton","t","useTranslation","dispatch","useDispatch","layoutActions","useLayoutSlice","actions","Button","variant","size","onClick","setRefreshTable","translations","RefreshTable","OpenDetails","props","bold","itemName","Box","component","marginX","openPanel","renderPageType","detailsType","renderPageProps","detailsTypeProps","expanded","useSidePanel","isCover","openSidePanel","type","closeMessageOnPanelOpen","closeMessage","Id","itemEndName","created","OpenMultiDetails","multiDetails","map","f","displayed","ClosableMessage","closeSnackbar","closable","message","snackKey","CloseRoot","IconButton","aria-label","className","icon","colorExtend","styled","span","SnackbarManager","useAppSettingsSlice","notifications","useSelector","selectNotifications","useSnackbar","enqueueSnackbar","history","useHistory","theme","useTheme","getActions","useCallback","item","actionType","SnackBarActionType","refreshTable","push","persist","key","length","i","LinkOnClick","React","itemLinkProps","messageTypeProps","undefined","linkUrl","replaceUrl","replace","window","open","toRootedURL","renderMessage","messageType","Fragment","parse","SnackBarMessageType","openSidepanelDetails","itemProps","multiple","createElement","Object","assign","showLinkMessage","linkText","afterLinkText","HTML","fileDownload","fileProps","file","fileName","fileTitle","messageList","listProps","messages","msg","useEffect","filter","some","notification","forEach","removeNotifications","includes","id","x","anchorOrigin","vertical","horizontal","preventDuplicate","autoHideDuration","action","onExited","_","myKey","removeNotification","direction"],"mappings":"8PAiDO,SAASA,IAAsB,IAC5BC,EAAMC,cAAND,EACFE,EAAWC,wBACAC,EAAkBC,cAA3BC,QAIR,OACE,cAACC,EAAA,EAAD,CAAQC,QAAQ,OAAOC,KAAK,QAAQC,QAJX,WACzBR,EAASE,EAAcO,iBAAgB,KAGvC,SACGX,EAAEY,IAAaC,gBAIf,SAASC,EACdC,GAEA,IAAMb,EAAWC,wBACTG,EAAYD,cAAZC,QAER,OACE,cAAC,WAAD,UACE,eAAC,IAAD,CAAMU,MAAM,EAAMP,KAAK,QAAvB,UACGM,EAAME,SACP,cAACC,E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VC,WAAY,UAEdlH,QAAS2D,EAAK3D,QACdmH,kBAAkB,EAClBC,iBAAkBzD,EAAKyD,iBACvBC,OAAQ5D,EAAWE,GAEnB2D,SAAU,SAACC,EAAGC,GAtOI,IAAAV,EAuOhBpH,EAASI,EAAQ2H,mBAAmBD,IAvOpBV,EAwOAU,EAvOtBxF,EAAS,YAAOA,EAAUwE,QAAO,SAAAvC,GAAG,OAAI6C,IAAO7C,QA2O7Cb,EAAgB2B,EAAcpB,GAAOoD,GAhPlBD,EAkPJnD,EAAKM,IAjPtBjC,EAAS,sBAAOA,GAAP,CAAkB8E,UAmP1B,CACD9D,EACAlD,EACAoC,EACAkB,EACA1D,EACA6D,EAAMmE,UACN3C,EACAtB,IAGK","file":"static/js/903.9dac8867.chunk.js","sourcesContent":["import { Body } from 'app/components/Typography';\r\nimport { translations } from 'locales/translations';\r\nimport { useTranslation } from 'react-i18next';\r\nimport { useDispatch } from 'react-redux';\r\nimport { useLayoutSlice } from '../../../slice';\r\nimport * as React from 'react';\r\nimport {\r\n PageTypeProps,\r\n RenderPageType,\r\n} from 'app/Layout/FrontendLayout/slice/type';\r\nimport { Box } from '@material-ui/core';\r\nimport { Button } from 'app/components/BasicButtons/Button';\r\nimport { SidePanelOpenState } from 'app/hooks/useSidePanelOpen';\r\n\r\nexport interface OpenDetailsProps {\r\n Id?: number;\r\n created: boolean;\r\n itemName: string;\r\n linkUrl?: string;\r\n linkText?: string;\r\n afterLinkText?: string;\r\n replaceUrl?: boolean;\r\n itemEndName?: string;\r\n detailsType?: RenderPageType;\r\n detailsTypeProps?: PageTypeProps;\r\n detailsUlr?: string;\r\n multiple?: boolean;\r\n multiDetails?: MultiDetailsProps[];\r\n useSidePanel?: boolean;\r\n openPanel?: (state: SidePanelOpenState) => void;\r\n closeMessageOnPanelOpen?: boolean;\r\n}\r\nexport interface MultiDetailsProps {\r\n Id: number;\r\n detailsType: RenderPageType;\r\n detailsTypeProps: PageTypeProps;\r\n}\r\nexport interface ListMessagesProps {\r\n messages: SingleMessagesProps[];\r\n}\r\nexport interface SingleMessagesProps {\r\n Id: string;\r\n message: string;\r\n}\r\nexport interface DownloadFileProps {\r\n file: any;\r\n fileTitle: string;\r\n fileName: string;\r\n}\r\nexport function RefreshTableButton() {\r\n const { t } = useTranslation();\r\n const dispatch = useDispatch();\r\n const { actions: layoutActions } = useLayoutSlice();\r\n const handleRefreshClick = () => {\r\n dispatch(layoutActions.setRefreshTable(true));\r\n };\r\n return (\r\n \r\n );\r\n}\r\nexport function OpenDetails(\r\n props: OpenDetailsProps & { closeMessage?: () => void },\r\n) {\r\n const dispatch = useDispatch();\r\n const { actions } = useLayoutSlice();\r\n\r\n return (\r\n \r\n \r\n {props.itemName}\r\n \r\n {\r\n if (!!props.openPanel) {\r\n props.openPanel({\r\n renderPageType: props.detailsType,\r\n renderPageProps: props.detailsTypeProps,\r\n expanded: false,\r\n useSidePanel: props.useSidePanel,\r\n isCover: props.useSidePanel,\r\n });\r\n } else {\r\n dispatch(\r\n actions.openSidePanel({\r\n type: props.detailsType,\r\n props: props.detailsTypeProps,\r\n }),\r\n );\r\n }\r\n if (props.closeMessageOnPanelOpen) {\r\n props.closeMessage?.();\r\n }\r\n }}\r\n >\r\n {`#${props.Id} `}\r\n \r\n \r\n {props.itemEndName\r\n ? props.itemEndName\r\n : `${props.created ? 'Created' : 'Updated'}!`}\r\n \r\n \r\n );\r\n}\r\nexport function OpenMultiDetails(\r\n props: OpenDetailsProps & {\r\n closeMessage?: () => void;\r\n },\r\n) {\r\n const dispatch = useDispatch();\r\n const { actions } = useLayoutSlice();\r\n return (\r\n \r\n \r\n {props.itemName}\r\n \r\n {props.multiDetails?.map(f => (\r\n {\r\n if (!!props.openPanel) {\r\n props.openPanel({\r\n renderPageType: f.detailsType,\r\n renderPageProps: f.detailsTypeProps,\r\n expanded: false,\r\n useSidePanel: props.useSidePanel,\r\n isCover: props.useSidePanel,\r\n });\r\n } else {\r\n dispatch(\r\n actions.openSidePanel({\r\n type: f.detailsType,\r\n props: f.detailsTypeProps,\r\n }),\r\n );\r\n }\r\n if (props.closeMessageOnPanelOpen) {\r\n props.closeMessage?.();\r\n }\r\n }}\r\n >\r\n {`#${f.Id} `}\r\n \r\n ))}\r\n \r\n {props.itemEndName\r\n ? props.itemEndName\r\n : `${props.created ? 'Created' : 'Updated'}!`}\r\n \r\n \r\n );\r\n}\r\n","import React, { useCallback } from 'react';\r\nimport { useSelector, useDispatch } from 'react-redux';\r\n\r\nimport { useSnackbar, OptionsObject, SnackbarKey } from 'notistack';\r\n\r\nimport { selectNotifications } from '../../../../slice/selectors';\r\nimport { useAppSettingsSlice } from 'app/slice';\r\nimport { Notification as AppNotificationMessage } from 'types/Notification';\r\nimport { useTheme } from '@material-ui/core/styles';\r\nimport { SnackBarActionType, SnackBarMessageType } from './types';\r\nimport {\r\n DownloadFileProps,\r\n ListMessagesProps,\r\n OpenDetails,\r\n OpenDetailsProps,\r\n OpenMultiDetails,\r\n RefreshTableButton,\r\n} from './Actions';\r\nimport { toRootedURL } from 'utils/url-utils';\r\nimport { Icon } from 'app/components/BasicIcons/FontAwesome';\r\nimport { parse } from 'app/components/CommentsContainer/commentParser';\r\nimport { Button } from 'app/components/BasicButtons/Button';\r\nimport { Caption } from 'app/components/Typography';\r\nimport { IconButton } from 'app/components/BasicButtons/IconButton';\r\nimport { useHistory } from 'react-router-dom';\r\nimport { FlexRow8 } from 'app/components/StyledComponents';\r\nimport fileDownload from 'js-file-download';\r\nimport styled from 'styled-components';\r\nimport { UlList } from 'app/components/BasicList/StyledList';\r\n\r\nlet displayed: any[] = [];\r\n\r\nconst SnackbarManager = () => {\r\n const dispatch = useDispatch();\r\n const { actions } = useAppSettingsSlice();\r\n const notifications = useSelector(selectNotifications);\r\n const { enqueueSnackbar, closeSnackbar } = useSnackbar();\r\n const history = useHistory();\r\n const theme = useTheme();\r\n const storeDisplayed = id => {\r\n displayed = [...displayed, id];\r\n };\r\n\r\n const removeDisplayed = id => {\r\n displayed = [...displayed.filter(key => id !== key)];\r\n };\r\n\r\n const getActions = useCallback(\r\n (item: AppNotificationMessage): React.ReactNode | undefined => {\r\n const actions: React.ReactNode[] = [];\r\n if (item.actionType) {\r\n switch (item.actionType) {\r\n case SnackBarActionType.refreshTable:\r\n actions.push();\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n if (item.persist) {\r\n actions.push(\r\n closeSnackbar(item.key)} />,\r\n );\r\n }\r\n if (actions.length > 0) {\r\n return (\r\n \r\n {actions.map((component, i) => (\r\n {component}\r\n ))}\r\n \r\n );\r\n }\r\n return undefined;\r\n },\r\n [closeSnackbar],\r\n );\r\n const LinkOnClick = React.useCallback(\r\n (item: AppNotificationMessage) => {\r\n closeSnackbar(item.key);\r\n let itemLinkProps = item.messageTypeProps as OpenDetailsProps;\r\n if (itemLinkProps?.linkUrl !== undefined) {\r\n if (!!itemLinkProps.replaceUrl) {\r\n history.replace(itemLinkProps.linkUrl);\r\n } else {\r\n window.open(toRootedURL(itemLinkProps?.linkUrl), '_self');\r\n }\r\n }\r\n },\r\n [closeSnackbar, history],\r\n );\r\n const renderMessage = React.useCallback(\r\n (item: AppNotificationMessage): React.ReactNode => {\r\n if (\r\n item.messageType !== undefined &&\r\n item.messageTypeProps !== undefined\r\n ) {\r\n switch (item.messageType) {\r\n case SnackBarMessageType.openSidepanelDetails:\r\n let itemProps = item.messageTypeProps as OpenDetailsProps;\r\n if (itemProps.multiple === true) {\r\n if (\r\n !!itemProps.multiDetails &&\r\n itemProps.multiDetails.length > 0\r\n ) {\r\n return (\r\n \r\n {React.createElement(\r\n OpenMultiDetails,\r\n Object.assign({}, itemProps, {\r\n closeMessage: () => closeSnackbar(item.key),\r\n }),\r\n )}\r\n \r\n );\r\n } else {\r\n return {item.message};\r\n }\r\n } else {\r\n if (\r\n itemProps.detailsType !== undefined &&\r\n itemProps.detailsTypeProps !== undefined\r\n ) {\r\n return (\r\n \r\n {React.createElement(\r\n OpenDetails,\r\n Object.assign({}, itemProps, {\r\n closeMessage: () => closeSnackbar(item.key),\r\n }),\r\n )}\r\n \r\n );\r\n } else {\r\n return {item.message};\r\n }\r\n }\r\n\r\n case SnackBarMessageType.showLinkMessage:\r\n let itemLinkProps = item.messageTypeProps as OpenDetailsProps;\r\n if (itemLinkProps.linkUrl !== undefined) {\r\n return (\r\n \r\n {itemLinkProps.itemName}\r\n \r\n LinkOnClick(item)}\r\n >\r\n {itemLinkProps.linkText}\r\n \r\n \r\n {itemLinkProps.afterLinkText && (\r\n {itemLinkProps.afterLinkText}\r\n )}\r\n \r\n );\r\n } else {\r\n return item.closable ? (\r\n \r\n ) : (\r\n {item.message}\r\n );\r\n }\r\n case SnackBarMessageType.HTML:\r\n return <>{parse(item.message)};\r\n case SnackBarMessageType.fileDownload:\r\n const fileProps = item.messageTypeProps as DownloadFileProps;\r\n return (\r\n <>\r\n {item.message}{' '}\r\n \r\n fileDownload(fileProps.file, fileProps.fileName)\r\n }\r\n >\r\n {fileProps.fileTitle}\r\n \r\n \r\n );\r\n case SnackBarMessageType.messageList:\r\n let listProps = item.messageTypeProps as ListMessagesProps;\r\n return item.closable ? (\r\n \r\n {listProps.messages.map(msg => (\r\n
  • {msg.message}
  • \r\n ))}\r\n \r\n }\r\n closable={item.closable}\r\n snackKey={item.key}\r\n />\r\n ) : (\r\n \r\n {listProps.messages.map(msg => (\r\n
  • {msg.message}
  • \r\n ))}\r\n
    \r\n );\r\n default:\r\n return item.closable ? (\r\n \r\n ) : (\r\n {item.message}\r\n );\r\n }\r\n // switch (item.messageType) {\r\n // case SnackBarMessageType.openTrainingDetails:\r\n // return (\r\n // \r\n // {React.createElement(OpenDetails, item.messageTypeProps)}\r\n // \r\n // );\r\n // case SnackBarMessageType.openWorkOrderDetails:\r\n // return ( \r\n // {React.createElement(OpenDetails, item.messageTypeProps)}\r\n // \r\n // )\r\n // default:\r\n // return {item.message};\r\n // }\r\n } else {\r\n if (item.closable) {\r\n return (\r\n \r\n );\r\n } else {\r\n return {parse(item.message)};\r\n }\r\n }\r\n },\r\n [LinkOnClick, closeSnackbar],\r\n );\r\n\r\n React.useEffect(() => {\r\n // remove obsolete notifcations that were removed manually throgh notif\r\n removeNotifications(notifications, closeSnackbar);\r\n\r\n notifications.forEach((item: AppNotificationMessage) => {\r\n if (displayed.length > 0 && displayed.includes(item.key)) return;\r\n const x: OptionsObject = {\r\n key: item.key,\r\n persist: item.persist,\r\n anchorOrigin: {\r\n vertical: 'bottom',\r\n horizontal: 'center',\r\n },\r\n variant: item.variant,\r\n preventDuplicate: true,\r\n autoHideDuration: item.autoHideDuration,\r\n action: getActions(item),\r\n\r\n onExited: (_, myKey) => {\r\n dispatch(actions.removeNotification(myKey));\r\n removeDisplayed(myKey);\r\n },\r\n };\r\n //Object.assign(x, { closable: item.closable });\r\n enqueueSnackbar(renderMessage(item), x);\r\n\r\n storeDisplayed(item.key);\r\n });\r\n }, [\r\n notifications,\r\n actions,\r\n closeSnackbar,\r\n enqueueSnackbar,\r\n dispatch,\r\n theme.direction,\r\n renderMessage,\r\n getActions,\r\n ]);\r\n\r\n return null;\r\n};\r\nconst ClosableMessage = ({\r\n closeSnackbar,\r\n closable,\r\n message,\r\n snackKey,\r\n}: {\r\n closeSnackbar: (snackKey?: SnackbarKey) => void;\r\n closable?: boolean;\r\n message: React.ReactNode;\r\n snackKey?: SnackbarKey;\r\n}): JSX.Element => {\r\n return (\r\n \r\n {message}\r\n {!!closable && closable === true && (\r\n closeSnackbar(snackKey)}\r\n className=\"close-icon\"\r\n >\r\n \r\n \r\n )}\r\n \r\n );\r\n};\r\nconst CloseRoot = styled.span`\r\n margin-right: 16px;\r\n & .close-icon {\r\n position: absolute;\r\n right: 0;\r\n top: 0;\r\n color: white;\r\n }\r\n`;\r\nexport default SnackbarManager;\r\n\r\n/**\r\n * Removes notifications that were removed through the appSettingActions/removeNotifications\r\n */\r\nfunction removeNotifications(\r\n notifications: AppNotificationMessage[],\r\n closeSnackbar: (key?: SnackbarKey | undefined) => void,\r\n) {\r\n const obsoleteNotifications = displayed.filter(\r\n key => !notifications.some(notification => notification.key === key),\r\n );\r\n obsoleteNotifications.forEach(key => closeSnackbar(key));\r\n}\r\n"],"sourceRoot":""}