diff options
Diffstat (limited to 'modern/src/CachingController.js')
-rw-r--r-- | modern/src/CachingController.js | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js deleted file mode 100644 index b8e5fd90..00000000 --- a/modern/src/CachingController.js +++ /dev/null @@ -1,70 +0,0 @@ -import { useDispatch, useSelector, connect } from 'react-redux'; - -import { - geofencesActions, groupsActions, driversActions, maintenancesActions, calendarsActions, -} from './store'; -import { useEffectAsync } from './reactHelper'; - -const CachingController = () => { - const authenticated = useSelector((state) => !!state.session.user); - const dispatch = useDispatch(); - - useEffectAsync(async () => { - if (authenticated) { - const response = await fetch('/api/geofences'); - if (response.ok) { - dispatch(geofencesActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - } - }, [authenticated]); - - useEffectAsync(async () => { - if (authenticated) { - const response = await fetch('/api/groups'); - if (response.ok) { - dispatch(groupsActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - } - }, [authenticated]); - - useEffectAsync(async () => { - if (authenticated) { - const response = await fetch('/api/drivers'); - if (response.ok) { - dispatch(driversActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - } - }, [authenticated]); - - useEffectAsync(async () => { - if (authenticated) { - const response = await fetch('/api/maintenance'); - if (response.ok) { - dispatch(maintenancesActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - } - }, [authenticated]); - - useEffectAsync(async () => { - if (authenticated) { - const response = await fetch('/api/calendars'); - if (response.ok) { - dispatch(calendarsActions.refresh(await response.json())); - } else { - throw Error(await response.text()); - } - } - }, [authenticated]); - - return null; -}; - -export default connect()(CachingController); |