Normalize this code.
This commit is contained in:
parent
c71c1e57db
commit
52308af74d
1 changed files with 5 additions and 5 deletions
|
@ -46,9 +46,9 @@ const ActivePill = ({ active }: { active: boolean }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const params = useParams() as Params;
|
|
||||||
const history = useHistory();
|
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 id = ServerContext.useStoreState(state => state.server.data!.id);
|
||||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||||
|
@ -61,20 +61,20 @@ export default () => {
|
||||||
const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule);
|
const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (schedule?.id === Number(params.id)) {
|
if (schedule?.id === Number(scheduleId)) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFlashes('schedules');
|
clearFlashes('schedules');
|
||||||
getServerSchedule(uuid, Number(params.id))
|
getServerSchedule(uuid, Number(scheduleId))
|
||||||
.then(schedule => appendSchedule(schedule))
|
.then(schedule => appendSchedule(schedule))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
clearAndAddHttpError({ error, key: 'schedules' });
|
clearAndAddHttpError({ error, key: 'schedules' });
|
||||||
})
|
})
|
||||||
.then(() => setIsLoading(false));
|
.then(() => setIsLoading(false));
|
||||||
}, [ params ]);
|
}, [ scheduleId ]);
|
||||||
|
|
||||||
const toggleEditModal = useCallback(() => {
|
const toggleEditModal = useCallback(() => {
|
||||||
setShowEditModal(s => !s);
|
setShowEditModal(s => !s);
|
||||||
|
|
Loading…
Reference in a new issue