Skip to content

Commit

Permalink
hotfix: fix issue about #141 (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
aide-cloud authored Jul 4, 2024
1 parent b79256f commit 4cfe041
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions web/src/pages/home/monitor/alarm-realtime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const AlarmRealtime: FC = () => {
const [queryParams, setQueryParams] = useState<AlarmRealtimeListRequest>(
defaultAlarmRealtimeListRequest
)
const [alarmPageIds, setAlarmPageIds] = useState<number[]>([])
const [alarmPageIds, setAlarmPageIds] = useState<number[]>()
const [alarmCountMap, setAlarmCountMap] = useState<{
[key: number]: number | string
}>()
Expand Down Expand Up @@ -78,27 +78,27 @@ const AlarmRealtime: FC = () => {

const handleGetAlarmPageList = () => {
dictApi.myAlarmPageList().then((res) => {
setAlarmPageList(res.list)
setAlarmPageIds(res.list.map((item) => item.id))
setAlarmPageList(res?.list || [])
setAlarmPageIds(res?.list?.map((item) => item.id) || [])
handleRefresh()
})
}

const handleCountAlarmByPageIds = () => {
if (alarmPageIds.length === 0) {
if ((alarmPageIds?.length || 0) === 0) {
return
}
dictApi
.countAlarmPage({
ids: alarmPageIds
ids: alarmPageIds || []
})
.then((res) => {
setAlarmCountMap(res.alarmCount)
})
}

const handleGetAlarmRealtime = () => {
if (alarmPageIds.length === 0) {
if ((alarmPageIds?.length || 0) === 0) {
return
}

Expand Down Expand Up @@ -262,10 +262,10 @@ const AlarmRealtime: FC = () => {
useEffect(() => {
handleCountAlarmByPageIds()
const params = queryParams
if (!params.alarmPageId && alarmPageIds.length > 0) {
if (!params.alarmPageId && (alarmPageIds?.length || 0) > 0) {
setQueryParams({
...queryParams,
alarmPageId: alarmPageIds[0]
alarmPageId: alarmPageIds?.[0] || 0
})
}
}, [alarmPageIds])
Expand Down

0 comments on commit 4cfe041

Please sign in to comment.