diff --git a/frontend/js/actions/admins.js b/frontend/js/actions/admins.js
index c9c713a..9beb65b 100644
--- a/frontend/js/actions/admins.js
+++ b/frontend/js/actions/admins.js
@@ -30,3 +30,13 @@ export function updateUser(data) {
]
)
}
+
+export function deleteUser(username) {
+ return request(
+ "ADMIN_DELETE_USER",
+ configureAxios().delete("/admins/users/"+ username),
+ [
+ () => getUsers(),
+ ]
+ )
+}
diff --git a/frontend/js/components/admins/user.js b/frontend/js/components/admins/user.js
index b6a9ad5..f21b142 100644
--- a/frontend/js/components/admins/user.js
+++ b/frontend/js/components/admins/user.js
@@ -37,6 +37,7 @@ export const User = ({
{
const [modal, setModal] = useState(false);
@@ -28,8 +30,9 @@ const UserEditConnect = ({
const [polochonId, setPolochonId] = useState(initPolochonId);
const [polochonActivated, setPolochonActivated] = useState(initPolochonActivated);
const [password, setPassword] = useState("");
+ const [confirmDelete, setConfirmDelete] = useState(false);
- const handleSubmit = function(e) {
+ const handleSubmit = (e) => {
if (e) { e.preventDefault(); }
updateUser({
userId: id,
@@ -43,6 +46,16 @@ const UserEditConnect = ({
setModal(false);
};
+ const handleDeleteUser = (e) => {
+ if (e) { e.preventDefault(); }
+ if (confirmDelete) {
+ deleteUser(name)
+ setModal(false)
+ } else {
+ setConfirmDelete(true)
+ }
+ }
+
return (
+
+
+
+
);
}
UserEditConnect.propTypes = {
id: PropTypes.string,
+ name: PropTypes.string,
activated: PropTypes.bool,
admin: PropTypes.bool,
- data: PropTypes.object,
updateUser: PropTypes.func,
+ deleteUser: PropTypes.func,
polochonToken: PropTypes.string,
polochonId: PropTypes.string,
polochonActivated: PropTypes.bool,
@@ -101,4 +121,4 @@ const mapStateToProps = (state) => ({
publicPolochons: state.polochon.get("public"),
});
-export const UserEdit = connect(mapStateToProps, {updateUser})(UserEditConnect);
+export const UserEdit = connect(mapStateToProps, {updateUser, deleteUser})(UserEditConnect);
|