Skip to content
Snippets Groups Projects
Commit 8507422c authored by Orlando Piñero's avatar Orlando Piñero
Browse files
parents 164797fe 2da3d3fc
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-bootstrap": "^0.26.2",
"react-router-dom": "^6.6.1",
"react-router-dom": "^6.6.2",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"redux-thunk": "^2.4.2",
......@@ -14440,9 +14440,9 @@
}
},
"node_modules/react-router": {
"version": "6.6.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.6.1.tgz",
"integrity": "sha512-YkvlYRusnI/IN0kDtosUCgxqHeulN5je+ew8W+iA1VvFhf86kA+JEI/X/8NqYcr11hCDDp906S+SGMpBheNeYQ==",
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.6.2.tgz",
"integrity": "sha512-uJPG55Pek3orClbURDvfljhqFvMgJRo59Pktywkk8hUUkTY2aRfza8Yhl/vZQXs+TNQyr6tu+uqz/fLxPICOGQ==",
"dependencies": {
"@remix-run/router": "1.2.1"
},
......@@ -14466,12 +14466,12 @@
}
},
"node_modules/react-router-dom": {
"version": "6.6.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.6.1.tgz",
"integrity": "sha512-u+8BKUtelStKbZD5UcY0NY90WOzktrkJJhyhNg7L0APn9t1qJNLowzrM9CHdpB6+rcPt6qQrlkIXsTvhuXP68g==",
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.6.2.tgz",
"integrity": "sha512-6SCDXxRQqW5af8ImOqKza7icmQ47/EMbz572uFjzvcArg3lZ+04PxSPp8qGs+p2Y+q+b+S/AjXv8m8dyLndIIA==",
"dependencies": {
"@remix-run/router": "1.2.1",
"react-router": "6.6.1"
"react-router": "6.6.2"
},
"engines": {
"node": ">=14"
......
......@@ -13,7 +13,7 @@
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-bootstrap": "^0.26.2",
"react-router-dom": "^6.6.1",
"react-router-dom": "^6.6.2",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"redux-thunk": "^2.4.2",
......
......@@ -7,6 +7,7 @@ export const CREATE_NEW_USER_ERROR = 'CREATE_NEW_USER_ERROR';
export const DELETE_USER_SUCCESS = 'DELETE_USER_SUCCESS';
export const DELETE_USER_ERROR = 'DELETE_USER_ERROR';
//Pending, Success, Error Actions
......@@ -70,6 +71,23 @@ export function getCreateNewUserErrorAction(error) {
}
export function getDeleteUserSuccessAction(message) {
console.log("GetDeleteUserSuccessAction")
return {
type: DELETE_USER_SUCCESS,
message: message
}
}
export function getDeleteUserErrorAction(error) {
console.log("GetDeleteUserErrorAction")
return {
type: DELETE_USER_ERROR,
error: error
}
}
//Frontend Connections
......@@ -137,7 +155,24 @@ export function deleteUserWithID(userID, token) {
}
}
export function deleteUserWithUserID(userID, token) {
console.log("deleting user with id: " + userID)
return dispatch => {
dispatch(getDeleteUserSuccessAction());
deleteUser(userID, token)
.then(successMessage => {
const action = getDeleteUserSuccessAction(successMessage);
dispatch(action);
},
error => {
dispatch(getDeleteUserErrorAction(error));
}
).catch(error => {
dispatch(getDeleteUserErrorAction(error));
})
}
}
//Backend Callings
......@@ -156,7 +191,6 @@ export function getAllUsers(token) {
return response.json().then(body => {
if (response.status === 200) {
console.log(body)
console.log("yeah")
return body
}
})
......@@ -188,6 +222,27 @@ export function createNewUser(userData, token) {
})
}
export function deleteUser(userID, token) {
const requestOptions = {
method: 'DELETE',
headers: {
'Authorization': token
}
}
return fetch('https://localhost/api/users/' + userID, requestOptions)
.then(response => {
return response.json().then(body => {
if (response.status === 204) {
console.log(body)
return body
}
})
})
}
export function deleteUser(userID, token) {
console.log("delete user")
console.log(userID)
......
......@@ -32,7 +32,7 @@ class TopMenu extends Component {
render() {
let OpenUserManagementPageButton;
console.log(this.props.isAdmin)
if (this.props.isAdmin) {
if (this.props.isAdmin.isAdministrator) {
OpenUserManagementPageButton = <LinkContainer to="/userManagement" id="OpenUserManagementPageButton" onClick={this.handleUserManagementButtonAction}>
<Nav.Link>User-Management</Nav.Link>
</LinkContainer>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment