Normalize this code.

This commit is contained in:
Dane Everitt 2021-04-04 09:45:20 -07:00
parent c71c1e57db
commit 52308af74d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -46,9 +46,9 @@ const ActivePill = ({ active }: { active: boolean }) => (
);
export default () => {
const params = useParams() as Params;
const history = useHistory();
const state: State = useLocation().state;
const { state } = useLocation<State>();
const { id: scheduleId } = useParams<Params>();
const id = ServerContext.useStoreState(state => state.server.data!.id);
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
@ -61,20 +61,20 @@ export default () => {
const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule);
useEffect(() => {
if (schedule?.id === Number(params.id)) {
if (schedule?.id === Number(scheduleId)) {
setIsLoading(false);
return;
}
clearFlashes('schedules');
getServerSchedule(uuid, Number(params.id))
getServerSchedule(uuid, Number(scheduleId))
.then(schedule => appendSchedule(schedule))
.catch(error => {
console.error(error);
clearAndAddHttpError({ error, key: 'schedules' });
})
.then(() => setIsLoading(false));
}, [ params ]);
}, [ scheduleId ]);
const toggleEditModal = useCallback(() => {
setShowEditModal(s => !s);