Added survey to web application with the backend working
This commit is contained in:
parent
8424cb346f
commit
e0ffe1a79b
2 changed files with 39 additions and 13 deletions
|
@ -149,6 +149,17 @@ def register():
|
|||
)}
|
||||
return ret, 200
|
||||
|
||||
|
||||
@app.route('/umfrage', methods=['POST'])
|
||||
@flask_praetorian.auth_required
|
||||
def survey():
|
||||
req = flask.request.get_json(force=True)
|
||||
gender = req.get('gender', None)
|
||||
print(req)
|
||||
ret = {'message': 'Umfrage freigestellt'}
|
||||
return ret, 200
|
||||
|
||||
|
||||
@app.route('/time')
|
||||
def get_current_time():
|
||||
return {'time': time.time()}
|
||||
|
|
|
@ -5,6 +5,7 @@ import "../Input.css";
|
|||
import Footer from "../../Footer";
|
||||
import InputField from "../InputField";
|
||||
import SubmitField from "../SubmitField";
|
||||
import { authFetch } from "../../auth/AuthProvider";
|
||||
|
||||
export default function Umfrage() {
|
||||
const [age, setAge] = useState("");
|
||||
|
@ -12,6 +13,8 @@ export default function Umfrage() {
|
|||
const [education, setEducation] = useState("");
|
||||
const [skills, setSkills] = useState("");
|
||||
|
||||
let surveyIsValid = true;
|
||||
|
||||
const onSubmitClick = (e) => {
|
||||
e.preventDefault();
|
||||
let opts = {
|
||||
|
@ -20,20 +23,32 @@ export default function Umfrage() {
|
|||
education: education,
|
||||
skills: skills,
|
||||
};
|
||||
|
||||
if (!Number(age)) {
|
||||
console.log("age is not a number");
|
||||
surveyIsValid = false;
|
||||
}
|
||||
if (gender === "DEFAULT" || gender === "") {
|
||||
console.log("choose gender");
|
||||
surveyIsValid = false;
|
||||
}
|
||||
if (education === "DEFAULT" || education === "") {
|
||||
console.log("choose edu");
|
||||
surveyIsValid = false;
|
||||
}
|
||||
if (skills === "DEFAULT" || skills === "") {
|
||||
console.log("choose skills");
|
||||
surveyIsValid = false;
|
||||
}
|
||||
|
||||
if (surveyIsValid === true) {
|
||||
console.log(opts);
|
||||
/*fetch("/api/login", {
|
||||
}
|
||||
|
||||
authFetch("/umfrage", {
|
||||
method: "post",
|
||||
body: JSON.stringify(opts),
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then((token) => {
|
||||
if (token.access_token) {
|
||||
login(token);
|
||||
} else {
|
||||
console.log("Please type in the correct username / password");
|
||||
}
|
||||
});
|
||||
*/
|
||||
};
|
||||
|
||||
const handleAgeChange = (e) => {
|
||||
|
|
Loading…
Reference in a new issue