Skip to content
Snippets Groups Projects
Commit b362d6a4 authored by AdrianBeilharz's avatar AdrianBeilharz
Browse files

revert to fix bugs

parent b9c09810
No related branches found
No related tags found
No related merge requests found
......@@ -8,8 +8,9 @@ function ApothekeBtmList(props) {
const [btms, setBtms] = useState([]);
const [input, setInput] = useState("");
const getBtms = () => {
fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btmbuchung`,
const getBtms = async () => {
const response = await fetch(
`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btmbuchung`,
{
method: "GET",
headers: {
......@@ -17,26 +18,26 @@ function ApothekeBtmList(props) {
"Bearer " + window.sessionStorage.getItem("edbapo-jwt"),
},
}
).then(response => {
if (response.status === 200) {
setBtms(response.json());
} else if (response.status === 403) {
props.history.push("/forbidden");
} else if (response.status === 400) {
props.history.push("/badrequest");
}
}).catch((err) => {
).catch((err) => {
//SHOW ERROR
return;
});
if (response.status === 200) {
setBtms(await response.json());
} else if (response.status === 403) {
props.history.push("/forbidden");
} else if (response.status === 400) {
props.history.push("/badrequest");
}
};
//wird aufgerufen von NeuesBtmModal wenn ein neues BTM hinzugefügt wurde
props.apothekeRefFunctions.updateBtmList = getBtms;
useEffect(getBtms, [apoId, props.history]);
useEffect(() => {
getBtms();
}, []);
return (
<div className="btm-buchung-wrapper">
......@@ -53,12 +54,11 @@ function ApothekeBtmList(props) {
.filter((val) => {
if (input === "") {
return val;
} else if (val.btm.name.toLowerCase().includes(input.toLowerCase())) {
return val;
} else if (val.btm.name.toLowerCase().includes(input.toLowerCase())){
return val;
}
return null;
})
.map((btm) => (
.map((btm, key) => (
<BuchungTabelle {...props} btm={btm} />
))}
</div>
......
......@@ -15,33 +15,33 @@ function BTMBuch (props) {
const [isLoggedIn, setLoggedIn] = useState(false);
const [aktiveRolle, setAktiveRolle] = useState('');
const getUserDetails = event => {
fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {
const getUserDetails = async event => {
const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"),
}
}).then(response => {
if(response.status === 200) {
let u = response.json();
console.log(JSON.stringify(u))
setUser(u);
setAktiveRolle(u.rolle);
setLoggedIn(true);
}else if(response.status === 403) {
props.history.push('/forbidden');
}else if(response.status === 400){
props.history.push('/badrequest');
}
}).catch((err) => {
//SHOW ERROR
return;
});
if(response.status === 200) {
let u = await response.json();
console.log(JSON.stringify(u))
setUser(u);
setAktiveRolle(u.rolle);
setLoggedIn(true);
}else if(response.status === 403) {
props.history.push('/forbidden');
}else if(response.status === 400){
props.history.push('/badrequest');
}
}
useEffect(getUserDetails, [apoId, props.history])
useEffect(() => {
getUserDetails();
}, [])
//this obj is passed to each child, each child can add functions to this object and call functions from this object
let apothekeRefFunctions = {}
......
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