Refactor AlertsDisplay component to simplify layout and remove mobile-specific logic
- Removed the useMediaQuery hook and associated mobile rendering logic, streamlining the component's structure. - Updated the return statement to consistently render alerts within a Flex container, enhancing layout consistency.
This commit is contained in:
parent
9aa2b0f2f8
commit
c588196580
@ -1,11 +1,10 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { createElement } from 'react'
|
import { createElement } from 'react'
|
||||||
import { Flex, Alert, Button, Dropdown, Popover } from 'antd'
|
import { Flex, Alert, Button, Dropdown } from 'antd'
|
||||||
import ExclamationOctagonIcon from '../../Icons/ExclamationOctagonIcon'
|
import ExclamationOctagonIcon from '../../Icons/ExclamationOctagonIcon'
|
||||||
import InfoCircleIcon from '../../Icons/InfoCircleIcon'
|
import InfoCircleIcon from '../../Icons/InfoCircleIcon'
|
||||||
import { CaretDownOutlined } from '@ant-design/icons'
|
import { CaretDownOutlined } from '@ant-design/icons'
|
||||||
|
|
||||||
import { useMediaQuery } from 'react-responsive'
|
|
||||||
import { getModelByName } from '../../../database/ObjectModels'
|
import { getModelByName } from '../../../database/ObjectModels'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ const AlertsDisplay = ({
|
|||||||
showDismiss = true,
|
showDismiss = true,
|
||||||
showActions = true
|
showActions = true
|
||||||
}) => {
|
}) => {
|
||||||
const isMobile = useMediaQuery({ maxWidth: 768 })
|
|
||||||
const getAlertType = (type, priority) => {
|
const getAlertType = (type, priority) => {
|
||||||
if (type === 'error' || priority === '9') return 'error'
|
if (type === 'error' || priority === '9') return 'error'
|
||||||
if (type === 'warning' || priority === '8') return 'warning'
|
if (type === 'warning' || priority === '8') return 'warning'
|
||||||
@ -176,23 +174,11 @@ const AlertsDisplay = ({
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isMobile) {
|
return (
|
||||||
return (
|
<Flex gap='small' style={{ width: '100%' }} vertical align='stretch'>
|
||||||
<Popover
|
{alertElements}
|
||||||
content={alertElements}
|
</Flex>
|
||||||
trigger='hover'
|
)
|
||||||
arrow={false}
|
|
||||||
placement='bottom'
|
|
||||||
classNames={{
|
|
||||||
root: 'printer-alerts-display-popover'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button>Alerts</Button>
|
|
||||||
</Popover>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Flex gap='small'>{alertElements}</Flex>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertsDisplay.propTypes = {
|
AlertsDisplay.propTypes = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user