Clean and lint

This commit is contained in:
Nathan Barber
2021-12-01 01:52:18 -05:00
parent c0d5778d93
commit 999cc0a37c
6 changed files with 32 additions and 35 deletions

View File

@@ -71,7 +71,7 @@ const AddUser = (props) => {
type="checkbox"
id="admin-check"
checked={admin}
onChange={(e) => setAdmin(!admin)}
onChange={() => setAdmin(!admin)}
/>
<span> </span>
<label className="form-check-label">Admin</label>
@@ -104,14 +104,16 @@ const AddUser = (props) => {
? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch((err) => console.log(err))
.catch(() =>
setErrorAlert(`Failed to update users.`)
)
: setErrorAlert(
`Failed to create user. ${
data.status == 409 ? "User already exists." : ""
}`
)
)
.catch((err) => setErrorAlert(`Failed to create user.`));
.catch(() => setErrorAlert(`Failed to create user.`));
}}
>
Add Users

View File

@@ -80,7 +80,7 @@ const CreateGroup = (props) => {
? updateGroups(0, limit)
.then((data) => dispatchPageUpdate(data, 0))
.then(() => history.push("/groups"))
.catch((err) =>
.catch(() =>
setErrorAlert(`Could not update groups list.`)
)
: setErrorAlert(
@@ -91,7 +91,7 @@ const CreateGroup = (props) => {
}`
);
})
.catch((err) => setErrorAlert(`Failed to create group.`));
.catch(() => setErrorAlert(`Failed to create group.`));
}}
>
Create

View File

@@ -19,14 +19,7 @@ const EditUser = (props) => {
});
};
var {
editUser,
deleteUser,
failRegexEvent,
noChangeEvent,
updateUsers,
history,
} = props;
var { editUser, deleteUser, noChangeEvent, updateUsers, history } = props;
if (props.location.state == undefined) {
props.history.push("/");
@@ -101,14 +94,14 @@ const EditUser = (props) => {
? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch((err) =>
.catch(() =>
setErrorAlert(
`Could not update users list.`
)
)
: setErrorAlert(`Failed to edit user.`);
})
.catch((err) => {
.catch(() => {
setErrorAlert(`Failed to edit user.`);
});
}}
@@ -147,14 +140,14 @@ const EditUser = (props) => {
? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch((err) =>
.catch(() =>
setErrorAlert(
`Could not update users list.`
)
)
: setErrorAlert(`Failed to edit user.`);
})
.catch((err) => {
.catch(() => {
setErrorAlert(`Failed to edit user.`);
});
} else {
@@ -169,12 +162,12 @@ const EditUser = (props) => {
? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch((err) =>
.catch(() =>
setErrorAlert(`Could not update users list.`)
)
: setErrorAlert(`Failed to edit user.`);
})
.catch((err) => {
.catch(() => {
setErrorAlert(`Failed to edit user.`);
});
}

View File

@@ -116,7 +116,7 @@ const GroupEdit = (props) => {
.then(() => history.push("/groups"))
: setErrorAlert(`Failed to edit group.`);
})
.catch((err) => setErrorAlert(`Failed to edit group.`));
.catch(() => setErrorAlert(`Failed to edit group.`));
}}
>
Apply
@@ -137,7 +137,7 @@ const GroupEdit = (props) => {
.then(() => history.push("/groups"))
: setErrorAlert(`Failed to delete group.`);
})
.catch((err) => setErrorAlert(`Failed to delete group.`));
.catch(() => setErrorAlert(`Failed to delete group.`));
}}
>
Delete Group

View File

@@ -169,14 +169,12 @@ const ServerDashboard = (props) => {
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch((err) =>
.catch(() =>
setErrorAlert(`Failed to update users list.`)
);
return res;
})
.catch((err) =>
setErrorAlert(`Failed to start servers.`)
);
.catch(() => setErrorAlert(`Failed to start servers.`));
}}
>
Start All
@@ -207,12 +205,12 @@ const ServerDashboard = (props) => {
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch((err) =>
.catch(() =>
setErrorAlert(`Failed to update users list.`)
);
return res;
})
.catch((err) => setErrorAlert(`Failed to stop servers.`));
.catch(() => setErrorAlert(`Failed to stop servers.`));
}}
>
Stop All
@@ -249,7 +247,7 @@ const ServerDashboard = (props) => {
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch((err) =>
.catch(() =>
setErrorAlert(
`Failed to update users list.`
)
@@ -257,9 +255,7 @@ const ServerDashboard = (props) => {
: setErrorAlert(`Failed to stop server`);
return res;
})
.catch((err) =>
setErrorAlert(`Failed to stop server.`)
)
.catch(() => setErrorAlert(`Failed to stop server.`))
}
>
Stop Server
@@ -276,7 +272,7 @@ const ServerDashboard = (props) => {
.then((data) => {
dispatchPageUpdate(data, page);
})
.catch((err) =>
.catch(() =>
setErrorAlert(
`Failed to update users list.`
)
@@ -284,7 +280,7 @@ const ServerDashboard = (props) => {
: setErrorAlert(`Failed to start server`);
return res;
})
.catch((err) => {
.catch(() => {
setErrorAlert(`Failed to start server.`);
})
}

View File

@@ -37,8 +37,14 @@ const withAPI = withProps(() => ({
jhapiRequest("/users/" + username, "GET")
.then((data) => data.status)
.then((data) => (data > 200 ? false : true)),
failRegexEvent: () => {},
noChangeEvent: () => {},
// Temporarily Unused
failRegexEvent: () => {
return null;
},
noChangeEvent: () => {
return null;
},
//
refreshGroupsData: () =>
jhapiRequest("/groups", "GET").then((data) => data.json()),
refreshUserData: () =>