-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate alerts and fleet segments apis to rtk
- Loading branch information
1 parent
26664f2
commit f57c7d0
Showing
17 changed files
with
171 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 13 additions & 10 deletions
23
frontend/src/domain/use_cases/alert/getOperationalAlerts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { alertApi } from '@api/alert' | ||
import { RTK_FORCE_REFETCH_QUERY_OPTIONS } from '@api/constants' | ||
import { setPendingAlerts } from '@features/Alert/components/SideWindowAlerts/slice' | ||
|
||
import { getOperationalAlertsFromAPI } from '../../../api/alert' | ||
import { setError } from '../../shared_slices/Global' | ||
|
||
import type { MainAppThunk } from '../../../store' | ||
import type { MainAppThunk } from '@store' | ||
|
||
export const getOperationalAlerts = (): MainAppThunk => dispatch => { | ||
getOperationalAlertsFromAPI() | ||
.then(alerts => { | ||
dispatch(setPendingAlerts(alerts)) | ||
}) | ||
.catch(error => { | ||
dispatch(setError(error)) | ||
}) | ||
export const getOperationalAlerts = (): MainAppThunk => async dispatch => { | ||
try { | ||
const alerts = await dispatch( | ||
alertApi.endpoints.getOperationalAlerts.initiate(undefined, RTK_FORCE_REFETCH_QUERY_OPTIONS) | ||
).unwrap() | ||
|
||
dispatch(setPendingAlerts(alerts)) | ||
} catch (error) { | ||
dispatch(setError(error)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { alertApi } from '@api/alert' | ||
import { RTK_FORCE_REFETCH_QUERY_OPTIONS } from '@api/constants' | ||
import { setSilencedAlerts } from '@features/Alert/components/SideWindowAlerts/slice' | ||
|
||
import { getSilencedAlertsFromAPI } from '../../../api/alert' | ||
import { setError } from '../../shared_slices/Global' | ||
|
||
export const getSilencedAlerts = () => dispatch => { | ||
getSilencedAlertsFromAPI() | ||
.then(silencedAlerts => { | ||
dispatch(setSilencedAlerts(silencedAlerts)) | ||
}) | ||
.catch(error => { | ||
dispatch(setError(error)) | ||
}) | ||
export const getSilencedAlerts = () => async dispatch => { | ||
try { | ||
const silencedAlerts = await dispatch( | ||
alertApi.endpoints.getSilencedAlerts.initiate(undefined, RTK_FORCE_REFETCH_QUERY_OPTIONS) | ||
).unwrap() | ||
|
||
dispatch(setSilencedAlerts(silencedAlerts)) | ||
} catch (error) { | ||
dispatch(setError(error)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.