diff options
author | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2021-04-20 12:15:13 +0530 |
---|---|---|
committer | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2021-04-20 12:15:13 +0530 |
commit | 2d5ec8721c2d9ae3d519dd5ff267a05b5f1ab96b (patch) | |
tree | 3e352b219ccfa178ca7f678d6a434a104bfdd987 /modern/src/CachingController.js | |
parent | 047bf86480e2b3e215c13df2af0da456a664b507 (diff) | |
download | etbsa-traccar-web-2d5ec8721c2d9ae3d519dd5ff267a05b5f1ab96b.tar.gz etbsa-traccar-web-2d5ec8721c2d9ae3d519dd5ff267a05b5f1ab96b.tar.bz2 etbsa-traccar-web-2d5ec8721c2d9ae3d519dd5ff267a05b5f1ab96b.zip |
Created mostly used stores
Diffstat (limited to 'modern/src/CachingController.js')
-rw-r--r-- | modern/src/CachingController.js | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js index fa3b9f6..faeec48 100644 --- a/modern/src/CachingController.js +++ b/modern/src/CachingController.js @@ -1,6 +1,6 @@ import { useDispatch, useSelector } from 'react-redux'; import { connect } from 'react-redux'; -import { geofencesActions } from './store'; +import { geofencesActions, groupsActions, driversActions, calendarsActions, commandsActions, computedAttributesActions, maintenancesActions, notificationsActions } from './store'; import { useEffectAsync } from './reactHelper'; const CachingController = () => { @@ -15,6 +15,69 @@ const CachingController = () => { } } }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/groups'); + if (response.ok) { + dispatch(groupsActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/drivers'); + if (response.ok) { + dispatch(driversActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/calendars'); + if (response.ok) { + dispatch(calendarsActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/commands'); + if (response.ok) { + dispatch(commandsActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/attributes/computed'); + if (response.ok) { + dispatch(computedAttributesActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/maintenance'); + if (response.ok) { + dispatch(maintenancesActions.update(await response.json())); + } + } + }, [authenticated]); + + useEffectAsync(async () => { + if (authenticated) { + const response = await fetch('/api/notifications'); + if (response.ok) { + dispatch(notificationsActions.update(await response.json())); + } + } + }, [authenticated]); return null; } |