diff options
author | Anton Tananaev <anton@traccar.org> | 2023-01-27 14:24:09 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-01-27 14:24:09 -0800 |
commit | 2a1bc9710eb1005a8937dc7ec63c25975bb28f41 (patch) | |
tree | af414797d86b809f845562e498637a4f2f2bf9ce /modern/src/CachingController.js | |
parent | c2f20eb92f9d916df576d6fecc4063c41a089b0e (diff) | |
download | trackermap-web-2a1bc9710eb1005a8937dc7ec63c25975bb28f41.tar.gz trackermap-web-2a1bc9710eb1005a8937dc7ec63c25975bb28f41.tar.bz2 trackermap-web-2a1bc9710eb1005a8937dc7ec63c25975bb28f41.zip |
Scheduled reports page
Diffstat (limited to 'modern/src/CachingController.js')
-rw-r--r-- | modern/src/CachingController.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js index 1c8fb43a..55a4e020 100644 --- a/modern/src/CachingController.js +++ b/modern/src/CachingController.js @@ -1,7 +1,7 @@ import { useDispatch, useSelector, connect } from 'react-redux'; import { - geofencesActions, groupsActions, driversActions, maintenancesActions, + geofencesActions, groupsActions, driversActions, maintenancesActions, calendarsActions, } from './store'; import { useEffectAsync } from './reactHelper'; @@ -53,6 +53,17 @@ const CachingController = () => { } }, [authenticated]); + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/calendars'); + if (response.ok) { + dispatch(calendarsActions.update(await response.json())); + } else { + throw Error(await response.text()); + } + } + }, [authenticated]); + return null; }; |