Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
20Alexanderxx authored Sep 18, 2023
1 parent 5f5aa0e commit d0cf342
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions frontend/src/components/RegionView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ const RegionView = ({data, open, setOpen, setUpdateMap}) => {
};

const addBuilderToDB = (builder) => {
console.log(builder)
axios.post(`/api/v1/region/${region.id}/additionalBuilder`, {
username: builder.username
}, {headers: {authorization: "Bearer " + keycloak.token}})
Expand Down Expand Up @@ -229,24 +228,20 @@ const RegionView = ({data, open, setOpen, setUpdateMap}) => {
};

const removeBuilderFromDB = (builder) => {
setLoading(true);

axios.delete(`/api/v1/region/${region.id}/additionalBuilder/${builder.id}`, {headers: {authorization: "Bearer " + keycloak.token}})
.then(() => {
showNotification({
title: 'Success',
message: 'Builder removed',
color: "green"
});
setLoading(false);
})
.catch((e) => {
showNotification({
title: 'Failed',
message: 'An unexpected error occurred.',
color: "red"
});
setLoading(false);
});
};

Expand Down Expand Up @@ -285,6 +280,8 @@ const RegionView = ({data, open, setOpen, setUpdateMap}) => {
const owner = document.getElementById('owner')?.value ?? region.username;
const addedBuilders = additionalBuildersArray.filter((item) => !region.additionalBuilder.includes(item));
const removedBuilders = region.additionalBuilder.filter((item) => !additionalBuildersArray.includes(item));
setEditing(false);
setLoading(true);
for (let builder of addedBuilders) {
addBuilderToDB(builder);
}
Expand All @@ -308,8 +305,6 @@ const RegionView = ({data, open, setOpen, setUpdateMap}) => {
alert("User does not exist! Error: " + error);
return;
}
setEditing(false);
setLoading(true);
setUpdateMap(true);
getData();
};
Expand Down

0 comments on commit d0cf342

Please sign in to comment.