diff --git a/frontend/.eslintcache b/frontend/.eslintcache index e94cb4bac895405e514ba5a566f5f06a6716177f..e860332f92b6c67fc7c02cb066be586a0d61cf3a 100644 --- a/frontend/.eslintcache +++ b/frontend/.eslintcache @@ -1 +1 @@ -[{"D:\\dev\\EDB-Apo\\frontend\\src\\index.js":"1","D:\\dev\\EDB-Apo\\frontend\\src\\App.js":"2","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Startseite.js":"3","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BTMBuch.js":"4","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Login.js":"5","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\Header.js":"6","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\StatusHeader.js":"7","D:\\dev\\EDB-Apo\\frontend\\src\\user\\UserDetails.js":"8","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeuesBtmModal.js":"9","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BuchungTabelle.js":"10","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeueBuchungModal.js":"11","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\ApothekeEinstellungen.js":"12","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekenDetails.js":"13","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekeBtmList.js":"14","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\PersonalTabelle.js":"15","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\ArztTabelle.js":"16","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\LieferantTabelle.js":"17","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\BtmTabelle.js":"18","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalAddModal.js":"19","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\DeleteModal.js":"20","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalEditModal.js":"21"},{"size":280,"mtime":1607716944341,"results":"22","hashOfConfig":"23"},{"size":1048,"mtime":1607868492230,"results":"24","hashOfConfig":"23"},{"size":291,"mtime":1607728571901,"results":"25","hashOfConfig":"23"},{"size":2359,"mtime":1607860312906,"results":"26","hashOfConfig":"23"},{"size":1808,"mtime":1607728571901,"results":"27","hashOfConfig":"23"},{"size":206,"mtime":1607728571901,"results":"28","hashOfConfig":"23"},{"size":542,"mtime":1607728571901,"results":"29","hashOfConfig":"23"},{"size":1186,"mtime":1607728571902,"results":"30","hashOfConfig":"23"},{"size":4879,"mtime":1607728571900,"results":"31","hashOfConfig":"23"},{"size":2685,"mtime":1607728571900,"results":"32","hashOfConfig":"23"},{"size":10483,"mtime":1607728571900,"results":"33","hashOfConfig":"23"},{"size":4052,"mtime":1607944227136,"results":"34","hashOfConfig":"23"},{"size":1625,"mtime":1607728571899,"results":"35","hashOfConfig":"23"},{"size":1922,"mtime":1607728571899,"results":"36","hashOfConfig":"23"},{"size":4193,"mtime":1607945014099,"results":"37","hashOfConfig":"23"},{"size":1845,"mtime":1607944222765,"results":"38","hashOfConfig":"23"},{"size":1915,"mtime":1607944210150,"results":"39","hashOfConfig":"23"},{"size":1870,"mtime":1607944218425,"results":"40","hashOfConfig":"23"},{"size":5139,"mtime":1607945102335,"results":"41","hashOfConfig":"23"},{"size":1120,"mtime":1607944232732,"results":"42","hashOfConfig":"23"},{"size":6432,"mtime":1607945038639,"results":"43","hashOfConfig":"23"},{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"19g8awo",{"filePath":"47","messages":"48","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"49","usedDeprecatedRules":"46"},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"52","messages":"53","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"54","usedDeprecatedRules":"46"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"57","usedDeprecatedRules":"46"},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"64","usedDeprecatedRules":"46"},{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"71","usedDeprecatedRules":"72"},{"filePath":"73","messages":"74","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"75","usedDeprecatedRules":"46"},{"filePath":"76","messages":"77","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"78","usedDeprecatedRules":"46"},{"filePath":"79","messages":"80","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"81","usedDeprecatedRules":"46"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"84","usedDeprecatedRules":"46"},{"filePath":"85","messages":"86","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"87","usedDeprecatedRules":"46"},{"filePath":"88","messages":"89","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"90","usedDeprecatedRules":"46"},{"filePath":"91","messages":"92","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"93","usedDeprecatedRules":"46"},{"filePath":"94","messages":"95","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"96","usedDeprecatedRules":"46"},{"filePath":"97","messages":"98","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"99","messages":"100","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"101","usedDeprecatedRules":"46"},"D:\\dev\\EDB-Apo\\frontend\\src\\index.js",[],["102","103"],"D:\\dev\\EDB-Apo\\frontend\\src\\App.js",["104"],"import React from 'react';\r\nimport './App.scss';\r\nimport { BrowserRouter as Router, Switch, Route, Link } from \"react-router-dom\";\r\nimport Startseite from './components/startseite/Startseite';\r\nimport BTMBuch from './components/btmbuch/BTMBuch';\r\nimport ApothekeEinstellungen from './components/apotheke/einstellungen/ApothekeEinstellungen';\r\nimport { SnackbarProvider } from 'notistack';\r\nrequire('dotenv').config()\r\n\r\n// library.add(fab, faCheckSquare, faBookMedical)\r\n\r\nfunction App() {\r\n return (\r\n <React.Fragment>\r\n <SnackbarProvider maxSnack={10} anchorOrigin={{vertical:'bottom', horizontal:'center'}}>\r\n <Router>\r\n <Switch>\r\n <Route path=\"/\" exact component={Startseite} />\r\n <Route path=\"/login\" exact component={Startseite} />\r\n <Route path=\"/apotheke/:id\" exact component={BTMBuch} />\r\n <Route path=\"/apotheke/:id/einstellungen\" exact component={ApothekeEinstellungen} />\r\n </Switch>\r\n </Router>\r\n </SnackbarProvider>\r\n </React.Fragment>);\r\n}\r\n\r\nexport default App;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Startseite.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BTMBuch.js",["105","106"],"import React, { useState, useEffect } from 'react';\r\nimport Header from '../headers/Header'\r\nimport StatusHeader from '../headers/StatusHeader'\r\nimport ApothekenDetails from '../apotheke/ApothekenDetails';\r\nimport UserDetails from '../../user/UserDetails';\r\nimport ApothekeBtmList from '../apotheke/ApothekeBtmList';\r\nimport {Row, Col} from 'react-bootstrap';\r\nimport './BTMBuch.scss'\r\n \r\nfunction BTMBuch (props) {\r\n let paths = props.location.pathname.split(\"/\");\r\n\r\n const [apothekeId, setApothekeId] = useState(paths[paths.length-1])\r\n const [user, setUser] = useState({});\r\n const [isLoggedIn, setLoggedIn] = useState(false);\r\n const [aktiveRolle, setAktiveRolle] = useState('');\r\n\r\n const getUserDetails = async event => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if(response.status === 200) {\r\n let u = await response.json();\r\n console.log(JSON.stringify(u))\r\n setUser(u);\r\n setAktiveRolle(u.rolle);\r\n setLoggedIn(true);\r\n }else if(response.status === 403) {\r\n props.history.push('/forbidden');\r\n }else if(response.status === 400){\r\n props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getUserDetails();\r\n }, [])\r\n\r\n //this obj is passed to each child, each child can add functions to this object and call functions from this object\r\n let apothekeRefFunctions = {}\r\n \r\n return(\r\n <React.Fragment>\r\n {aktiveRolle.toLowerCase() !== 'benutzer' ?<StatusHeader aktiveRolle={aktiveRolle}/> : null}\r\n <Header />\r\n <Row className=\"details-list\">\r\n <Col><ApothekenDetails {...props} apothekeRefFunctions={apothekeRefFunctions} apothekeId={apothekeId}/></Col>\r\n <Col>{isLoggedIn ? <UserDetails {...props} user={user} aktiveRolle={aktiveRolle} setAktiveRolle={setAktiveRolle}/> : null }</Col>\r\n </Row> \r\n <ApothekeBtmList apothekeId={apothekeId} user={user} apothekeRefFunctions={apothekeRefFunctions} {...props}/> \r\n </React.Fragment>\r\n )\r\n}\r\n\r\nexport default BTMBuch;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Login.js",["107"],"import React, { useState } from 'react';\r\nimport {Row, Col, Button, Form,} from 'react-bootstrap';\r\nimport { useForm } from \"react-hook-form\";\r\nimport './Startseite.scss'\r\n\r\n\r\nfunction Login(props) {\r\n const {handleSubmit} = useForm();\r\n const [user, setUser] = useState({username:'', password:''});\r\n \r\n const login = async event => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/login`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n },\r\n body: JSON.stringify({\r\n username: user.username,\r\n password: user.password\r\n })\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n\r\n if(response && response.status === 200){\r\n const data = await response.json();\r\n window.sessionStorage.setItem(\"edbapo-jwt\", data.jwt)\r\n props.history.push(`/apotheke/${data.apothekeId}`);\r\n }\r\n }\r\n\r\n return (\r\n <div className=\"login\">\r\n <b style={{fontSize:'20pt'}}>Login:</b>\r\n <Form onSubmit={handleSubmit(login)} >\r\n <Form.Row>\r\n <Col>\r\n <Form.Control onChange={e => setUser({...user, username: e.target.value})} placeholder=\"Benutzername\" />\r\n <Form.Control onChange={e => setUser({...user, password: e.target.value})} placeholder=\"Passwort\" />\r\n <Button variant=\"primary\" type=\"submit\">Login</Button>\r\n <Button variant=\"primary\" >Neue Apotheke registrieren</Button>\r\n </Col>\r\n </Form.Row>\r\n </Form>\r\n </div>\r\n )\r\n}\r\nexport default Login;","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\Header.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\StatusHeader.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\user\\UserDetails.js",["108","109","110"],"import React from 'react'\r\nimport { Button, Col, Row, Form } from 'react-bootstrap';\r\n\r\nfunction UserDetails(props) {\r\n //eslint disable-next-line\r\n const {rolle, vorname, name, nutzername, aktiv} = props.user;\r\n\r\n var allRoles = {\r\n ADMIN : { 0: \"Admin\", 1 : \"Pruefer\", 2: \"Benutzer\"},\r\n PRUEFER : { 0 : \"Pruefer\", 1: \"Benutzer\"},\r\n BENUTZER : { 0: \"Benutzer\"}\r\n }\r\n\r\n const logout = () => {\r\n window.sessionStorage.removeItem(\"edbapo-jwt\")\r\n props.history.push('/');\r\n }\r\n\r\n return(\r\n <Row>\r\n <Col><b>Nutzername:</b> {nutzername}</Col>\r\n <Col>\r\n <Form.Control as=\"select\" onChange={(event) => props.setAktiveRolle(event.target.value.toUpperCase())}>\r\n {Object.keys(allRoles[rolle]).map( role => <option key={allRoles[rolle][role]} value={allRoles[rolle][role]}>{allRoles[rolle][role]}</option>)}\r\n </Form.Control>\r\n </Col>\r\n <Col>\r\n <Button>Einstellungen</Button>\r\n </Col>\r\n <Col>\r\n <Button onClick={logout}>Logout</Button>\r\n </Col>\r\n </Row>\r\n )\r\n}\r\n\r\nexport default UserDetails;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeuesBtmModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BuchungTabelle.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeueBuchungModal.js",["111","112"],"import React, { useState, useEffect } from 'react';\r\nimport { Modal, Button, Form, Row, Col } from 'react-bootstrap';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction NeueBuchungModal(props) {\r\n \r\n const { enqueueSnackbar } = useSnackbar();\r\n const [typ, setTyp] = useState('');\r\n const [lieferanten, setLieferanten] = useState([]);\r\n const [aerzte, setAerzte] = useState([]);\r\n const [empfaenger, setEmpfaenger] = useState([]);\r\n\r\n const sendNewBuchungAnfrage = async (buchungData) => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/btmbuchung`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n body: JSON.stringify(buchungData)\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n\r\n if (response && response.status === 201) {\r\n const data = await response.json();\r\n // console.log(data);\r\n hideModal();\r\n enqueueSnackbar('Buchung erfolgreich angelegt', { variant:'success', autoHideDuration: 3000} );\r\n props.apothekeRefFunctions.updateBtmList();\r\n } else {\r\n //SHOW ERROR\r\n console.log(response);\r\n }\r\n }\r\n\r\n const createNewBuchung = event => {\r\n event.preventDefault();\r\n if (typ.toLowerCase() === 'zugang') {\r\n let { anforderungsschein, btmMenge, lieferant, pruefdatum } = event.target;\r\n let buchungData = {\r\n benutzer: props.user.id,\r\n btm: props.btm.btm.id,\r\n menge: btmMenge.value,\r\n typ: 'ZUGANG',\r\n lieferant: lieferant.value,\r\n anforderungsschein: anforderungsschein.value,\r\n pruefdatum: pruefdatum.value\r\n }\r\n sendNewBuchungAnfrage(buchungData);\r\n } else if (typ.toLowerCase() === 'abgang') {\r\n let { btmMenge, rezept, empfaenger, arzt, pruefdatum } = event.target;\r\n let buchungData = {\r\n benutzer: props.user.id,\r\n btm: props.btm.btm.id,\r\n menge: btmMenge.value,\r\n typ: 'ABGANG',\r\n empfaenger: empfaenger.value,\r\n arzt: arzt.value,\r\n rezept: rezept.value,\r\n pruefdatum: pruefdatum.value\r\n }\r\n sendNewBuchungAnfrage(buchungData);\r\n }\r\n }\r\n\r\n const hideModal = () => {\r\n setTyp('');\r\n props.onHide();\r\n }\r\n\r\n\r\n const loadLieferanten = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/lieferant`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setLieferanten(await response.json());\r\n console.log(lieferanten);\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n const loadAerzte = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/arzt`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setAerzte(await response.json());\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n const loadEmpfaenger = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/empfaenger`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setEmpfaenger(await response.json());\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n loadLieferanten();\r\n loadAerzte();\r\n loadEmpfaenger();\r\n }, []);\r\n\r\n const renderZugang = () => {\r\n return (\r\n <React.Fragment>\r\n <Form.Group as={Row} controlId=\"anforderungsschein\">\r\n <Form.Label column sm=\"2\">\r\n Anforderungsschein\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"anforderungsschein\" type=\"text\" required />\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"lieferant\">\r\n <Form.Label column sm=\"2\">\r\n Lieferant\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"lieferant\" required as=\"select\">\r\n {lieferanten.map(l => <option key={l.id} value={l.id}>{l.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n </React.Fragment>)\r\n }\r\n\r\n const renderAbgang = () => {\r\n return (\r\n <React.Fragment>\r\n <Form.Group as={Row} controlId=\"empfaenger\">\r\n <Form.Label column sm=\"2\">\r\n Empfaenger\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"empfaenger\" required as=\"select\">\r\n {empfaenger.map(e => <option key={e.id} value={e.id}>{e.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"arzt\">\r\n <Form.Label column sm=\"2\">\r\n Arzt\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"arzt\" required as=\"select\">\r\n {aerzte.map(a => <option key={a.id} value={a.id}>{a.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"rezept\">\r\n <Form.Label column sm=\"2\">\r\n Rezept\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"rezept\" type=\"text\" required />\r\n </Col>\r\n </Form.Group>\r\n </React.Fragment>)\r\n }\r\n\r\n return (\r\n <Modal\r\n {...props}\r\n size=\"lg\"\r\n aria-labelledby=\"contained-modal-title-vcenter\"\r\n centered\r\n onExiting={hideModal}\r\n >\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\">\r\n Betäubungsmittel-Buchung hinzufügen\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Form onSubmit={createNewBuchung}>\r\n <Modal.Body>\r\n <Form.Group as={Row} controlId=\"Typ\">\r\n <Col sm={{ span: 10, offset: 2 }}>\r\n <Row sm={6}>\r\n <Form.Check required\r\n type=\"radio\"\r\n label=\"Zugang\"\r\n name=\"TypRadio\"\r\n id=\"ZugangRadio\"\r\n onClick={() => setTyp('zugang')}\r\n />\r\n <Form.Check required\r\n type=\"radio\"\r\n label=\"Abgang\"\r\n name=\"TypRadio\"\r\n id=\"AbgangRadio\"\r\n onClick={() => setTyp('abgang')}\r\n />\r\n </Row>\r\n </Col>\r\n </Form.Group>\r\n\r\n <Form.Group as={Row} controlId=\"btmMenge\">\r\n <Form.Label column sm=\"2\">\r\n Menge\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"btmMenge\" type=\"number\" min=\"1\" defaultValue=\"0\" />\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"pruefdatum\">\r\n <Form.Label column sm=\"2\">\r\n Prüfdatum\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"pruefdatum\" type=\"date\" defaultValue={new Date()} />\r\n </Col>\r\n </Form.Group>\r\n\r\n {typ.toLowerCase() === 'zugang' ? renderZugang() : null}\r\n {typ.toLowerCase() === 'abgang' ? renderAbgang() : null}\r\n\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button variant=\"danger\" onClick={hideModal}>Close</Button>\r\n <Button variant=\"primary\" type=\"submit\">Bestätigen</Button>\r\n </Modal.Footer>\r\n </Form>\r\n\r\n\r\n\r\n </Modal>\r\n )\r\n\r\n}\r\n\r\nexport default NeueBuchungModal;",["113","114"],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\ApothekeEinstellungen.js",["115"],"import React, { useState, Fragment, useEffect } from 'react';\r\nimport { ListGroup, Button, Row, Col } from 'react-bootstrap';\r\nimport { useParams } from 'react-router-dom';\r\n\r\nimport Header from '../../headers/Header';\r\nimport StatusHeader from '../../headers/StatusHeader';\r\nimport ArztTabelle from './tabellen/ArztTabelle';\r\nimport BtmTabelle from './tabellen/BtmTabelle';\r\nimport LieferantTabelle from './tabellen/LieferantTabelle';\r\nimport PersonalTabelle from './tabellen/PersonalTabelle';\r\n\r\nimport './ApothekeEinstellungen.scss'\r\n\r\nfunction ApothekeEinstellungen(props) {\r\n const { id } = useParams()\r\n\r\n const [apotheke, setApotheke] = useState({ anschrift: {} })\r\n const [activeMenuItem, setActiveMenuItem] = useState('personal');\r\n const [user, setUser] = useState(null);\r\n\r\n\r\n const getCurrentApotheke = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\")\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setApotheke(data))\r\n .catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n })\r\n }\r\n\r\n const getUserData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n })\r\n .then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then(data => setUser(data)\r\n ).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n\r\n const renderContent = () => {\r\n if (activeMenuItem === 'personal') {\r\n return <PersonalTabelle {...props} />;\r\n } else if (activeMenuItem === 'btm') {\r\n return <BtmTabelle {...props} />;\r\n } else if (activeMenuItem === 'aerzte') {\r\n return <ArztTabelle {...props} />\r\n } else if (activeMenuItem === 'lieferanten') {\r\n return <LieferantTabelle {...props} />\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getUserData();\r\n getCurrentApotheke();\r\n }, []);\r\n\r\n return (\r\n <Fragment>\r\n <StatusHeader aktiveRolle=\"admin\" />\r\n <Header />\r\n <div className=\"main-content\">\r\n <Row>\r\n <Col sm={4}>\r\n <ul>\r\n <li>Name: {apotheke.name}</li>\r\n <li>E-Mail: {apotheke.email}</li>\r\n <li>Anschrift: {apotheke.anschrift.strasse} {apotheke.anschrift.nummer} ({apotheke.anschrift.plz} {apotheke.anschrift.ort})</li>\r\n </ul>\r\n <Button>Angaben bearbeiten</Button>\r\n </Col>\r\n </Row>\r\n <Row style={{ marginTop: '3em' }}>\r\n <Col sm={3}>\r\n <ListGroup as=\"ul\" className=\"menu-list\">\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('personal')} active={activeMenuItem === 'personal'}>Pharmazeutisches Personal</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('btm')} active={activeMenuItem === 'btm'}>Betäubungsmittel</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('aerzte')} active={activeMenuItem === 'aerzte'}>Ärzte</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('lieferanten')} active={activeMenuItem === 'lieferanten'}>Lieferanten</ListGroup.Item>\r\n </ListGroup>\r\n </Col>\r\n <Col sm={8}>\r\n {user ? renderContent() : null}\r\n </Col>\r\n </Row>\r\n </div>\r\n\r\n\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default ApothekeEinstellungen;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekenDetails.js",["116","117"],"import React, { Fragment, useEffect, useState } from \"react\";\r\nimport { Button } from \"react-bootstrap\";\r\nimport NeuesBtmModal from '../btmbuch/NeuesBtmModal';\r\nimport '../../App.scss'\r\n\r\nfunction ApothekenDetails(props) {\r\n const[apotheke, setApotheke] = useState({anschrift:{}});\r\n const[neuesBtmModalShow, setneuesBtmModalShow] = useState(false);\r\n\r\n\r\n const getApothekeData = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.match.params.id}`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if(response.status === 200){\r\n setApotheke(await response.json());\r\n }else if(response.status === 403) {\r\n props.history.push('/forbidden');\r\n }else if(response.status === 400){\r\n props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getApothekeData();\r\n }, [])\r\n\r\n return(\r\n <div className=\"apo-details\">\r\n <ul>\r\n <li>Name: {apotheke.name}</li>\r\n <li>E-Mail: {apotheke.email}</li> \r\n </ul>\r\n <Button>Apotheke Einstellungen</Button>\r\n <Button onClick={() => setneuesBtmModalShow(true)} style={{marginLeft:'1em'}}>Neues Betäubungsmittel anlegen</Button>\r\n <NeuesBtmModal show={neuesBtmModalShow} {...props} onHide={() => setneuesBtmModalShow(false)} /> \r\n </div>\r\n )\r\n}\r\nexport default ApothekenDetails;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekeBtmList.js",["118","119","120"],"import React, { useState, useEffect } from \"react\";\r\nimport { FormControl } from \"react-bootstrap\";\r\nimport BuchungTabelle from \"../btmbuch/BuchungTabelle\";\r\n\r\nfunction ApothekeBtmList(props) {\r\n const [btms, setBtms] = useState([]);\r\n const [input, setInput] = useState(\"\");\r\n\r\n const getBtms = async () => {\r\n const response = await fetch(\r\n `http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.match.params.id}/btmbuchung`,\r\n {\r\n method: \"GET\",\r\n headers: {\r\n Authorization:\r\n \"Bearer \" + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }\r\n ).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if (response.status === 200) {\r\n setBtms(await response.json());\r\n } else if (response.status === 403) {\r\n props.history.push(\"/forbidden\");\r\n } else if (response.status === 400) {\r\n props.history.push(\"/badrequest\");\r\n }\r\n };\r\n\r\n //wird aufgerufen von NeuesBtmModal wenn ein neues BTM hinzugefügt wurde\r\n props.apothekeRefFunctions.updateBtmList = getBtms;\r\n\r\n useEffect(() => {\r\n getBtms();\r\n }, []);\r\n\r\n return (\r\n <div className=\"btm-buchung-wrapper\">\r\n <input\r\n id=\"searchBtmField\"\r\n type=\"text\"\r\n placeholder=\"Betäubungsmittel suchen\"\r\n onChange={(event) => {\r\n setInput(event.target.value);\r\n }}\r\n value={input}\r\n />\r\n {btms\r\n .filter((val) => {\r\n if (input === \"\") {\r\n console.log(\"namen der Liste\", val.btm.name);\r\n return val;\r\n } else if (val.btm.name.toLowerCase().includes(input.toLowerCase())){\r\n return val;\r\n }\r\n })\r\n .map((btm, key) => (\r\n <BuchungTabelle {...props} btm={btm} />\r\n ))}\r\n </div>\r\n );\r\n}\r\n\r\nexport default ApothekeBtmList;\r\n\r\n/*{btms.map(btm => <BuchungTabelle {...props} btm={btm} /> )}*/\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\PersonalTabelle.js",["121"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { AddBox, Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\n\r\nimport PersonalAddModal from '../../../../modals/PersonalAddModal';\r\nimport PersonalEditModal from '../../../../modals/PersonalEditModal';\r\nimport DeleteModal from '../../../../modals/DeleteModal';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction PersonalTabelle(props) {\r\n const { id } = useParams();\r\n const [personal, setPersonal] = useState([]);\r\n const { enqueueSnackbar } = useSnackbar();\r\n const [selectedUser, setSelectedUser] = useState(null);\r\n const [showPersonalAddModal, setShowPersonalAddModal] = useState(false);\r\n const [showPersonalEditModal, setShowPersonalEditModal] = useState(false);\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n\r\n\r\n\r\n const getPersonalData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setPersonal(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n const deleteUser = async () => {\r\n console.log(\"user should get deleted\");\r\n fetch(`http://${process.env.REACT_APP_BACKEND_HOSTNAME}/apotheke/${id}/benutzer/${selectedUser.id}`, {\r\n method: 'DELETE',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }).then((res) => {\r\n if (res && res.status === 200) {\r\n props.updateUserList();\r\n enqueueSnackbar('Benutzer erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 });\r\n } else {\r\n //SHOW ERROR\r\n console.log(res);\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n\r\n }\r\n\r\n const del = user => {\r\n setSelectedUser(user);\r\n setShowDeleteModal(true);\r\n }\r\n const edit = user => {\r\n setSelectedUser(user);\r\n setShowPersonalEditModal(true);\r\n }\r\n\r\n useEffect(() => {\r\n getPersonalData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <PersonalAddModal {...props} show={showPersonalAddModal} onHide={() => setShowPersonalAddModal(false)} />\r\n {selectedUser ? <PersonalEditModal {...props} user={selectedUser} show={showPersonalEditModal} onHide={() => setShowPersonalEditModal(false)} /> : null}\r\n <DeleteModal {...props} headertext={'Benutzer löschen'}\r\n maintext={'Möchtest du diesen Benutzer wirklich löschen?'} onSubmit={deleteUser} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'}\r\n show={showDeleteModal} onHide={() => setShowDeleteModal(false)} />\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Nutzername</th>\r\n <th>Nachname</th>\r\n <th>Vorname</th>\r\n <th>Aktiv</th>\r\n <th>Rolle</th>\r\n <th style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => setShowPersonalAddModal(true)} >Hinzufügen <AddBox /></Button>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {personal.map(user =>\r\n <tr key={user.id}>\r\n <td>{user.nutzername}</td>\r\n <td>{user.name}</td>\r\n <td>{user.vorname}</td>\r\n <td>{user.aktiv ? 'ja' : 'nein'}</td>\r\n <td>{user.rolle}</td>\r\n <td style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => edit(user)}><Edit /></Button>\r\n <Button onClick={() => del(user)}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default PersonalTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\ArztTabelle.js",["122"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\n\r\nimport { Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\n\r\nfunction ArztTabelle(props) {\r\n const { id } = useParams();\r\n const [aerzte, setAerzte] = useState([]);\r\n\r\n const getPersonalData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/arzt`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setAerzte(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n getPersonalData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Strasse</th>\r\n <th>Ort</th>\r\n <th>Aktionen</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {aerzte.map(arzt =>\r\n <tr key={arzt.id}>\r\n <td>{arzt.name}</td>\r\n <td>{arzt.anschrift.strasse} {arzt.anschrift.nummer}</td>\r\n <td>{arzt.anschrift.plz} {arzt.anschrift.ort}</td>\r\n <td>\r\n <Button onClick={() => console.log(\"update\")}><Edit /></Button>\r\n <Button onClick={() => console.log(\"delete\")}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default ArztTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\LieferantTabelle.js",["123"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\n\r\nimport { Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\n\r\nfunction LieferantTabelle(props) {\r\n const { id } = useParams();\r\n const [lieferanten, setLieferanten] = useState([]);\r\n\r\n const getPersonalData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/lieferant`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setLieferanten(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n getPersonalData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Strasse</th>\r\n <th>Ort</th>\r\n <th>Aktionen</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {lieferanten.map(lieferant =>\r\n <tr key={lieferant.id}>\r\n <td>{lieferant.name}</td>\r\n <td>{lieferant.anschrift.strasse} {lieferant.anschrift.nummer}</td>\r\n <td>{lieferant.anschrift.plz} {lieferant.anschrift.ort}</td>\r\n <td>\r\n <Button onClick={() => console.log(\"update\")}><Edit /></Button>\r\n <Button onClick={() => console.log(\"delete\")}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default LieferantTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\BtmTabelle.js",["124"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\n\r\nimport { Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\n\r\nfunction BtmTabelle(props) {\r\n const { id } = useParams();\r\n const [btmListe, setBtmListe] = useState([]);\r\n\r\n const getPersonalData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/btm`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setBtmListe(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n getPersonalData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Darreichungsform</th>\r\n <th>Einheit</th>\r\n <th>Menge</th>\r\n <th>Aktionen</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {btmListe.map(btm =>\r\n <tr key={btm.id}>\r\n <td>{btm.name}</td>\r\n <td>{btm.darreichungsform}</td>\r\n <td>{btm.einheit}</td>\r\n <td>{btm.menge}</td>\r\n <td>\r\n <Button onClick={() => console.log(\"update\")}><Edit /></Button>\r\n <Button onClick={() => console.log(\"delete\")}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default BtmTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalAddModal.js",["125"],"import React, { useState, useEffect } from 'react';\r\nimport { Modal, Col, Button, Form } from 'react-bootstrap';\r\nimport { useParams } from 'react-router-dom';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction PersonalAddModal(props) {\r\n\r\n const { id } = useParams();\r\n\r\n const [nutzernameVergeben, setNutzernameVergeben] = useState(false);\r\n\r\n //for password checking\r\n const [passwordConfirmInvalid, setPasswordConfirmInvalid] = useState(false);\r\n const [newPasswordVal, setNewPasswordVal] = useState('');\r\n const [passwordConfirmVal, setPasswordConfirmVal] = useState('');\r\n\r\n const { enqueueSnackbar } = useSnackbar();\r\n\r\n let roles = [\"ADMIN\", \"PRUEFER\", \"BENUTZER\"];\r\n\r\n const createNewUser = async event => {\r\n event.preventDefault();\r\n let { username, vorname, nachname, neuesPasswort, rolle } = event.target;\r\n\r\n let body = {\r\n name: nachname.value,\r\n nutzername: username.value,\r\n vorname: vorname.value,\r\n aktiv: true,\r\n rolle: rolle.value,\r\n passwort: neuesPasswort.value\r\n }\r\n\r\n console.log(body)\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n body: JSON.stringify(body)\r\n }).then((res) => {\r\n if (res.status === 201) {\r\n props.onHide();\r\n props.updateUserList();\r\n enqueueSnackbar('Benutzer erstellt', { variant: 'success', autoHideDuration: 3000 });\r\n } else if (res.status === 400) {\r\n enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 });\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n }\r\n\r\n const checkIfUserNameIsTaken = async event => {\r\n let newUsername = event.target.value;\r\n if (newUsername.length < 4) {\r\n //if shorter than 4 its invalid\r\n setNutzernameVergeben(true);\r\n return;\r\n }\r\n\r\n await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer/${newUsername}/checkUsername`, {\r\n method: 'POST',\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n setNutzernameVergeben(false);\r\n } else if (res.status === 400) {\r\n setNutzernameVergeben(true);\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n setPasswordConfirmInvalid(newPasswordVal !== passwordConfirmVal);\r\n }, [newPasswordVal, passwordConfirmVal]);\r\n\r\n\r\n return (\r\n <Modal\r\n {...props}\r\n size=\"lg\"\r\n aria-labelledby=\"contained-modal-title-vcenter\"\r\n centered\r\n onExiting={props.onHide}\r\n >\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\">\r\n Benutzer Einstellungen\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Form onSubmit={createNewUser}>\r\n <Modal.Body>\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"username\">\r\n <Form.Label>Benutzername</Form.Label>\r\n <Form.Control name=\"username\" required onChange={checkIfUserNameIsTaken}\r\n isInvalid={nutzernameVergeben} type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} sm={4} controlId=\"vorname\">\r\n <Form.Label>Vorname</Form.Label>\r\n <Form.Control name=\"vorname\" required type=\"text\" />\r\n </Form.Group>\r\n\r\n <Form.Group as={Col} sm={8} controlId=\"nachname\">\r\n <Form.Label>Nachname</Form.Label>\r\n <Form.Control name=\"nachname\" required type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"neuesPasswort\">\r\n <Form.Label>Neues Passwort</Form.Label>\r\n <Form.Control required minlength={5} onChange={event => setNewPasswordVal(event.target.value)} name=\"neuesPasswort\" type=\"password\" />\r\n </Form.Group>\r\n <Form.Group as={Col} controlId=\"neuesPasswortConfirm\">\r\n <Form.Label>Neues Passwort bestätigen</Form.Label>\r\n <Form.Control required minlength={5} onChange={event => setPasswordConfirmVal(event.target.value)} isInvalid={passwordConfirmInvalid} name=\"neuesPasswortConfirm\" type=\"password\" />\r\n </Form.Group>\r\n </Form.Row>\r\n <Form.Row>\r\n <Form.Group as={Col} sm={4} controlId=\"rolle\">\r\n <Form.Label>Rolle</Form.Label>\r\n <Form.Control required name=\"rolle\" required as=\"select\" >\r\n {roles.map(r => <option key={r} value={r}>{r}</option>)}\r\n </Form.Control>\r\n </Form.Group>\r\n </Form.Row>\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button autofocus variant=\"\" onClick={props.onHide}>Abbrechen</Button>\r\n <Button variant=\"primary\" type=\"submit\" >Bestätigen</Button>\r\n </Modal.Footer>\r\n </Form>\r\n </Modal>\r\n )\r\n}\r\n\r\nexport default PersonalAddModal;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\DeleteModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalEditModal.js",["126"],"import React, { useState, useEffect } from 'react';\r\nimport { Modal, Col, Button, Form, OverlayTrigger, Row, Tooltip } from 'react-bootstrap';\r\nimport { useParams } from 'react-router-dom';\r\nimport HelpIcon from '@material-ui/icons/Help';\r\nimport { Checkbox } from '@material-ui/core';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction PersonalUpdateModal(props) {\r\n\r\n const { id } = useParams();\r\n\r\n let { nutzername, name, vorname, aktiv, rolle } = props.user;\r\n const [nutzernameVergeben, setNutzernameVergeben] = useState(false);\r\n\r\n //for password checking\r\n const [passwordConfirmInvalid, setPasswordConfirmInvalid] = useState(false);\r\n const [newPasswordVal, setNewPasswordVal] = useState('');\r\n const [passwordConfirmVal, setPasswordConfirmVal] = useState('');\r\n\r\n const { enqueueSnackbar } = useSnackbar();\r\n\r\n let roles = [\"ADMIN\", \"PRUEFER\", \"BENUTZER\"];\r\n\r\n\r\n const updateDetails = async event => {\r\n event.preventDefault();\r\n let { username, vorname, nachname, neuesPasswort, rolle, aktiv } = event.target;\r\n\r\n let body = {\r\n name: nachname.value,\r\n nutzername: username.value,\r\n vorname: vorname.value,\r\n aktiv: aktiv.checked,\r\n rolle: rolle.value\r\n }\r\n if (neuesPasswort.value) {\r\n body.newPassword = neuesPasswort.value;\r\n }\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer/${props.user.id}`, {\r\n method: 'PUT',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n body: JSON.stringify(body)\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n props.onHide();\r\n props.updateUserList();\r\n enqueueSnackbar('Benutzer aktualisiert', { variant: 'success', autoHideDuration: 3000 });\r\n } else if (res.status === 400) {\r\n enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 });\r\n } else if (res.status === 403) {\r\n enqueueSnackbar('Falsches Passwort', { variant: 'error', autoHideDuration: 3000 });\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n }\r\n\r\n const checkIfUserNameIsTaken = async event => {\r\n let newUsername = event.target.value;\r\n if (newUsername.length < 4) {\r\n //if shorter than 4 its invalid\r\n setNutzernameVergeben(true);\r\n return;\r\n }\r\n\r\n if (newUsername !== nutzername && newUsername) {\r\n await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer/${newUsername}/checkUsername`, {\r\n method: 'POST',\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n setNutzernameVergeben(false);\r\n } else if (res.status === 400) {\r\n setNutzernameVergeben(true);\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n\r\n } else {\r\n setNutzernameVergeben(false);\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n setPasswordConfirmInvalid(newPasswordVal !== passwordConfirmVal);\r\n }, [newPasswordVal, passwordConfirmVal]);\r\n\r\n\r\n return (\r\n <Modal\r\n {...props}\r\n size=\"lg\"\r\n aria-labelledby=\"contained-modal-title-vcenter\"\r\n centered\r\n onExiting={props.onHide}\r\n >\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\">\r\n Benutzer Einstellungen\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Form onSubmit={updateDetails}>\r\n <Modal.Body>\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"username\">\r\n <Form.Label>Benutzername</Form.Label>\r\n <Form.Control name=\"username\" required onChange={checkIfUserNameIsTaken}\r\n isInvalid={nutzernameVergeben} defaultValue={nutzername} type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} sm={4} controlId=\"vorname\">\r\n <Form.Label>Vorname</Form.Label>\r\n <Form.Control name=\"vorname\" required defaultValue={vorname} type=\"text\" />\r\n </Form.Group>\r\n\r\n <Form.Group as={Col} sm={8} controlId=\"nachname\">\r\n <Form.Label>Nachname</Form.Label>\r\n <Form.Control name=\"nachname\" required defaultValue={name} type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"neuesPasswort\">\r\n <Form.Label>Neues Passwort</Form.Label>\r\n <Form.Control minlength={5} onChange={event => setNewPasswordVal(event.target.value)} name=\"neuesPasswort\" type=\"password\" />\r\n </Form.Group>\r\n <Form.Group as={Col} controlId=\"neuesPasswortConfirm\">\r\n <Form.Label>Neues Passwort bestätigen</Form.Label>\r\n <Form.Control minlength={5} onChange={event => setPasswordConfirmVal(event.target.value)} isInvalid={passwordConfirmInvalid} name=\"neuesPasswortConfirm\" type=\"password\" />\r\n </Form.Group>\r\n </Form.Row>\r\n <Form.Group style={{ marginLeft: '1em' }} controlId=\"aktiv\">\r\n <Row style={{ alignItems: 'center' }} >\r\n <Form.Label>Aktiv</Form.Label>\r\n <Checkbox defaultChecked={aktiv} type=\"checkbox\" name=\"aktiv\" />\r\n <OverlayTrigger\r\n placement=\"right\"\r\n delay={{ show: 250, hide: 400 }}\r\n overlay={props => <Tooltip id=\"button-tooltip\" {...props}>Ein inaktiver Benutzer ist gesperrt und kann sich nicht einloggen</Tooltip>}\r\n >\r\n <HelpIcon style={{ marginLeft: '0.3em' }} />\r\n </OverlayTrigger>\r\n\r\n\r\n <Form.Group style={{ marginLeft: '3.5em' }} as={Col} sm={4} controlId=\"rolle\">\r\n <Form.Label>Rolle</Form.Label>\r\n <Form.Control name=\"rolle\" required as=\"select\" defaultValue={rolle}>\r\n {roles.map(r => <option key={r} value={r}>{r}</option>)}\r\n </Form.Control>\r\n </Form.Group>\r\n </Row>\r\n </Form.Group>\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button autofocus variant=\"\" onClick={props.onHide}>Abbrechen</Button>\r\n <Button variant=\"primary\" type=\"submit\" >Bestätigen</Button>\r\n </Modal.Footer>\r\n </Form>\r\n </Modal>\r\n )\r\n}\r\n\r\nexport default PersonalUpdateModal;\r\n",{"ruleId":"127","replacedBy":"128"},{"ruleId":"129","replacedBy":"130"},{"ruleId":"131","severity":1,"message":"132","line":3,"column":50,"nodeType":"133","messageId":"134","endLine":3,"endColumn":54},{"ruleId":"131","severity":1,"message":"135","line":13,"column":22,"nodeType":"133","messageId":"134","endLine":13,"endColumn":35},{"ruleId":"136","severity":1,"message":"137","line":44,"column":6,"nodeType":"138","endLine":44,"endColumn":8,"suggestions":"139"},{"ruleId":"131","severity":1,"message":"140","line":2,"column":9,"nodeType":"133","messageId":"134","endLine":2,"endColumn":12},{"ruleId":"131","severity":1,"message":"141","line":6,"column":18,"nodeType":"133","messageId":"134","endLine":6,"endColumn":25},{"ruleId":"131","severity":1,"message":"142","line":6,"column":27,"nodeType":"133","messageId":"134","endLine":6,"endColumn":31},{"ruleId":"131","severity":1,"message":"143","line":6,"column":45,"nodeType":"133","messageId":"134","endLine":6,"endColumn":50},{"ruleId":"131","severity":1,"message":"144","line":28,"column":19,"nodeType":"133","messageId":"134","endLine":28,"endColumn":23},{"ruleId":"136","severity":1,"message":"145","line":143,"column":8,"nodeType":"138","endLine":143,"endColumn":10,"suggestions":"146"},{"ruleId":"127","replacedBy":"147"},{"ruleId":"129","replacedBy":"148"},{"ruleId":"136","severity":1,"message":"149","line":81,"column":6,"nodeType":"138","endLine":81,"endColumn":8,"suggestions":"150"},{"ruleId":"131","severity":1,"message":"151","line":1,"column":17,"nodeType":"133","messageId":"134","endLine":1,"endColumn":25},{"ruleId":"136","severity":1,"message":"152","line":33,"column":6,"nodeType":"138","endLine":33,"endColumn":8,"suggestions":"153"},{"ruleId":"131","severity":1,"message":"154","line":2,"column":10,"nodeType":"133","messageId":"134","endLine":2,"endColumn":21},{"ruleId":"136","severity":1,"message":"155","line":38,"column":6,"nodeType":"138","endLine":38,"endColumn":8,"suggestions":"156"},{"ruleId":"157","severity":1,"message":"158","line":52,"column":23,"nodeType":"159","messageId":"160","endLine":52,"endColumn":25},{"ruleId":"136","severity":1,"message":"161","line":76,"column":6,"nodeType":"138","endLine":76,"endColumn":8,"suggestions":"162"},{"ruleId":"136","severity":1,"message":"161","line":33,"column":6,"nodeType":"138","endLine":33,"endColumn":8,"suggestions":"163"},{"ruleId":"136","severity":1,"message":"161","line":33,"column":6,"nodeType":"138","endLine":33,"endColumn":8,"suggestions":"164"},{"ruleId":"136","severity":1,"message":"161","line":33,"column":6,"nodeType":"138","endLine":33,"endColumn":8,"suggestions":"165"},{"ruleId":"166","severity":1,"message":"167","line":131,"column":51,"nodeType":"168","endLine":131,"endColumn":59},{"ruleId":"131","severity":1,"message":"169","line":39,"column":11,"nodeType":"133","messageId":"134","endLine":39,"endColumn":19},"no-native-reassign",["170"],"no-negated-in-lhs",["171"],"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'setApothekeId' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getUserDetails'. Either include it or remove the dependency array.","ArrayExpression",["172"],"'Row' is defined but never used.","'vorname' is assigned a value but never used.","'name' is assigned a value but never used.","'aktiv' is assigned a value but never used.","'data' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'loadAerzte', 'loadEmpfaenger', and 'loadLieferanten'. Either include them or remove the dependency array.",["173"],["170"],["171"],"React Hook useEffect has missing dependencies: 'getCurrentApotheke' and 'getUserData'. Either include them or remove the dependency array.",["174"],"'Fragment' is defined but never used.","React Hook useEffect has a missing dependency: 'getApothekeData'. Either include it or remove the dependency array.",["175"],"'FormControl' is defined but never used.","React Hook useEffect has a missing dependency: 'getBtms'. Either include it or remove the dependency array.",["176"],"array-callback-return","Array.prototype.filter() expects a value to be returned at the end of arrow function.","ArrowFunctionExpression","expectedAtEnd","React Hook useEffect has a missing dependency: 'getPersonalData'. Either include it or remove the dependency array.",["177"],["178"],["179"],["180"],"react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'response' is assigned a value but never used.","no-global-assign","no-unsafe-negation",{"desc":"181","fix":"182"},{"desc":"183","fix":"184"},{"desc":"185","fix":"186"},{"desc":"187","fix":"188"},{"desc":"189","fix":"190"},{"desc":"191","fix":"192"},{"desc":"191","fix":"193"},{"desc":"191","fix":"194"},{"desc":"191","fix":"195"},"Update the dependencies array to be: [getUserDetails]",{"range":"196","text":"197"},"Update the dependencies array to be: [loadAerzte, loadEmpfaenger, loadLieferanten]",{"range":"198","text":"199"},"Update the dependencies array to be: [getCurrentApotheke, getUserData]",{"range":"200","text":"201"},"Update the dependencies array to be: [getApothekeData]",{"range":"202","text":"203"},"Update the dependencies array to be: [getBtms]",{"range":"204","text":"205"},"Update the dependencies array to be: [getPersonalData]",{"range":"206","text":"207"},{"range":"208","text":"207"},{"range":"209","text":"207"},{"range":"210","text":"207"},[1519,1521],"[getUserDetails]",[5207,5209],"[loadAerzte, loadEmpfaenger, loadLieferanten]",[2544,2546],"[getCurrentApotheke, getUserData]",[1077,1079],"[getApothekeData]",[1122,1124],"[getBtms]",[2472,2474],"[getPersonalData]",[1000,1002],[1025,1027],[1004,1006]] \ No newline at end of file +[{"D:\\dev\\EDB-Apo\\frontend\\src\\index.js":"1","D:\\dev\\EDB-Apo\\frontend\\src\\App.js":"2","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Startseite.js":"3","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BTMBuch.js":"4","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Login.js":"5","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\Header.js":"6","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\StatusHeader.js":"7","D:\\dev\\EDB-Apo\\frontend\\src\\user\\UserDetails.js":"8","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeuesBtmModal.js":"9","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BuchungTabelle.js":"10","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeueBuchungModal.js":"11","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\ApothekeEinstellungen.js":"12","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekenDetails.js":"13","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekeBtmList.js":"14","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\PersonalTabelle.js":"15","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\ArztTabelle.js":"16","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\LieferantTabelle.js":"17","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\BtmTabelle.js":"18","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalAddModal.js":"19","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\DeleteModal.js":"20","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalEditModal.js":"21","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\BtmAddModal.js":"22","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\LieferantEditModal.js":"23","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\BtmEditModal.js":"24","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\ArztEditModal.js":"25","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\LieferantAddModal.js":"26","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\ArztAddModal.js":"27"},{"size":280,"mtime":1607716944341,"results":"28","hashOfConfig":"29"},{"size":1051,"mtime":1607960761970,"results":"30","hashOfConfig":"29"},{"size":291,"mtime":1607953306893,"results":"31","hashOfConfig":"29"},{"size":2359,"mtime":1607960985786,"results":"32","hashOfConfig":"29"},{"size":1808,"mtime":1607953306893,"results":"33","hashOfConfig":"29"},{"size":206,"mtime":1607953306892,"results":"34","hashOfConfig":"29"},{"size":542,"mtime":1607953306893,"results":"35","hashOfConfig":"29"},{"size":1186,"mtime":1607953306895,"results":"36","hashOfConfig":"29"},{"size":4879,"mtime":1607953306892,"results":"37","hashOfConfig":"29"},{"size":2685,"mtime":1607953306892,"results":"38","hashOfConfig":"29"},{"size":10483,"mtime":1607953306892,"results":"39","hashOfConfig":"29"},{"size":4058,"mtime":1607959343862,"results":"40","hashOfConfig":"29"},{"size":1625,"mtime":1607953306888,"results":"41","hashOfConfig":"29"},{"size":1922,"mtime":1607953306888,"results":"42","hashOfConfig":"29"},{"size":4203,"mtime":1607961925919,"results":"43","hashOfConfig":"29"},{"size":3969,"mtime":1607961881960,"results":"44","hashOfConfig":"29"},{"size":4253,"mtime":1607961900285,"results":"45","hashOfConfig":"29"},{"size":3950,"mtime":1607961867240,"results":"46","hashOfConfig":"29"},{"size":5148,"mtime":1607960265353,"results":"47","hashOfConfig":"29"},{"size":1120,"mtime":1607953306894,"results":"48","hashOfConfig":"29"},{"size":6408,"mtime":1607959739756,"results":"49","hashOfConfig":"29"},{"size":4523,"mtime":1607962038625,"results":"50","hashOfConfig":"29"},{"size":3550,"mtime":1607962090493,"results":"51","hashOfConfig":"29"},{"size":5656,"mtime":1607962116356,"results":"52","hashOfConfig":"29"},{"size":3524,"mtime":1607961980595,"results":"53","hashOfConfig":"29"},{"size":3227,"mtime":1607962079335,"results":"54","hashOfConfig":"29"},{"size":3186,"mtime":1607962362264,"results":"55","hashOfConfig":"29"},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},"19g8awo",{"filePath":"59","messages":"60","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"61","usedDeprecatedRules":"58"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"66","usedDeprecatedRules":"58"},{"filePath":"67","messages":"68","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"69","usedDeprecatedRules":"58"},{"filePath":"70","messages":"71","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"74","messages":"75","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"76","usedDeprecatedRules":"58"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"81","messages":"82","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"83","usedDeprecatedRules":"58"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"86","usedDeprecatedRules":"58"},{"filePath":"87","messages":"88","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"89","usedDeprecatedRules":"58"},{"filePath":"90","messages":"91","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"92","usedDeprecatedRules":"58"},{"filePath":"93","messages":"94","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"95","usedDeprecatedRules":"58"},{"filePath":"96","messages":"97","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"98","usedDeprecatedRules":"58"},{"filePath":"99","messages":"100","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"101","usedDeprecatedRules":"58"},{"filePath":"102","messages":"103","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"104","usedDeprecatedRules":"58"},{"filePath":"105","messages":"106","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"107","usedDeprecatedRules":"58"},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"116","messages":"117","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"118","messages":"119","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"120","messages":"121","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"58"},{"filePath":"122","messages":"123","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"D:\\dev\\EDB-Apo\\frontend\\src\\index.js",[],["124","125"],"D:\\dev\\EDB-Apo\\frontend\\src\\App.js",["126"],"import React from 'react';\r\nimport './App.scss';\r\nimport { BrowserRouter as Router, Switch, Route, Link } from \"react-router-dom\";\r\nimport Startseite from './components/startseite/Startseite';\r\nimport BTMBuch from './components/btmbuch/BTMBuch';\r\nimport ApothekeEinstellungen from './components/apotheke/einstellungen/ApothekeEinstellungen';\r\nimport { SnackbarProvider } from 'notistack';\r\nrequire('dotenv').config()\r\n\r\n// library.add(fab, faCheckSquare, faBookMedical)\r\n\r\nfunction App() {\r\n return (\r\n <React.Fragment>\r\n <SnackbarProvider maxSnack={10} anchorOrigin={{vertical:'bottom', horizontal:'center'}}>\r\n <Router>\r\n <Switch>\r\n <Route path=\"/\" exact component={Startseite} />\r\n <Route path=\"/login\" exact component={Startseite} />\r\n <Route path=\"/apotheke/:id\" exact component={BTMBuch} />\r\n <Route path=\"/apotheke/:apoId/einstellungen\" exact component={ApothekeEinstellungen} />\r\n </Switch>\r\n </Router>\r\n </SnackbarProvider>\r\n </React.Fragment>);\r\n}\r\n\r\nexport default App;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Startseite.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BTMBuch.js",["127","128"],"import React, { useState, useEffect } from 'react';\r\nimport Header from '../headers/Header'\r\nimport StatusHeader from '../headers/StatusHeader'\r\nimport ApothekenDetails from '../apotheke/ApothekenDetails';\r\nimport UserDetails from '../../user/UserDetails';\r\nimport ApothekeBtmList from '../apotheke/ApothekeBtmList';\r\nimport {Row, Col} from 'react-bootstrap';\r\nimport './BTMBuch.scss'\r\n \r\nfunction BTMBuch (props) {\r\n let paths = props.location.pathname.split(\"/\");\r\n\r\n const [apothekeId, setApothekeId] = useState(paths[paths.length-1])\r\n const [user, setUser] = useState({});\r\n const [isLoggedIn, setLoggedIn] = useState(false);\r\n const [aktiveRolle, setAktiveRolle] = useState('');\r\n\r\n const getUserDetails = async event => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if(response.status === 200) {\r\n let u = await response.json();\r\n console.log(JSON.stringify(u))\r\n setUser(u);\r\n setAktiveRolle(u.rolle);\r\n setLoggedIn(true);\r\n }else if(response.status === 403) {\r\n props.history.push('/forbidden');\r\n }else if(response.status === 400){\r\n props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getUserDetails();\r\n }, [])\r\n\r\n //this obj is passed to each child, each child can add functions to this object and call functions from this object\r\n let apothekeRefFunctions = {}\r\n \r\n return(\r\n <React.Fragment>\r\n {aktiveRolle.toLowerCase() !== 'benutzer' ?<StatusHeader aktiveRolle={aktiveRolle}/> : null}\r\n <Header />\r\n <Row className=\"details-list\">\r\n <Col><ApothekenDetails {...props} apothekeRefFunctions={apothekeRefFunctions} apothekeId={apothekeId}/></Col>\r\n <Col>{isLoggedIn ? <UserDetails {...props} user={user} aktiveRolle={aktiveRolle} setAktiveRolle={setAktiveRolle}/> : null }</Col>\r\n </Row> \r\n <ApothekeBtmList apothekeId={apothekeId} user={user} apothekeRefFunctions={apothekeRefFunctions} {...props}/> \r\n </React.Fragment>\r\n )\r\n}\r\n\r\nexport default BTMBuch;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\startseite\\Login.js",["129"],"import React, { useState } from 'react';\r\nimport {Row, Col, Button, Form,} from 'react-bootstrap';\r\nimport { useForm } from \"react-hook-form\";\r\nimport './Startseite.scss'\r\n\r\n\r\nfunction Login(props) {\r\n const {handleSubmit} = useForm();\r\n const [user, setUser] = useState({username:'', password:''});\r\n \r\n const login = async event => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/login`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n },\r\n body: JSON.stringify({\r\n username: user.username,\r\n password: user.password\r\n })\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n\r\n if(response && response.status === 200){\r\n const data = await response.json();\r\n window.sessionStorage.setItem(\"edbapo-jwt\", data.jwt)\r\n props.history.push(`/apotheke/${data.apothekeId}`);\r\n }\r\n }\r\n\r\n return (\r\n <div className=\"login\">\r\n <b style={{fontSize:'20pt'}}>Login:</b>\r\n <Form onSubmit={handleSubmit(login)} >\r\n <Form.Row>\r\n <Col>\r\n <Form.Control onChange={e => setUser({...user, username: e.target.value})} placeholder=\"Benutzername\" />\r\n <Form.Control onChange={e => setUser({...user, password: e.target.value})} placeholder=\"Passwort\" />\r\n <Button variant=\"primary\" type=\"submit\">Login</Button>\r\n <Button variant=\"primary\" >Neue Apotheke registrieren</Button>\r\n </Col>\r\n </Form.Row>\r\n </Form>\r\n </div>\r\n )\r\n}\r\nexport default Login;","D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\Header.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\headers\\StatusHeader.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\user\\UserDetails.js",["130","131","132"],"import React from 'react'\r\nimport { Button, Col, Row, Form } from 'react-bootstrap';\r\n\r\nfunction UserDetails(props) {\r\n //eslint disable-next-line\r\n const {rolle, vorname, name, nutzername, aktiv} = props.user;\r\n\r\n var allRoles = {\r\n ADMIN : { 0: \"Admin\", 1 : \"Pruefer\", 2: \"Benutzer\"},\r\n PRUEFER : { 0 : \"Pruefer\", 1: \"Benutzer\"},\r\n BENUTZER : { 0: \"Benutzer\"}\r\n }\r\n\r\n const logout = () => {\r\n window.sessionStorage.removeItem(\"edbapo-jwt\")\r\n props.history.push('/');\r\n }\r\n\r\n return(\r\n <Row>\r\n <Col><b>Nutzername:</b> {nutzername}</Col>\r\n <Col>\r\n <Form.Control as=\"select\" onChange={(event) => props.setAktiveRolle(event.target.value.toUpperCase())}>\r\n {Object.keys(allRoles[rolle]).map( role => <option key={allRoles[rolle][role]} value={allRoles[rolle][role]}>{allRoles[rolle][role]}</option>)}\r\n </Form.Control>\r\n </Col>\r\n <Col>\r\n <Button>Einstellungen</Button>\r\n </Col>\r\n <Col>\r\n <Button onClick={logout}>Logout</Button>\r\n </Col>\r\n </Row>\r\n )\r\n}\r\n\r\nexport default UserDetails;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeuesBtmModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\BuchungTabelle.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\components\\btmbuch\\NeueBuchungModal.js",["133","134"],"import React, { useState, useEffect } from 'react';\r\nimport { Modal, Button, Form, Row, Col } from 'react-bootstrap';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction NeueBuchungModal(props) {\r\n \r\n const { enqueueSnackbar } = useSnackbar();\r\n const [typ, setTyp] = useState('');\r\n const [lieferanten, setLieferanten] = useState([]);\r\n const [aerzte, setAerzte] = useState([]);\r\n const [empfaenger, setEmpfaenger] = useState([]);\r\n\r\n const sendNewBuchungAnfrage = async (buchungData) => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/btmbuchung`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n body: JSON.stringify(buchungData)\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n\r\n if (response && response.status === 201) {\r\n const data = await response.json();\r\n // console.log(data);\r\n hideModal();\r\n enqueueSnackbar('Buchung erfolgreich angelegt', { variant:'success', autoHideDuration: 3000} );\r\n props.apothekeRefFunctions.updateBtmList();\r\n } else {\r\n //SHOW ERROR\r\n console.log(response);\r\n }\r\n }\r\n\r\n const createNewBuchung = event => {\r\n event.preventDefault();\r\n if (typ.toLowerCase() === 'zugang') {\r\n let { anforderungsschein, btmMenge, lieferant, pruefdatum } = event.target;\r\n let buchungData = {\r\n benutzer: props.user.id,\r\n btm: props.btm.btm.id,\r\n menge: btmMenge.value,\r\n typ: 'ZUGANG',\r\n lieferant: lieferant.value,\r\n anforderungsschein: anforderungsschein.value,\r\n pruefdatum: pruefdatum.value\r\n }\r\n sendNewBuchungAnfrage(buchungData);\r\n } else if (typ.toLowerCase() === 'abgang') {\r\n let { btmMenge, rezept, empfaenger, arzt, pruefdatum } = event.target;\r\n let buchungData = {\r\n benutzer: props.user.id,\r\n btm: props.btm.btm.id,\r\n menge: btmMenge.value,\r\n typ: 'ABGANG',\r\n empfaenger: empfaenger.value,\r\n arzt: arzt.value,\r\n rezept: rezept.value,\r\n pruefdatum: pruefdatum.value\r\n }\r\n sendNewBuchungAnfrage(buchungData);\r\n }\r\n }\r\n\r\n const hideModal = () => {\r\n setTyp('');\r\n props.onHide();\r\n }\r\n\r\n\r\n const loadLieferanten = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/lieferant`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setLieferanten(await response.json());\r\n console.log(lieferanten);\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n const loadAerzte = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/arzt`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setAerzte(await response.json());\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n const loadEmpfaenger = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.apothekeId}/empfaenger`, {\r\n method: 'GET',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n\r\n if (response.status === 200) {\r\n setEmpfaenger(await response.json());\r\n } else if (response.status === 403) {\r\n // props.history.push('/forbidden');\r\n } else if (response.status === 400) {\r\n // props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n loadLieferanten();\r\n loadAerzte();\r\n loadEmpfaenger();\r\n }, []);\r\n\r\n const renderZugang = () => {\r\n return (\r\n <React.Fragment>\r\n <Form.Group as={Row} controlId=\"anforderungsschein\">\r\n <Form.Label column sm=\"2\">\r\n Anforderungsschein\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"anforderungsschein\" type=\"text\" required />\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"lieferant\">\r\n <Form.Label column sm=\"2\">\r\n Lieferant\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"lieferant\" required as=\"select\">\r\n {lieferanten.map(l => <option key={l.id} value={l.id}>{l.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n </React.Fragment>)\r\n }\r\n\r\n const renderAbgang = () => {\r\n return (\r\n <React.Fragment>\r\n <Form.Group as={Row} controlId=\"empfaenger\">\r\n <Form.Label column sm=\"2\">\r\n Empfaenger\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"empfaenger\" required as=\"select\">\r\n {empfaenger.map(e => <option key={e.id} value={e.id}>{e.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"arzt\">\r\n <Form.Label column sm=\"2\">\r\n Arzt\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"arzt\" required as=\"select\">\r\n {aerzte.map(a => <option key={a.id} value={a.id}>{a.name}</option>)}\r\n </Form.Control>\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"rezept\">\r\n <Form.Label column sm=\"2\">\r\n Rezept\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"rezept\" type=\"text\" required />\r\n </Col>\r\n </Form.Group>\r\n </React.Fragment>)\r\n }\r\n\r\n return (\r\n <Modal\r\n {...props}\r\n size=\"lg\"\r\n aria-labelledby=\"contained-modal-title-vcenter\"\r\n centered\r\n onExiting={hideModal}\r\n >\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\">\r\n Betäubungsmittel-Buchung hinzufügen\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Form onSubmit={createNewBuchung}>\r\n <Modal.Body>\r\n <Form.Group as={Row} controlId=\"Typ\">\r\n <Col sm={{ span: 10, offset: 2 }}>\r\n <Row sm={6}>\r\n <Form.Check required\r\n type=\"radio\"\r\n label=\"Zugang\"\r\n name=\"TypRadio\"\r\n id=\"ZugangRadio\"\r\n onClick={() => setTyp('zugang')}\r\n />\r\n <Form.Check required\r\n type=\"radio\"\r\n label=\"Abgang\"\r\n name=\"TypRadio\"\r\n id=\"AbgangRadio\"\r\n onClick={() => setTyp('abgang')}\r\n />\r\n </Row>\r\n </Col>\r\n </Form.Group>\r\n\r\n <Form.Group as={Row} controlId=\"btmMenge\">\r\n <Form.Label column sm=\"2\">\r\n Menge\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"btmMenge\" type=\"number\" min=\"1\" defaultValue=\"0\" />\r\n </Col>\r\n </Form.Group>\r\n <Form.Group as={Row} controlId=\"pruefdatum\">\r\n <Form.Label column sm=\"2\">\r\n Prüfdatum\r\n </Form.Label>\r\n <Col sm=\"10\">\r\n <Form.Control name=\"pruefdatum\" type=\"date\" defaultValue={new Date()} />\r\n </Col>\r\n </Form.Group>\r\n\r\n {typ.toLowerCase() === 'zugang' ? renderZugang() : null}\r\n {typ.toLowerCase() === 'abgang' ? renderAbgang() : null}\r\n\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button variant=\"danger\" onClick={hideModal}>Close</Button>\r\n <Button variant=\"primary\" type=\"submit\">Bestätigen</Button>\r\n </Modal.Footer>\r\n </Form>\r\n\r\n\r\n\r\n </Modal>\r\n )\r\n\r\n}\r\n\r\nexport default NeueBuchungModal;","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\ApothekeEinstellungen.js",["135"],"import React, { useState, Fragment, useEffect } from 'react';\r\nimport { ListGroup, Button, Row, Col } from 'react-bootstrap';\r\nimport { useParams } from 'react-router-dom';\r\n\r\nimport Header from '../../headers/Header';\r\nimport StatusHeader from '../../headers/StatusHeader';\r\nimport ArztTabelle from './tabellen/ArztTabelle';\r\nimport BtmTabelle from './tabellen/BtmTabelle';\r\nimport LieferantTabelle from './tabellen/LieferantTabelle';\r\nimport PersonalTabelle from './tabellen/PersonalTabelle';\r\n\r\nimport './ApothekeEinstellungen.scss'\r\n\r\nfunction ApothekeEinstellungen(props) {\r\n const { apoId } = useParams()\r\n\r\n const [apotheke, setApotheke] = useState({ anschrift: {} })\r\n const [activeMenuItem, setActiveMenuItem] = useState('personal');\r\n const [user, setUser] = useState(null);\r\n\r\n\r\n const getCurrentApotheke = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\")\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setApotheke(data))\r\n .catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n })\r\n }\r\n\r\n const getUserData = async () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/benutzer/me`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n })\r\n .then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then(data => setUser(data)\r\n ).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n\r\n const renderContent = () => {\r\n if (activeMenuItem === 'personal') {\r\n return <PersonalTabelle {...props} />;\r\n } else if (activeMenuItem === 'btm') {\r\n return <BtmTabelle {...props} />;\r\n } else if (activeMenuItem === 'aerzte') {\r\n return <ArztTabelle {...props} />\r\n } else if (activeMenuItem === 'lieferanten') {\r\n return <LieferantTabelle {...props} />\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getUserData();\r\n getCurrentApotheke();\r\n }, []);\r\n\r\n return (\r\n <Fragment>\r\n <StatusHeader aktiveRolle=\"admin\" />\r\n <Header />\r\n <div className=\"main-content\">\r\n <Row>\r\n <Col sm={4}>\r\n <ul>\r\n <li>Name: {apotheke.name}</li>\r\n <li>E-Mail: {apotheke.email}</li>\r\n <li>Anschrift: {apotheke.anschrift.strasse} {apotheke.anschrift.nummer} ({apotheke.anschrift.plz} {apotheke.anschrift.ort})</li>\r\n </ul>\r\n <Button>Angaben bearbeiten</Button>\r\n </Col>\r\n </Row>\r\n <Row style={{ marginTop: '3em' }}>\r\n <Col sm={3}>\r\n <ListGroup as=\"ul\" className=\"menu-list\">\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('personal')} active={activeMenuItem === 'personal'}>Pharmazeutisches Personal</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('btm')} active={activeMenuItem === 'btm'}>Betäubungsmittel</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('aerzte')} active={activeMenuItem === 'aerzte'}>Ärzte</ListGroup.Item>\r\n <ListGroup.Item as=\"li\" onClick={() => setActiveMenuItem('lieferanten')} active={activeMenuItem === 'lieferanten'}>Lieferanten</ListGroup.Item>\r\n </ListGroup>\r\n </Col>\r\n <Col sm={8}>\r\n {user ? renderContent() : null}\r\n </Col>\r\n </Row>\r\n </div>\r\n\r\n\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default ApothekeEinstellungen;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekenDetails.js",["136","137"],"import React, { Fragment, useEffect, useState } from \"react\";\r\nimport { Button } from \"react-bootstrap\";\r\nimport NeuesBtmModal from '../btmbuch/NeuesBtmModal';\r\nimport '../../App.scss'\r\n\r\nfunction ApothekenDetails(props) {\r\n const[apotheke, setApotheke] = useState({anschrift:{}});\r\n const[neuesBtmModalShow, setneuesBtmModalShow] = useState(false);\r\n\r\n\r\n const getApothekeData = async () => {\r\n const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.match.params.id}`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if(response.status === 200){\r\n setApotheke(await response.json());\r\n }else if(response.status === 403) {\r\n props.history.push('/forbidden');\r\n }else if(response.status === 400){\r\n props.history.push('/badrequest');\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getApothekeData();\r\n }, [])\r\n\r\n return(\r\n <div className=\"apo-details\">\r\n <ul>\r\n <li>Name: {apotheke.name}</li>\r\n <li>E-Mail: {apotheke.email}</li> \r\n </ul>\r\n <Button>Apotheke Einstellungen</Button>\r\n <Button onClick={() => setneuesBtmModalShow(true)} style={{marginLeft:'1em'}}>Neues Betäubungsmittel anlegen</Button>\r\n <NeuesBtmModal show={neuesBtmModalShow} {...props} onHide={() => setneuesBtmModalShow(false)} /> \r\n </div>\r\n )\r\n}\r\nexport default ApothekenDetails;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\ApothekeBtmList.js",["138","139","140"],"import React, { useState, useEffect } from \"react\";\r\nimport { FormControl } from \"react-bootstrap\";\r\nimport BuchungTabelle from \"../btmbuch/BuchungTabelle\";\r\n\r\nfunction ApothekeBtmList(props) {\r\n const [btms, setBtms] = useState([]);\r\n const [input, setInput] = useState(\"\");\r\n\r\n const getBtms = async () => {\r\n const response = await fetch(\r\n `http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${props.match.params.id}/btmbuchung`,\r\n {\r\n method: \"GET\",\r\n headers: {\r\n Authorization:\r\n \"Bearer \" + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }\r\n ).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n\r\n if (response.status === 200) {\r\n setBtms(await response.json());\r\n } else if (response.status === 403) {\r\n props.history.push(\"/forbidden\");\r\n } else if (response.status === 400) {\r\n props.history.push(\"/badrequest\");\r\n }\r\n };\r\n\r\n //wird aufgerufen von NeuesBtmModal wenn ein neues BTM hinzugefügt wurde\r\n props.apothekeRefFunctions.updateBtmList = getBtms;\r\n\r\n useEffect(() => {\r\n getBtms();\r\n }, []);\r\n\r\n return (\r\n <div className=\"btm-buchung-wrapper\">\r\n <input\r\n id=\"searchBtmField\"\r\n type=\"text\"\r\n placeholder=\"Betäubungsmittel suchen\"\r\n onChange={(event) => {\r\n setInput(event.target.value);\r\n }}\r\n value={input}\r\n />\r\n {btms\r\n .filter((val) => {\r\n if (input === \"\") {\r\n console.log(\"namen der Liste\", val.btm.name);\r\n return val;\r\n } else if (val.btm.name.toLowerCase().includes(input.toLowerCase())){\r\n return val;\r\n }\r\n })\r\n .map((btm, key) => (\r\n <BuchungTabelle {...props} btm={btm} />\r\n ))}\r\n </div>\r\n );\r\n}\r\n\r\nexport default ApothekeBtmList;\r\n\r\n/*{btms.map(btm => <BuchungTabelle {...props} btm={btm} /> )}*/\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\PersonalTabelle.js",["141"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { AddBox, Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\n\r\nimport PersonalAddModal from '../../../../modals/PersonalAddModal';\r\nimport PersonalEditModal from '../../../../modals/PersonalEditModal';\r\nimport DeleteModal from '../../../../modals/DeleteModal';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction PersonalTabelle(props) {\r\n const { apoId } = useParams();\r\n const [personal, setPersonal] = useState([]);\r\n const { enqueueSnackbar } = useSnackbar();\r\n const [selectedUser, setSelectedUser] = useState(null);\r\n const [showPersonalAddModal, setShowPersonalAddModal] = useState(false);\r\n const [showPersonalEditModal, setShowPersonalEditModal] = useState(false);\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n\r\n\r\n\r\n const getPersonalData = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setPersonal(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n const deleteUser = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer/${selectedUser.id}`, {\r\n method: 'DELETE',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }).then((res) => {\r\n if (res && res.status === 200) {\r\n getPersonalData();\r\n enqueueSnackbar('Benutzer erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 });\r\n } else {\r\n //SHOW ERROR\r\n console.log(res);\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n }\r\n\r\n const del = user => {\r\n setSelectedUser(user);\r\n setShowDeleteModal(true);\r\n }\r\n const edit = user => {\r\n setSelectedUser(user);\r\n setShowPersonalEditModal(true);\r\n }\r\n\r\n useEffect(() => {\r\n getPersonalData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <PersonalAddModal {...props} show={showPersonalAddModal} onHide={() => setShowPersonalAddModal(false)} updatePersonalData={getPersonalData}/>\r\n {selectedUser ? <PersonalEditModal {...props} user={selectedUser} show={showPersonalEditModal} onHide={() => setShowPersonalEditModal(false)} updatePersonalData={getPersonalData}/> : null}\r\n <DeleteModal {...props} headertext={'Benutzer löschen'}\r\n maintext={'Möchtest du diesen Benutzer wirklich löschen?'} onSubmit={deleteUser} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'}\r\n show={showDeleteModal} onHide={() => setShowDeleteModal(false)} />\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Nutzername</th>\r\n <th>Nachname</th>\r\n <th>Vorname</th>\r\n <th>Aktiv</th>\r\n <th>Rolle</th>\r\n <th style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => setShowPersonalAddModal(true)} >Hinzufügen <AddBox /></Button>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {personal.map(user =>\r\n <tr key={user.id}>\r\n <td>{user.nutzername}</td>\r\n <td>{user.name}</td>\r\n <td>{user.vorname}</td>\r\n <td>{user.aktiv ? 'ja' : 'nein'}</td>\r\n <td>{user.rolle}</td>\r\n <td style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => edit(user)}><Edit /></Button>\r\n <Button onClick={() => del(user)}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default PersonalTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\ArztTabelle.js",["142"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { AddBox, Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nimport ArztAddModal from '../../../../modals/ArztAddModal';\r\nimport ArztEditModal from '../../../../modals/ArztEditModal';\r\nimport DeleteModal from '../../../../modals/DeleteModal';\r\n\r\nfunction ArztTabelle(props) {\r\n const { apoId } = useParams();\r\n const [aerzte, setAerzte] = useState([]);\r\n const { enqueueSnackbar } = useSnackbar();\r\n const [selectedArzt, setSelectedArzt] = useState(null);\r\n const [showArztAddModal, setShowArztAddModal] = useState(false);\r\n const [showArztEditModal, setShowArztEditModal] = useState(false);\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n\r\n const getArztData = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setAerzte(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n const deleteArzt = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt/${selectedArzt.id}`, {\r\n method: 'DELETE',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n getArztData()\r\n enqueueSnackbar('Arzt erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 });\r\n } else {\r\n //SHOW ERROR\r\n console.log(res);\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n }\r\n\r\n const edit = arzt => {\r\n setSelectedArzt(arzt);\r\n setShowArztEditModal(true);\r\n }\r\n\r\n const del = arzt => {\r\n setSelectedArzt(arzt);\r\n setShowDeleteModal(true);\r\n }\r\n\r\n useEffect(() => {\r\n getArztData();\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <ArztAddModal {...props} show={showArztAddModal} onHide={() => setShowArztAddModal(false)} updateArztData={getArztData} />\r\n {selectedArzt ? <ArztEditModal {...props} arzt={selectedArzt} show={showArztEditModal} onHide={() => setShowArztEditModal(false)} updateArztData={getArztData} /> : null}\r\n <DeleteModal {...props} headertext={'Arzt löschen'}\r\n maintext={'Möchtest du diesen Arzt wirklich löschen?'} onSubmit={deleteArzt} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'}\r\n show={showDeleteModal} onHide={() => setShowDeleteModal(false)} />\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Strasse</th>\r\n <th>Ort</th>\r\n <th style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => setShowArztAddModal(true)} >Hinzufügen <AddBox /></Button>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {aerzte.map(arzt =>\r\n <tr key={arzt.id}>\r\n <td>{arzt.name}</td>\r\n <td>{arzt.anschrift.strasse} {arzt.anschrift.nummer}</td>\r\n <td>{arzt.anschrift.plz} {arzt.anschrift.ort}</td>\r\n <td style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => edit(arzt)}><Edit /></Button>\r\n <Button onClick={() => del(arzt)}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default ArztTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\LieferantTabelle.js",["143"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { AddBox, Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nimport LieferantAddModal from '../../../../modals/LieferantAddModal';\r\nimport LieferantEditModal from '../../../../modals/LieferantEditModal';\r\nimport DeleteModal from '../../../../modals/DeleteModal';\r\n\r\nfunction LieferantTabelle(props) {\r\n const { apoId } = useParams();\r\n const [lieferanten, setLieferanten] = useState([]);\r\n const { enqueueSnackbar } = useSnackbar();\r\n const [selectedLieferant, setSelectedLieferant] = useState(null);\r\n const [showLieferantAddModal, setShowLieferantAddModal] = useState(false);\r\n const [showLieferantEditModal, setShowLieferantEditModal] = useState(false);\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n\r\n const getLieferantData = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setLieferanten(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n const deleteLieferant = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant/${selectedLieferant.id}`, {\r\n method: 'DELETE',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n getLieferantData()\r\n enqueueSnackbar('Lieferant erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 });\r\n } else {\r\n //SHOW ERROR\r\n console.log(res);\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n }\r\n\r\n const edit = lieferant => {\r\n setSelectedLieferant(lieferant);\r\n setShowLieferantEditModal(true);\r\n }\r\n\r\n const del = lieferant => {\r\n setSelectedLieferant(lieferant);\r\n setShowDeleteModal(true);\r\n }\r\n\r\n useEffect(() => {\r\n getLieferantData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <LieferantAddModal {...props} show={showLieferantAddModal} onHide={() => setShowLieferantAddModal(false)} updateLieferantData={getLieferantData} />\r\n {selectedLieferant ? <LieferantEditModal {...props} lieferant={selectedLieferant} show={showLieferantEditModal} onHide={() => setShowLieferantEditModal(false)} updateLieferantData={getLieferantData} /> : null}\r\n <DeleteModal {...props} headertext={'Lieferant löschen'}\r\n maintext={'Möchtest du diesen Lieferant wirklich löschen?'} onSubmit={deleteLieferant} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'}\r\n show={showDeleteModal} onHide={() => setShowDeleteModal(false)} />\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Strasse</th>\r\n <th>Ort</th>\r\n <th style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => setShowLieferantAddModal(true)} >Hinzufügen <AddBox /></Button>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {lieferanten.map(lieferant =>\r\n <tr key={lieferant.id}>\r\n <td>{lieferant.name}</td>\r\n <td>{lieferant.anschrift.strasse} {lieferant.anschrift.nummer}</td>\r\n <td>{lieferant.anschrift.plz} {lieferant.anschrift.ort}</td>\r\n <td style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => edit(lieferant)}><Edit /></Button>\r\n <Button onClick={() => del(lieferant)}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default LieferantTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\components\\apotheke\\einstellungen\\tabellen\\BtmTabelle.js",["144"],"import React, { Fragment, useState, useEffect } from 'react';\r\nimport { useParams } from 'react-router-dom';\r\nimport { AddBox, Edit, DeleteForever } from '@material-ui/icons';\r\nimport { Table, Button } from 'react-bootstrap';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nimport BtmAddModal from '../../../../modals/BtmAddModal';\r\nimport BtmEditModal from '../../../../modals/BtmEditModal';\r\nimport DeleteModal from '../../../../modals/DeleteModal';\r\n\r\nfunction BtmTabelle(props) {\r\n const { apoId } = useParams();\r\n const [btmListe, setBtmListe] = useState([]);\r\n const { enqueueSnackbar } = useSnackbar();\r\n const [selectedBtm, setSelectedBtm] = useState(null);\r\n const [showBtmAddModal, setShowBtmAddModal] = useState(false);\r\n const [showBtmEditModal, setShowBtmEditModal] = useState(false);\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n\r\n const getBtmData = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm`, {\r\n method: 'GET',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n }\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n return res.json()\r\n } else if (res.status === 403) {\r\n props.history.push('forbidden');\r\n } else if (res.status === 400) {\r\n props.history.push('badrequest');\r\n }\r\n }).then((data) => setBtmListe(data)).catch((err) => {\r\n //SHOW ERROR\r\n return;\r\n });\r\n }\r\n\r\n const deleteBtm = () => {\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm/${selectedBtm.id}`, {\r\n method: 'DELETE',\r\n headers: {\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n getBtmData()\r\n enqueueSnackbar('Btm erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 });\r\n } else {\r\n //SHOW ERROR\r\n console.log(res);\r\n }\r\n }).catch((err) => {\r\n //SHOW ERROR\r\n console.log(err);\r\n });\r\n }\r\n\r\n const edit = btm => {\r\n setSelectedBtm(btm);\r\n setShowBtmEditModal(true);\r\n }\r\n\r\n const del = btm => {\r\n setSelectedBtm(btm);\r\n setShowDeleteModal(true);\r\n }\r\n\r\n useEffect(() => {\r\n getBtmData()\r\n }, [])\r\n\r\n return (\r\n <Fragment>\r\n <BtmAddModal {...props} show={showBtmAddModal} onHide={() => setShowBtmAddModal(false)} updateBtmData={getBtmData} />\r\n {selectedBtm ? <BtmEditModal {...props} btm={selectedBtm} show={showBtmEditModal} onHide={() => setShowBtmEditModal(false)} updateBtmData={getBtmData} /> : null}\r\n <DeleteModal {...props} headertext={'Btm löschen'}\r\n maintext={'Möchtest du diesen Btm wirklich löschen?'} onSubmit={deleteBtm} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'}\r\n show={showDeleteModal} onHide={() => setShowDeleteModal(false)} />\r\n <Table striped bordered hover>\r\n <thead>\r\n <tr>\r\n <th>Name</th>\r\n <th>Darreichungsform</th>\r\n <th>Einheit</th>\r\n <th>Menge</th>\r\n <th style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => setShowBtmAddModal(true)} >Hinzufügen <AddBox /></Button>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {btmListe.map(btm =>\r\n <tr key={btm.id}>\r\n <td>{btm.name}</td>\r\n <td>{btm.darreichungsform}</td>\r\n <td>{btm.einheit}</td>\r\n <td>{btm.menge}</td>\r\n <td style={{ textAlign: 'center', verticalAlign: 'middle' }}>\r\n <Button onClick={() => edit(btm)}><Edit /></Button>\r\n <Button onClick={() => del(btm)}><DeleteForever /></Button>\r\n </td>\r\n </tr>\r\n )}\r\n </tbody>\r\n </Table>\r\n </Fragment>\r\n )\r\n}\r\n\r\nexport default BtmTabelle;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalAddModal.js",["145"],"import React, { useState, useEffect } from 'react';\r\nimport { Modal, Col, Button, Form } from 'react-bootstrap';\r\nimport { useParams } from 'react-router-dom';\r\nimport { useSnackbar } from 'notistack';\r\n\r\nfunction PersonalAddModal(props) {\r\n\r\n const { apoId } = useParams();\r\n\r\n const [nutzernameVergeben, setNutzernameVergeben] = useState(false);\r\n\r\n //for password checking\r\n const [passwordConfirmInvalid, setPasswordConfirmInvalid] = useState(false);\r\n const [newPasswordVal, setNewPasswordVal] = useState('');\r\n const [passwordConfirmVal, setPasswordConfirmVal] = useState('');\r\n\r\n const { enqueueSnackbar } = useSnackbar();\r\n\r\n let roles = [\"ADMIN\", \"PRUEFER\", \"BENUTZER\"];\r\n\r\n const createNewUser = async event => {\r\n event.preventDefault();\r\n let { username, vorname, nachname, neuesPasswort, rolle } = event.target;\r\n\r\n let body = {\r\n name: nachname.value,\r\n nutzername: username.value,\r\n vorname: vorname.value,\r\n aktiv: true,\r\n rolle: rolle.value,\r\n passwort: neuesPasswort.value\r\n }\r\n\r\n console.log(body)\r\n fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': 'Bearer ' + window.sessionStorage.getItem(\"edbapo-jwt\"),\r\n },\r\n body: JSON.stringify(body)\r\n }).then((res) => {\r\n if (res.status === 201) {\r\n props.onHide();\r\n props.updateUserList();\r\n enqueueSnackbar('Benutzer erstellt', { variant: 'success', autoHideDuration: 3000 });\r\n } else if (res.status === 400) {\r\n enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 });\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n }\r\n\r\n const checkIfUserNameIsTaken = async event => {\r\n let newUsername = event.target.value;\r\n if (newUsername.length < 4) {\r\n //if shorter than 4 its invalid\r\n setNutzernameVergeben(true);\r\n return;\r\n }\r\n\r\n await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer/${newUsername}/checkUsername`, {\r\n method: 'POST',\r\n }).then((res) => {\r\n if (res.status === 200) {\r\n setNutzernameVergeben(false);\r\n } else if (res.status === 400) {\r\n setNutzernameVergeben(true);\r\n }\r\n }).catch((err) => {\r\n console.log(err);\r\n return;\r\n });\r\n }\r\n\r\n useEffect(() => {\r\n setPasswordConfirmInvalid(newPasswordVal !== passwordConfirmVal);\r\n }, [newPasswordVal, passwordConfirmVal]);\r\n\r\n\r\n return (\r\n <Modal\r\n {...props}\r\n size=\"lg\"\r\n aria-labelledby=\"contained-modal-title-vcenter\"\r\n centered\r\n onExiting={props.onHide}\r\n >\r\n <Modal.Header closeButton>\r\n <Modal.Title id=\"contained-modal-title-vcenter\">\r\n Benutzer Einstellungen\r\n </Modal.Title>\r\n </Modal.Header>\r\n <Form onSubmit={createNewUser}>\r\n <Modal.Body>\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"username\">\r\n <Form.Label>Benutzername</Form.Label>\r\n <Form.Control name=\"username\" required onChange={checkIfUserNameIsTaken}\r\n isInvalid={nutzernameVergeben} type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} sm={4} controlId=\"vorname\">\r\n <Form.Label>Vorname</Form.Label>\r\n <Form.Control name=\"vorname\" required type=\"text\" />\r\n </Form.Group>\r\n\r\n <Form.Group as={Col} sm={8} controlId=\"nachname\">\r\n <Form.Label>Nachname</Form.Label>\r\n <Form.Control name=\"nachname\" required type=\"text\" />\r\n </Form.Group>\r\n </Form.Row>\r\n\r\n <Form.Row>\r\n <Form.Group as={Col} controlId=\"neuesPasswort\">\r\n <Form.Label>Neues Passwort</Form.Label>\r\n <Form.Control required minlength={5} onChange={event => setNewPasswordVal(event.target.value)} name=\"neuesPasswort\" type=\"password\" />\r\n </Form.Group>\r\n <Form.Group as={Col} controlId=\"neuesPasswortConfirm\">\r\n <Form.Label>Neues Passwort bestätigen</Form.Label>\r\n <Form.Control required minlength={5} onChange={event => setPasswordConfirmVal(event.target.value)} isInvalid={passwordConfirmInvalid} name=\"neuesPasswortConfirm\" type=\"password\" />\r\n </Form.Group>\r\n </Form.Row>\r\n <Form.Row>\r\n <Form.Group as={Col} sm={4} controlId=\"rolle\">\r\n <Form.Label>Rolle</Form.Label>\r\n <Form.Control required name=\"rolle\" required as=\"select\" >\r\n {roles.map(r => <option key={r} value={r}>{r}</option>)}\r\n </Form.Control>\r\n </Form.Group>\r\n </Form.Row>\r\n </Modal.Body>\r\n <Modal.Footer>\r\n <Button autofocus variant=\"\" onClick={props.onHide}>Abbrechen</Button>\r\n <Button variant=\"primary\" type=\"submit\" >Bestätigen</Button>\r\n </Modal.Footer>\r\n </Form>\r\n </Modal>\r\n )\r\n}\r\n\r\nexport default PersonalAddModal;\r\n","D:\\dev\\EDB-Apo\\frontend\\src\\modals\\DeleteModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\PersonalEditModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\BtmAddModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\LieferantEditModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\BtmEditModal.js",["146","147","148"],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\ArztEditModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\LieferantAddModal.js",[],"D:\\dev\\EDB-Apo\\frontend\\src\\modals\\ArztAddModal.js",[],{"ruleId":"149","replacedBy":"150"},{"ruleId":"151","replacedBy":"152"},{"ruleId":"153","severity":1,"message":"154","line":3,"column":50,"nodeType":"155","messageId":"156","endLine":3,"endColumn":54},{"ruleId":"153","severity":1,"message":"157","line":13,"column":22,"nodeType":"155","messageId":"156","endLine":13,"endColumn":35},{"ruleId":"158","severity":1,"message":"159","line":44,"column":6,"nodeType":"160","endLine":44,"endColumn":8,"suggestions":"161"},{"ruleId":"153","severity":1,"message":"162","line":2,"column":9,"nodeType":"155","messageId":"156","endLine":2,"endColumn":12},{"ruleId":"153","severity":1,"message":"163","line":6,"column":18,"nodeType":"155","messageId":"156","endLine":6,"endColumn":25},{"ruleId":"153","severity":1,"message":"164","line":6,"column":27,"nodeType":"155","messageId":"156","endLine":6,"endColumn":31},{"ruleId":"153","severity":1,"message":"165","line":6,"column":45,"nodeType":"155","messageId":"156","endLine":6,"endColumn":50},{"ruleId":"153","severity":1,"message":"166","line":28,"column":19,"nodeType":"155","messageId":"156","endLine":28,"endColumn":23},{"ruleId":"158","severity":1,"message":"167","line":143,"column":8,"nodeType":"160","endLine":143,"endColumn":10,"suggestions":"168"},{"ruleId":"158","severity":1,"message":"169","line":81,"column":6,"nodeType":"160","endLine":81,"endColumn":8,"suggestions":"170"},{"ruleId":"153","severity":1,"message":"171","line":1,"column":17,"nodeType":"155","messageId":"156","endLine":1,"endColumn":25},{"ruleId":"158","severity":1,"message":"172","line":33,"column":6,"nodeType":"160","endLine":33,"endColumn":8,"suggestions":"173"},{"ruleId":"153","severity":1,"message":"174","line":2,"column":10,"nodeType":"155","messageId":"156","endLine":2,"endColumn":21},{"ruleId":"158","severity":1,"message":"175","line":38,"column":6,"nodeType":"160","endLine":38,"endColumn":8,"suggestions":"176"},{"ruleId":"177","severity":1,"message":"178","line":52,"column":23,"nodeType":"179","messageId":"180","endLine":52,"endColumn":25},{"ruleId":"158","severity":1,"message":"181","line":73,"column":6,"nodeType":"160","endLine":73,"endColumn":8,"suggestions":"182"},{"ruleId":"158","severity":1,"message":"183","line":72,"column":6,"nodeType":"160","endLine":72,"endColumn":8,"suggestions":"184"},{"ruleId":"158","severity":1,"message":"185","line":72,"column":6,"nodeType":"160","endLine":72,"endColumn":8,"suggestions":"186"},{"ruleId":"158","severity":1,"message":"187","line":72,"column":6,"nodeType":"160","endLine":72,"endColumn":8,"suggestions":"188"},{"ruleId":"189","severity":1,"message":"190","line":131,"column":51,"nodeType":"191","endLine":131,"endColumn":59},{"ruleId":"153","severity":1,"message":"192","line":30,"column":21,"nodeType":"155","messageId":"156","endLine":30,"endColumn":33},{"ruleId":"153","severity":1,"message":"193","line":31,"column":24,"nodeType":"155","messageId":"156","endLine":31,"endColumn":39},{"ruleId":"158","severity":1,"message":"194","line":75,"column":6,"nodeType":"160","endLine":75,"endColumn":17,"suggestions":"195"},"no-native-reassign",["196"],"no-negated-in-lhs",["197"],"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'setApothekeId' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getUserDetails'. Either include it or remove the dependency array.","ArrayExpression",["198"],"'Row' is defined but never used.","'vorname' is assigned a value but never used.","'name' is assigned a value but never used.","'aktiv' is assigned a value but never used.","'data' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'loadAerzte', 'loadEmpfaenger', and 'loadLieferanten'. Either include them or remove the dependency array.",["199"],"React Hook useEffect has missing dependencies: 'getCurrentApotheke' and 'getUserData'. Either include them or remove the dependency array.",["200"],"'Fragment' is defined but never used.","React Hook useEffect has a missing dependency: 'getApothekeData'. Either include it or remove the dependency array.",["201"],"'FormControl' is defined but never used.","React Hook useEffect has a missing dependency: 'getBtms'. Either include it or remove the dependency array.",["202"],"array-callback-return","Array.prototype.filter() expects a value to be returned at the end of arrow function.","ArrowFunctionExpression","expectedAtEnd","React Hook useEffect has a missing dependency: 'getPersonalData'. Either include it or remove the dependency array.",["203"],"React Hook useEffect has a missing dependency: 'getArztData'. Either include it or remove the dependency array.",["204"],"React Hook useEffect has a missing dependency: 'getLieferantData'. Either include it or remove the dependency array.",["205"],"React Hook useEffect has a missing dependency: 'getBtmData'. Either include it or remove the dependency array.",["206"],"react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'setShowError' is assigned a value but never used.","'setErrorMessage' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'activeDarreichungsform', 'activeEinheit', 'darreichungsformen', and 'einheiten'. Either include them or remove the dependency array.",["207"],"no-global-assign","no-unsafe-negation",{"desc":"208","fix":"209"},{"desc":"210","fix":"211"},{"desc":"212","fix":"213"},{"desc":"214","fix":"215"},{"desc":"216","fix":"217"},{"desc":"218","fix":"219"},{"desc":"220","fix":"221"},{"desc":"222","fix":"223"},{"desc":"224","fix":"225"},{"desc":"226","fix":"227"},"Update the dependencies array to be: [getUserDetails]",{"range":"228","text":"229"},"Update the dependencies array to be: [loadAerzte, loadEmpfaenger, loadLieferanten]",{"range":"230","text":"231"},"Update the dependencies array to be: [getCurrentApotheke, getUserData]",{"range":"232","text":"233"},"Update the dependencies array to be: [getApothekeData]",{"range":"234","text":"235"},"Update the dependencies array to be: [getBtms]",{"range":"236","text":"237"},"Update the dependencies array to be: [getPersonalData]",{"range":"238","text":"239"},"Update the dependencies array to be: [getArztData]",{"range":"240","text":"241"},"Update the dependencies array to be: [getLieferantData]",{"range":"242","text":"243"},"Update the dependencies array to be: [getBtmData]",{"range":"244","text":"245"},"Update the dependencies array to be: [activeDarreichungsform, activeEinheit, darreichungsformen, einheiten, props.btm]",{"range":"246","text":"247"},[1519,1521],"[getUserDetails]",[5207,5209],"[loadAerzte, loadEmpfaenger, loadLieferanten]",[2550,2552],"[getCurrentApotheke, getUserData]",[1077,1079],"[getApothekeData]",[1122,1124],"[getBtms]",[2410,2412],"[getPersonalData]",[2331,2333],"[getArztData]",[2475,2477],"[getLieferantData]",[2310,2312],"[getBtmData]",[2744,2755],"[activeDarreichungsform, activeEinheit, darreichungsformen, einheiten, props.btm]"] \ No newline at end of file diff --git a/frontend/src/App.js b/frontend/src/App.js index e28d93c7f0ef222a01b014964bc2387c2262486b..328aa4de96d6a4bff3507f77c9f2377255425437 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -18,7 +18,7 @@ function App() { <Route path="/" exact component={Startseite} /> <Route path="/login" exact component={Startseite} /> <Route path="/apotheke/:id" exact component={BTMBuch} /> - <Route path="/apotheke/:id/einstellungen" exact component={ApothekeEinstellungen} /> + <Route path="/apotheke/:apoId/einstellungen" exact component={ApothekeEinstellungen} /> </Switch> </Router> </SnackbarProvider> diff --git a/frontend/src/components/apotheke/einstellungen/ApothekeEinstellungen.js b/frontend/src/components/apotheke/einstellungen/ApothekeEinstellungen.js index f2bdf0375473b4688b231f42ce9a605db6068a33..d5456d52cac30647637c3c11617289a69d07563b 100644 --- a/frontend/src/components/apotheke/einstellungen/ApothekeEinstellungen.js +++ b/frontend/src/components/apotheke/einstellungen/ApothekeEinstellungen.js @@ -12,7 +12,7 @@ import PersonalTabelle from './tabellen/PersonalTabelle'; import './ApothekeEinstellungen.scss' function ApothekeEinstellungen(props) { - const { id } = useParams() + const { apoId } = useParams() const [apotheke, setApotheke] = useState({ anschrift: {} }) const [activeMenuItem, setActiveMenuItem] = useState('personal'); @@ -20,7 +20,7 @@ function ApothekeEinstellungen(props) { const getCurrentApotheke = async () => { - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}`, { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}`, { method: 'GET', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt") diff --git a/frontend/src/components/apotheke/einstellungen/tabellen/ArztTabelle.js b/frontend/src/components/apotheke/einstellungen/tabellen/ArztTabelle.js index 56bd456ca2478e537676fccd398f48fda5cdf1cd..1c1815a63a06f9a5e5446cae162b9f4b5969a794 100644 --- a/frontend/src/components/apotheke/einstellungen/tabellen/ArztTabelle.js +++ b/frontend/src/components/apotheke/einstellungen/tabellen/ArztTabelle.js @@ -1,15 +1,24 @@ import React, { Fragment, useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; - -import { Edit, DeleteForever } from '@material-ui/icons'; +import { AddBox, Edit, DeleteForever } from '@material-ui/icons'; import { Table, Button } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +import ArztAddModal from '../../../../modals/ArztAddModal'; +import ArztEditModal from '../../../../modals/ArztEditModal'; +import DeleteModal from '../../../../modals/DeleteModal'; function ArztTabelle(props) { - const { id } = useParams(); + const { apoId } = useParams(); const [aerzte, setAerzte] = useState([]); + const { enqueueSnackbar } = useSnackbar(); + const [selectedArzt, setSelectedArzt] = useState(null); + const [showArztAddModal, setShowArztAddModal] = useState(false); + const [showArztEditModal, setShowArztEditModal] = useState(false); + const [showDeleteModal, setShowDeleteModal] = useState(false); - const getPersonalData = async () => { - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/arzt`, { + const getArztData = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt`, { method: 'GET', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), @@ -28,19 +37,56 @@ function ArztTabelle(props) { }); } + const deleteArzt = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt/${selectedArzt.id}`, { + method: 'DELETE', + headers: { + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + }).then((res) => { + if (res.status === 200) { + getArztData() + enqueueSnackbar('Arzt erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 }); + } else { + //SHOW ERROR + console.log(res); + } + }).catch((err) => { + //SHOW ERROR + console.log(err); + }); + } + + const edit = arzt => { + setSelectedArzt(arzt); + setShowArztEditModal(true); + } + + const del = arzt => { + setSelectedArzt(arzt); + setShowDeleteModal(true); + } + useEffect(() => { - getPersonalData() + getArztData(); }, []) return ( <Fragment> + <ArztAddModal {...props} show={showArztAddModal} onHide={() => setShowArztAddModal(false)} updateArztData={getArztData} /> + {selectedArzt ? <ArztEditModal {...props} arzt={selectedArzt} show={showArztEditModal} onHide={() => setShowArztEditModal(false)} updateArztData={getArztData} /> : null} + <DeleteModal {...props} headertext={'Arzt löschen'} + maintext={'Möchtest du diesen Arzt wirklich löschen?'} onSubmit={deleteArzt} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'} + show={showDeleteModal} onHide={() => setShowDeleteModal(false)} /> <Table striped bordered hover> <thead> <tr> <th>Name</th> <th>Strasse</th> <th>Ort</th> - <th>Aktionen</th> + <th style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => setShowArztAddModal(true)} >Hinzufügen <AddBox /></Button> + </th> </tr> </thead> <tbody> @@ -49,9 +95,9 @@ function ArztTabelle(props) { <td>{arzt.name}</td> <td>{arzt.anschrift.strasse} {arzt.anschrift.nummer}</td> <td>{arzt.anschrift.plz} {arzt.anschrift.ort}</td> - <td> - <Button onClick={() => console.log("update")}><Edit /></Button> - <Button onClick={() => console.log("delete")}><DeleteForever /></Button> + <td style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => edit(arzt)}><Edit /></Button> + <Button onClick={() => del(arzt)}><DeleteForever /></Button> </td> </tr> )} diff --git a/frontend/src/components/apotheke/einstellungen/tabellen/BtmTabelle.js b/frontend/src/components/apotheke/einstellungen/tabellen/BtmTabelle.js index 1967b19f76ea08b98cf0415faebef3262f721266..d6422837e03507cef065159ec5977058413da3a6 100644 --- a/frontend/src/components/apotheke/einstellungen/tabellen/BtmTabelle.js +++ b/frontend/src/components/apotheke/einstellungen/tabellen/BtmTabelle.js @@ -1,15 +1,24 @@ import React, { Fragment, useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; - -import { Edit, DeleteForever } from '@material-ui/icons'; +import { AddBox, Edit, DeleteForever } from '@material-ui/icons'; import { Table, Button } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +import BtmAddModal from '../../../../modals/BtmAddModal'; +import BtmEditModal from '../../../../modals/BtmEditModal'; +import DeleteModal from '../../../../modals/DeleteModal'; function BtmTabelle(props) { - const { id } = useParams(); + const { apoId } = useParams(); const [btmListe, setBtmListe] = useState([]); + const { enqueueSnackbar } = useSnackbar(); + const [selectedBtm, setSelectedBtm] = useState(null); + const [showBtmAddModal, setShowBtmAddModal] = useState(false); + const [showBtmEditModal, setShowBtmEditModal] = useState(false); + const [showDeleteModal, setShowDeleteModal] = useState(false); - const getPersonalData = async () => { - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/btm`, { + const getBtmData = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm`, { method: 'GET', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), @@ -28,12 +37,47 @@ function BtmTabelle(props) { }); } + const deleteBtm = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm/${selectedBtm.id}`, { + method: 'DELETE', + headers: { + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + }).then((res) => { + if (res.status === 200) { + getBtmData() + enqueueSnackbar('Btm erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 }); + } else { + //SHOW ERROR + console.log(res); + } + }).catch((err) => { + //SHOW ERROR + console.log(err); + }); + } + + const edit = btm => { + setSelectedBtm(btm); + setShowBtmEditModal(true); + } + + const del = btm => { + setSelectedBtm(btm); + setShowDeleteModal(true); + } + useEffect(() => { - getPersonalData() + getBtmData() }, []) return ( <Fragment> + <BtmAddModal {...props} show={showBtmAddModal} onHide={() => setShowBtmAddModal(false)} updateBtmData={getBtmData} /> + {selectedBtm ? <BtmEditModal {...props} btm={selectedBtm} show={showBtmEditModal} onHide={() => setShowBtmEditModal(false)} updateBtmData={getBtmData} /> : null} + <DeleteModal {...props} headertext={'Btm löschen'} + maintext={'Möchtest du diesen Btm wirklich löschen?'} onSubmit={deleteBtm} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'} + show={showDeleteModal} onHide={() => setShowDeleteModal(false)} /> <Table striped bordered hover> <thead> <tr> @@ -41,7 +85,9 @@ function BtmTabelle(props) { <th>Darreichungsform</th> <th>Einheit</th> <th>Menge</th> - <th>Aktionen</th> + <th style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => setShowBtmAddModal(true)} >Hinzufügen <AddBox /></Button> + </th> </tr> </thead> <tbody> @@ -51,9 +97,9 @@ function BtmTabelle(props) { <td>{btm.darreichungsform}</td> <td>{btm.einheit}</td> <td>{btm.menge}</td> - <td> - <Button onClick={() => console.log("update")}><Edit /></Button> - <Button onClick={() => console.log("delete")}><DeleteForever /></Button> + <td style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => edit(btm)}><Edit /></Button> + <Button onClick={() => del(btm)}><DeleteForever /></Button> </td> </tr> )} diff --git a/frontend/src/components/apotheke/einstellungen/tabellen/LieferantTabelle.js b/frontend/src/components/apotheke/einstellungen/tabellen/LieferantTabelle.js index 94e809ad84490a9a5ca517f17b75bb8415d16fac..fc60b938545f624bbaf2ef115f27339b164e1cfc 100644 --- a/frontend/src/components/apotheke/einstellungen/tabellen/LieferantTabelle.js +++ b/frontend/src/components/apotheke/einstellungen/tabellen/LieferantTabelle.js @@ -1,15 +1,24 @@ import React, { Fragment, useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; - -import { Edit, DeleteForever } from '@material-ui/icons'; +import { AddBox, Edit, DeleteForever } from '@material-ui/icons'; import { Table, Button } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +import LieferantAddModal from '../../../../modals/LieferantAddModal'; +import LieferantEditModal from '../../../../modals/LieferantEditModal'; +import DeleteModal from '../../../../modals/DeleteModal'; function LieferantTabelle(props) { - const { id } = useParams(); + const { apoId } = useParams(); const [lieferanten, setLieferanten] = useState([]); + const { enqueueSnackbar } = useSnackbar(); + const [selectedLieferant, setSelectedLieferant] = useState(null); + const [showLieferantAddModal, setShowLieferantAddModal] = useState(false); + const [showLieferantEditModal, setShowLieferantEditModal] = useState(false); + const [showDeleteModal, setShowDeleteModal] = useState(false); - const getPersonalData = async () => { - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/lieferant`, { + const getLieferantData = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant`, { method: 'GET', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), @@ -28,19 +37,56 @@ function LieferantTabelle(props) { }); } + const deleteLieferant = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant/${selectedLieferant.id}`, { + method: 'DELETE', + headers: { + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + }).then((res) => { + if (res.status === 200) { + getLieferantData() + enqueueSnackbar('Lieferant erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 }); + } else { + //SHOW ERROR + console.log(res); + } + }).catch((err) => { + //SHOW ERROR + console.log(err); + }); + } + + const edit = lieferant => { + setSelectedLieferant(lieferant); + setShowLieferantEditModal(true); + } + + const del = lieferant => { + setSelectedLieferant(lieferant); + setShowDeleteModal(true); + } + useEffect(() => { - getPersonalData() + getLieferantData() }, []) return ( <Fragment> + <LieferantAddModal {...props} show={showLieferantAddModal} onHide={() => setShowLieferantAddModal(false)} updateLieferantData={getLieferantData} /> + {selectedLieferant ? <LieferantEditModal {...props} lieferant={selectedLieferant} show={showLieferantEditModal} onHide={() => setShowLieferantEditModal(false)} updateLieferantData={getLieferantData} /> : null} + <DeleteModal {...props} headertext={'Lieferant löschen'} + maintext={'Möchtest du diesen Lieferant wirklich löschen?'} onSubmit={deleteLieferant} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'} + show={showDeleteModal} onHide={() => setShowDeleteModal(false)} /> <Table striped bordered hover> <thead> <tr> <th>Name</th> <th>Strasse</th> <th>Ort</th> - <th>Aktionen</th> + <th style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => setShowLieferantAddModal(true)} >Hinzufügen <AddBox /></Button> + </th> </tr> </thead> <tbody> @@ -49,9 +95,9 @@ function LieferantTabelle(props) { <td>{lieferant.name}</td> <td>{lieferant.anschrift.strasse} {lieferant.anschrift.nummer}</td> <td>{lieferant.anschrift.plz} {lieferant.anschrift.ort}</td> - <td> - <Button onClick={() => console.log("update")}><Edit /></Button> - <Button onClick={() => console.log("delete")}><DeleteForever /></Button> + <td style={{ textAlign: 'center', verticalAlign: 'middle' }}> + <Button onClick={() => edit(lieferant)}><Edit /></Button> + <Button onClick={() => del(lieferant)}><DeleteForever /></Button> </td> </tr> )} diff --git a/frontend/src/components/apotheke/einstellungen/tabellen/PersonalTabelle.js b/frontend/src/components/apotheke/einstellungen/tabellen/PersonalTabelle.js index e1ac8cd6894c8c01cc5cb3cdbc887c163638b742..00fff5fcda5104fee18669a08fe683ea8a6f5660 100644 --- a/frontend/src/components/apotheke/einstellungen/tabellen/PersonalTabelle.js +++ b/frontend/src/components/apotheke/einstellungen/tabellen/PersonalTabelle.js @@ -9,7 +9,7 @@ import DeleteModal from '../../../../modals/DeleteModal'; import { useSnackbar } from 'notistack'; function PersonalTabelle(props) { - const { id } = useParams(); + const { apoId } = useParams(); const [personal, setPersonal] = useState([]); const { enqueueSnackbar } = useSnackbar(); const [selectedUser, setSelectedUser] = useState(null); @@ -19,8 +19,8 @@ function PersonalTabelle(props) { - const getPersonalData = async () => { - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer`, { + const getPersonalData = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer`, { method: 'GET', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), @@ -39,16 +39,15 @@ function PersonalTabelle(props) { }); } - const deleteUser = async () => { - console.log("user should get deleted"); - fetch(`http://${process.env.REACT_APP_BACKEND_HOSTNAME}/apotheke/${id}/benutzer/${selectedUser.id}`, { + const deleteUser = () => { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer/${selectedUser.id}`, { method: 'DELETE', headers: { 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), }, }).then((res) => { if (res && res.status === 200) { - props.updateUserList(); + getPersonalData(); enqueueSnackbar('Benutzer erfolgreich gelöscht', { variant: 'success', autoHideDuration: 3000 }); } else { //SHOW ERROR @@ -58,8 +57,6 @@ function PersonalTabelle(props) { //SHOW ERROR console.log(err); }); - - } const del = user => { @@ -77,8 +74,8 @@ function PersonalTabelle(props) { return ( <Fragment> - <PersonalAddModal {...props} show={showPersonalAddModal} onHide={() => setShowPersonalAddModal(false)} /> - {selectedUser ? <PersonalEditModal {...props} user={selectedUser} show={showPersonalEditModal} onHide={() => setShowPersonalEditModal(false)} /> : null} + <PersonalAddModal {...props} show={showPersonalAddModal} onHide={() => setShowPersonalAddModal(false)} updatePersonalData={getPersonalData}/> + {selectedUser ? <PersonalEditModal {...props} user={selectedUser} show={showPersonalEditModal} onHide={() => setShowPersonalEditModal(false)} updatePersonalData={getPersonalData}/> : null} <DeleteModal {...props} headertext={'Benutzer löschen'} maintext={'Möchtest du diesen Benutzer wirklich löschen?'} onSubmit={deleteUser} subtext={'Dieser Vorgang kann nicht rückgängig gemacht werden'} show={showDeleteModal} onHide={() => setShowDeleteModal(false)} /> diff --git a/frontend/src/modals/ArztAddModal.js b/frontend/src/modals/ArztAddModal.js new file mode 100644 index 0000000000000000000000000000000000000000..3bdb2e47ad01aca4200ececf6b6d091e802072b2 --- /dev/null +++ b/frontend/src/modals/ArztAddModal.js @@ -0,0 +1,102 @@ +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Col, Button, Form } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +function ArztAddModal(props) { + + const { apoId } = useParams(); + const { enqueueSnackbar } = useSnackbar(); + + const updateDetails = event => { + event.preventDefault(); + let { name, plz, ort, strasse, nummer } = event.target; + + let body = { + name: name.value, + anschrift: { + ort: ort.value, + plz: plz.value, + strasse: strasse.value, + nummer: nummer.value + } + } + + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify(body) + }).then((res) => { + if (res.status === 201) { + props.onHide(); + props.updateArztData(); + enqueueSnackbar('Arzt erstellt', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 }); + } + }).catch((err) => { + console.log(err); + return; + }); + + + } + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={props.onHide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Benutzer Einstellungen + </Modal.Title> + </Modal.Header> + <Form onSubmit={updateDetails}> + <Modal.Body> + <Form.Row> + <Form.Group as={Col} controlId="name"> + <Form.Label>Name</Form.Label> + <Form.Control name="name" required type="text" /> + </Form.Group> + </Form.Row> + + <Form.Row> + <Form.Group as={Col} sm={9} controlId="strasse"> + <Form.Label>Straße</Form.Label> + <Form.Control name="strasse" required type="text" /> + </Form.Group> + <Form.Group as={Col} sm={3} controlId="nummer"> + <Form.Label>Nummer</Form.Label> + <Form.Control name="nummer" required type="text" /> + </Form.Group> + </Form.Row> + <Form.Row> + <Form.Group as={Col} sm={3} controlId="plz"> + <Form.Label>PLZ</Form.Label> + <Form.Control name="plz" required type="text" /> + </Form.Group> + + <Form.Group as={Col} sm={9} controlId="ort"> + <Form.Label>Ort</Form.Label> + <Form.Control name="ort" required type="text" /> + </Form.Group> + </Form.Row> + </Modal.Body> + <Modal.Footer> + <Button autofocus variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit" >Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) + +} + +export default ArztAddModal; diff --git a/frontend/src/modals/ArztEditModal.js b/frontend/src/modals/ArztEditModal.js new file mode 100644 index 0000000000000000000000000000000000000000..9f829f743a0548da94d841c3685145ed8eb6a00c --- /dev/null +++ b/frontend/src/modals/ArztEditModal.js @@ -0,0 +1,107 @@ +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Col, Button, Form } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +function ArztEditModal(props) { + + const { apoId } = useParams(); + const { enqueueSnackbar } = useSnackbar(); + + let { id, name, anschrift } = props.arzt; + + + const updateDetails = async event => { + event.preventDefault(); + let { name, plz, ort, strasse, nummer } = event.target; + + let body = { + name: name.value, + anschrift: { + ort: ort.value, + plz: plz.value, + strasse: strasse.value, + nummer: nummer.value + } + } + + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/arzt/${id}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify(body) + }).then((res) => { + if (res.status === 200) { + props.onHide(); + props.updateArztData(); + enqueueSnackbar('Arzt aktualisiert', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 }); + } else if (res.status === 403) { + enqueueSnackbar('Falsches Passwort', { variant: 'error', autoHideDuration: 3000 }); + } + }).catch((err) => { + console.log(err); + return; + }); + + + } + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={props.onHide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Benutzer Einstellungen + </Modal.Title> + </Modal.Header> + <Form onSubmit={updateDetails}> + <Modal.Body> + <Form.Row> + <Form.Group as={Col} controlId="name"> + <Form.Label>Name</Form.Label> + <Form.Control name="name" required defaultValue={name} type="text" /> + </Form.Group> + </Form.Row> + + <Form.Row> + <Form.Group as={Col} sm={9} controlId="strasse"> + <Form.Label>Straße</Form.Label> + <Form.Control name="strasse" required type="text" defaultValue={anschrift.strasse} /> + </Form.Group> + <Form.Group as={Col} sm={3} controlId="nummer"> + <Form.Label>Nummer</Form.Label> + <Form.Control name="nummer" required type="text" defaultValue={anschrift.nummer} /> + </Form.Group> + </Form.Row> + <Form.Row> + <Form.Group as={Col} sm={3} controlId="plz"> + <Form.Label>PLZ</Form.Label> + <Form.Control name="plz" required type="text" defaultValue={anschrift.plz} /> + </Form.Group> + + <Form.Group as={Col} sm={9} controlId="ort"> + <Form.Label>Ort</Form.Label> + <Form.Control name="ort" required type="text" defaultValue={anschrift.ort} /> + </Form.Group> + </Form.Row> + </Modal.Body> + <Modal.Footer> + <Button autofocus variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit" >Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) + +} + +export default ArztEditModal; diff --git a/frontend/src/modals/BtmAddModal.js b/frontend/src/modals/BtmAddModal.js new file mode 100644 index 0000000000000000000000000000000000000000..1120c8cf800a7219fff15ed7b0366e76702e6754 --- /dev/null +++ b/frontend/src/modals/BtmAddModal.js @@ -0,0 +1,129 @@ +import React, { useState } from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Button, Form, Row, Col, Alert } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +function BtmAddModal(props) { + + const { apoId } = useParams(); + const { enqueueSnackbar } = useSnackbar(); + const [activeDarreichungsform, setActiveDarreichungsform] = useState('Tbl'); + const [showError, setShowError] = useState(false); + const [errorMessage, setErrorMessage] = useState(''); + + const createNewBtm = async event => { + event.preventDefault(); + let { btmName, btmMenge, btmDarreichungsform, btmEinheit } = event.target; + + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify({ + name: btmName.value, + menge: btmMenge.value, + darreichungsform: btmDarreichungsform.value, + einheit: btmEinheit.value + }) + }).then((res) => { + if (res.status === 201) { + props.onHide(); + props.updateBtmData(); + enqueueSnackbar('Betäubungsmittel erfolgreich angelegt', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + setErrorMessage('Betäubungsmittel existiert bereits oder Daten ungültig'); + setShowError(true); + } + }).catch((err) => { + //SHOW ERROR + console.log(err); + }); + + + + } + + // let einheiten = ['g','mg','ml', 'Stueck'] + let darreichungsformen = { + 'Tbl': { einheiten: ['Stueck'] }, + 'Trp': { einheiten: ['ml'] }, + 'Sup': { einheiten: ['Stueck'] }, + 'RTA': { einheiten: ['Stueck'] }, + 'RKA': { einheiten: ['Stueck'] }, + 'Ampullen': { einheiten: ['Stueck'] }, + 'Rezeptursubstanz': { einheiten: ['mg', 'g'] }, + 'HKP': { einheiten: ['Stueck'] }, + 'Pfl': { einheiten: ['Stueck'] } + } + var units = darreichungsformen[activeDarreichungsform].einheiten; + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={props.onHide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Betäubungsmittel hinzufügen + </Modal.Title> + </Modal.Header> + <Form onSubmit={createNewBtm}> + {showError ? <Alert variant="danger">{errorMessage}</Alert> : null} + <Modal.Body> + <Form.Group as={Row} controlId="btmName"> + <Form.Label column sm="2"> + Name + </Form.Label> + <Col sm="10"> + <Form.Control name="btmName" required type="text" /> + </Col> + </Form.Group> + + <Form.Group as={Row} controlId="btmMenge"> + <Form.Label column sm="2"> + Menge + </Form.Label> + <Col sm="10"> + <Form.Control name="btmMenge" type="number" min="0" defaultValue="0" /> + </Col> + </Form.Group> + + + <Form.Group as={Row} controlId="btmDarreichungsform"> + <Form.Label column sm="2"> + Darreichungsform + </Form.Label> + <Col sm="10"> + <Form.Control onChange={event => setActiveDarreichungsform(event.target.value)} name="btmDarreichungsform" required as="select"> + {Object.keys(darreichungsformen).map(df => <option kef={df} value={df}>{df}</option>)} + </Form.Control> + </Col> + </Form.Group> + + <Form.Group as={Row} controlId="btmEinheit"> + <Form.Label column sm="2"> + Einheit + </Form.Label> + <Col sm="10"> + <Form.Control name="btmEinheit" required as="select"> + {activeDarreichungsform !== '' ? Object.keys(units).map(e => <option key={units[e]} value={units[e]}>{units[e]}</option>) : null} + </Form.Control> + </Col> + </Form.Group> + + </Modal.Body> + <Modal.Footer> + <Button variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit">Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) +} + +export default BtmAddModal; diff --git a/frontend/src/modals/BtmEditModal.js b/frontend/src/modals/BtmEditModal.js new file mode 100644 index 0000000000000000000000000000000000000000..47e3fd31ba4302ffb0bdfda8e21b1a052721b923 --- /dev/null +++ b/frontend/src/modals/BtmEditModal.js @@ -0,0 +1,160 @@ +import React, { useState, useEffect } from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Col, Button, Form, Alert, Row } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; +import { responsiveFontSizes } from '@material-ui/core'; + +function BtmEditModal(props) { + + const { apoId } = useParams(); + + const darreichungsformen = { + 'Tbl': { einheiten: ['Stueck'] }, + 'Trp': { einheiten: ['ml'] }, + 'Sup': { einheiten: ['Stueck'] }, + 'RTA': { einheiten: ['Stueck'] }, + 'RKA': { einheiten: ['Stueck'] }, + 'Ampullen': { einheiten: ['Stueck'] }, + 'Rezeptursubstanz': { einheiten: ['mg', 'g'] }, + 'HKP': { einheiten: ['Stueck'] }, + 'Pfl': { einheiten: ['Stueck'] } + }; + + let { id, darreichungsform, einheit, name, menge } = props.btm; + // console.log(props.btm) + + const [activeDarreichungsform, setActiveDarreichungsform] = useState(darreichungsform); + const [activeEinheit, setActiveEinheit] = useState(einheit); + const [einheiten, setEinheiten] = useState(darreichungsformen[darreichungsform].einheiten); + + const [showError, setShowError] = useState(false); + const [errorMessage, setErrorMessage] = useState(''); + const { enqueueSnackbar } = useSnackbar(); + + + const updateDetails = async event => { + event.preventDefault(); + let { name, darreichungsform, einheit, menge } = event.target; + let body = { + name: name.value, + darreichungsform: darreichungsform.value, + einheit: einheit.value, + menge: menge.value + } + console.log(body) + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/btm/${id}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify(body) + }).then((res) => { + if (res.status === 200) { + hide(); + props.updateBtmData(); + enqueueSnackbar('Benutzer aktualisiert', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 }); + } else if (responsiveFontSizes.status === 403) { + enqueueSnackbar('Falsches Passwort', { variant: 'error', autoHideDuration: 3000 }); + } + }).catch((err) => { + console.log(err); + return; + }); + + + } + + useEffect(() => { + setActiveDarreichungsform(props.btm.darreichungsform); + setActiveEinheit(props.btm.einheit); + setEinheiten(darreichungsformen[props.btm.darreichungsform].einheiten) + console.log(activeDarreichungsform, activeEinheit, einheiten) + }, [props.btm]) + + const hide = () => { + setActiveDarreichungsform(props.btm.darreichungsform); + setActiveEinheit(props.btm.einheit); + setEinheiten(darreichungsformen[props.btm.darreichungsform].einheiten) + props.onHide(); + } + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={hide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Betäubungsmittel bearbeiten + </Modal.Title> + </Modal.Header> + <Form onSubmit={updateDetails}> + {showError ? <Alert variant="danger">{errorMessage}</Alert> : null} + <Modal.Body> + <Form.Group as={Row} controlId="name"> + <Form.Label column sm="2"> + Name + </Form.Label> + <Col sm="10"> + <Form.Control defaultValue={name} name="name" required type="text" /> + </Col> + </Form.Group> + + <Form.Group as={Row} controlId="menge"> + <Form.Label column sm="2"> + Menge + </Form.Label> + <Col sm="10"> + <Form.Control defaultValue={menge} name="menge" type="number" min="0" /> + </Col> + </Form.Group> + + + <Form.Group as={Row} controlId="darreichungsform"> + <Form.Label column sm="2"> + Darreichungsform + </Form.Label> + <Col sm="10"> + <Form.Control defaultValue={darreichungsform} onChange={event => { + setActiveDarreichungsform(event.target.value) + setEinheiten(darreichungsformen[event.target.value].einheiten) + }} name="darreichungsform" required as="select"> + { + darreichungsformen ? Object.keys(darreichungsformen).map(df => <option kef={df} value={df}>{df}</option>) : null + } + </Form.Control> + </Col> + </Form.Group> + + <Form.Group as={Row} controlId="einheit"> + <Form.Label column sm="2"> + Einheit + </Form.Label> + <Col sm="10"> + <Form.Control defaultValue={einheit} name="einheit" required as="select"> + { + einheiten ? Object.keys(einheiten).map(e => <option key={einheiten[e]} value={einheiten[e]}>{einheiten[e]}</option>) : null + } + </Form.Control> + </Col> + </Form.Group> + + </Modal.Body> + <Modal.Footer> + <Button variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit">Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) + + +} + +export default BtmEditModal; diff --git a/frontend/src/modals/LieferantAddModal.js b/frontend/src/modals/LieferantAddModal.js new file mode 100644 index 0000000000000000000000000000000000000000..8f51e77b521469447807ca11747e21d406785dd1 --- /dev/null +++ b/frontend/src/modals/LieferantAddModal.js @@ -0,0 +1,101 @@ +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Col, Button, Form } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +function NeuesLieferantenModal(props) { + + const { apoId } = useParams(); + const { enqueueSnackbar } = useSnackbar(); + + const updateDetails = async event => { + event.preventDefault(); + let { name, plz, ort, strasse, nummer } = event.target; + + let body = { + name: name.value, + anschrift: { + ort: ort.value, + plz: plz.value, + strasse: strasse.value, + nummer: nummer.value + } + } + + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify(body) + }).then((res) => { + if (res.status === 201) { + props.onHide(); + props.updateLieferantData(); + enqueueSnackbar('Lieferant aktualisiert', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 }); + } + }).catch((err) => { + console.log(err); + return; + }); + + + } + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={props.onHide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Benutzer Einstellungen + </Modal.Title> + </Modal.Header> + <Form onSubmit={updateDetails}> + <Modal.Body> + <Form.Row> + <Form.Group as={Col} controlId="name"> + <Form.Label>Name</Form.Label> + <Form.Control name="name" required type="text" /> + </Form.Group> + </Form.Row> + + <Form.Row> + <Form.Group as={Col} sm={9} controlId="strasse"> + <Form.Label>Straße</Form.Label> + <Form.Control name="strasse" required type="text" /> + </Form.Group> + <Form.Group as={Col} sm={3} controlId="nummer"> + <Form.Label>Nummer</Form.Label> + <Form.Control name="nummer" required type="text" /> + </Form.Group> + </Form.Row> + <Form.Row> + <Form.Group as={Col} sm={3} controlId="plz"> + <Form.Label>PLZ</Form.Label> + <Form.Control name="plz" required type="text" /> + </Form.Group> + + <Form.Group as={Col} sm={9} controlId="ort"> + <Form.Label>Ort</Form.Label> + <Form.Control name="ort" required type="text" /> + </Form.Group> + </Form.Row> + </Modal.Body> + <Modal.Footer> + <Button autofocus variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit" >Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) +} + +export default NeuesLieferantenModal; diff --git a/frontend/src/modals/LieferantEditModal.js b/frontend/src/modals/LieferantEditModal.js new file mode 100644 index 0000000000000000000000000000000000000000..1835a76b2b5c9c425e158f62d9faea35f908a2e7 --- /dev/null +++ b/frontend/src/modals/LieferantEditModal.js @@ -0,0 +1,103 @@ +import React from 'react'; +import { useParams } from 'react-router-dom'; +import { Modal, Col, Button, Form } from 'react-bootstrap'; +import { useSnackbar } from 'notistack'; + +function LieferantUpdateModal(props) { + + const { apoId } = useParams(); + const { enqueueSnackbar } = useSnackbar(); + + let { id, name, anschrift } = props.lieferant; + + const updateDetails = async event => { + event.preventDefault(); + let { name, plz, ort, strasse, nummer } = event.target; + + let body = { + name: name.value, + anschrift: { + ort: ort.value, + plz: plz.value, + strasse: strasse.value, + nummer: nummer.value + } + } + + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/lieferant/${id}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + window.sessionStorage.getItem("edbapo-jwt"), + }, + body: JSON.stringify(body) + }).then((res) => { + if (res.status === 200) { + props.onHide(); + props.updateLieferantData(); + enqueueSnackbar('Lieferant aktualisiert', { variant: 'success', autoHideDuration: 3000 }); + } else if (res.status === 400) { + enqueueSnackbar('Ein Fehler ist aufgetaucht', { variant: 'error', autoHideDuration: 3000 }); + } else if (res.status === 403) { + enqueueSnackbar('Falsches Passwort', { variant: 'error', autoHideDuration: 3000 }); + } + }).catch((err) => { + console.log(err); + return; + }); + } + + return ( + <Modal + {...props} + size="lg" + aria-labelledby="contained-modal-title-vcenter" + centered + onExiting={props.onHide} + > + <Modal.Header closeButton> + <Modal.Title id="contained-modal-title-vcenter"> + Benutzer Einstellungen + </Modal.Title> + </Modal.Header> + <Form onSubmit={updateDetails}> + <Modal.Body> + <Form.Row> + <Form.Group as={Col} controlId="name"> + <Form.Label>Name</Form.Label> + <Form.Control name="name" required defaultValue={name} type="text" /> + </Form.Group> + </Form.Row> + + <Form.Row> + <Form.Group as={Col} sm={9} controlId="strasse"> + <Form.Label>Straße</Form.Label> + <Form.Control name="strasse" required type="text" defaultValue={anschrift.strasse} /> + </Form.Group> + <Form.Group as={Col} sm={3} controlId="nummer"> + <Form.Label>Nummer</Form.Label> + <Form.Control name="nummer" required type="text" defaultValue={anschrift.nummer} /> + </Form.Group> + </Form.Row> + <Form.Row> + <Form.Group as={Col} sm={3} controlId="plz"> + <Form.Label>PLZ</Form.Label> + <Form.Control name="plz" required type="text" defaultValue={anschrift.plz} /> + </Form.Group> + + <Form.Group as={Col} sm={9} controlId="ort"> + <Form.Label>Ort</Form.Label> + <Form.Control name="ort" required type="text" defaultValue={anschrift.ort} /> + </Form.Group> + </Form.Row> + </Modal.Body> + <Modal.Footer> + <Button autofocus variant="" onClick={props.onHide}>Abbrechen</Button> + <Button variant="primary" type="submit" >Bestätigen</Button> + </Modal.Footer> + </Form> + </Modal> + ) +} + +export default LieferantUpdateModal; diff --git a/frontend/src/modals/PersonalAddModal.js b/frontend/src/modals/PersonalAddModal.js index 72499ab8cb328949a7867ecca256cb714dcd23ca..298240eb6a286ffe9893608072b15f1e4c013775 100644 --- a/frontend/src/modals/PersonalAddModal.js +++ b/frontend/src/modals/PersonalAddModal.js @@ -5,7 +5,7 @@ import { useSnackbar } from 'notistack'; function PersonalAddModal(props) { - const { id } = useParams(); + const { apoId } = useParams(); const [nutzernameVergeben, setNutzernameVergeben] = useState(false); @@ -32,7 +32,7 @@ function PersonalAddModal(props) { } console.log(body) - fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer`, { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -61,7 +61,7 @@ function PersonalAddModal(props) { return; } - await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer/${newUsername}/checkUsername`, { + await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer/${newUsername}/checkUsername`, { method: 'POST', }).then((res) => { if (res.status === 200) { diff --git a/frontend/src/modals/PersonalEditModal.js b/frontend/src/modals/PersonalEditModal.js index 72b990bd9ef0325043f8e130330930b62f4c82d8..06b56c590680e810dac867a74ea04483da9ce56d 100644 --- a/frontend/src/modals/PersonalEditModal.js +++ b/frontend/src/modals/PersonalEditModal.js @@ -7,9 +7,9 @@ import { useSnackbar } from 'notistack'; function PersonalUpdateModal(props) { - const { id } = useParams(); + const { apoId } = useParams(); - let { nutzername, name, vorname, aktiv, rolle } = props.user; + let { id, nutzername, name, vorname, aktiv, rolle } = props.user; const [nutzernameVergeben, setNutzernameVergeben] = useState(false); //for password checking @@ -36,7 +36,7 @@ function PersonalUpdateModal(props) { if (neuesPasswort.value) { body.newPassword = neuesPasswort.value; } - const response = await fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${id}/benutzer/${props.user.id}`, { + fetch(`http://${process.env.REACT_APP_BACKEND_URL}/apotheke/${apoId}/benutzer/${id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json',