diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-26 22:56:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 22:56:40 -0700 |
commit | 17e1f8c7b67a36c4e9384b7c7b930b68c8bfd6f4 (patch) | |
tree | cc596678a30c0c50d1a99831e30839cd964ed501 /modern/src/CachingController.js | |
parent | 047bf86480e2b3e215c13df2af0da456a664b507 (diff) | |
parent | 127a2628b61b0a151eb5225af7ecaf483f907665 (diff) | |
download | etbsa-traccar-web-17e1f8c7b67a36c4e9384b7c7b930b68c8bfd6f4.tar.gz etbsa-traccar-web-17e1f8c7b67a36c4e9384b7c7b930b68c8bfd6f4.tar.bz2 etbsa-traccar-web-17e1f8c7b67a36c4e9384b7c7b930b68c8bfd6f4.zip |
Merge pull request #844 from mail2bishnoi/stores
Created mostly used stores
Diffstat (limited to 'modern/src/CachingController.js')
-rw-r--r-- | modern/src/CachingController.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js index fa3b9f6..3f808de 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, maintenancesActions } from './store'; import { useEffectAsync } from './reactHelper'; const CachingController = () => { @@ -15,6 +15,33 @@ 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/maintenance'); + if (response.ok) { + dispatch(maintenancesActions.update(await response.json())); + } + } + }, [authenticated]); return null; } |