Compare commits

..

No commits in common. "e762032f00c43d17615e0d7d7f4fc1ace29dd923" and "fd205273fca7e5310b0ac33a5fccd3e7dabb815c" have entirely different histories.

5 changed files with 47 additions and 37 deletions

View file

@ -4,15 +4,15 @@ import "./App.css";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "./components/pages/Home";
import Ueber from "./components/pages/Ueber";
import Lizenzen from "./components/pages/Lizenzen";
import Lizenzen from "./components/pages/lizenzen";
import Privacy from "./components/pages/Privacy";
import Login from "./components/pages/Login";
import Register from "./components/pages/Register";
import Manual from "./components/pages/Manual";
import Secret from "./components/pages/Secret";
import Umfrage from "./components/pages/Umfrage";
import PrivateRoute from "./auth/PrivateRoute";
import Study from "./components/pages/Study";
import Secret from "./components/pages/Secret";
function App() {
return (

View file

@ -44,17 +44,11 @@ function Navbar() {
Startseite
</Link>
</li>
{isLoggedIn && (
<li className="nav-item">
<Link
to="/study"
className="nav-links"
onClick={closeMobileMenu}
>
Studie
</Link>
</li>
)}
<li className="nav-item">
<Link to="/study" className="nav-links" onClick={closeMobileMenu}>
Studie
</Link>
</li>
<li className="nav-item">
<Link to="/Ueber" className="nav-links" onClick={closeMobileMenu}>
Über

View file

@ -15,15 +15,6 @@ import { authFetch } from "../../auth/AuthProvider";
export default function Study() {
const _logger = useRef(0);
const [serverUsername, setServerUsername] = useState("");
const [genPassword, setGenPassword] = useState("");
const STATES = {
START: "start",
NORMAL: "normal",
PHONE: "phone",
STANDING: "standing",
END: "end",
};
const [state, setState] = useState(STATES.START);
useEffect(() => {
_logger.current = new Logger({
@ -53,6 +44,12 @@ export default function Study() {
password = tmp_password;
};
const [isStepStart, setIsStepStart] = useState(true);
const [isStepNormal, setIsStepNormal] = useState(false);
const [isStepPhone, setIsStepPhone] = useState(false);
const [isStepStanding, setIsStepStanding] = useState(false);
const [isStepEnd, setIsStepEnd] = useState(false);
const handleLoggerOff = () => {
_logger.current.stop();
console.log("Logger ausgeschaltet");
@ -78,9 +75,15 @@ export default function Study() {
};
const checkIfUsernameIsCorrect = () => {
return serverUsername === username;
if (serverUsername === username) {
return true;
} else {
return false;
}
};
const [genPassword, setGenPassword] = useState("");
const receiveRandomPassword = () => {
fetch("/api/rcv_pw", {
method: "get",
@ -94,31 +97,43 @@ export default function Study() {
};
const checkIfPasswordIsCorrect = () => {
return genPassword === password;
if (genPassword === password) {
return true;
} else {
return false;
}
};
const checkIfValuesAreCorrect = () => {
console.log(checkIfPasswordIsCorrect());
return checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect();
if (checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect()) {
return true;
} else {
alert("Passt nicht");
return false;
}
};
const handleClickAtStepStart = () => {
receiveRandomPassword();
setState(STATES.NORMAL);
setIsStepStart(false);
setIsStepNormal(true);
handleLoggerOn();
};
const handleClickAtStepNormal = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
setState(STATES.PHONE);
setIsStepNormal(false);
setIsStepPhone(true);
}
};
const handleClickAtStepPhone = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
setState(STATES.STANDING);
setIsStepPhone(false);
setIsStepStanding(true);
} else {
console.log("Passwort und Benutzername stimmen nicht.");
}
@ -126,7 +141,8 @@ export default function Study() {
const handleClickAtStepStanding = () => {
if (checkIfValuesAreCorrect()) {
setState(STATES.END);
setIsStepStanding(false);
setIsStepEnd(true);
handleLoggerOff();
} else {
console.log("Passwort und Benutzername stimmen nicht.");
@ -225,7 +241,7 @@ export default function Study() {
onChange={handlePasswordChange}
InputType="password"
InputName="Passwort"
InputPlaceHolder="Passwort"
InputPlaceHolder="Benutzername"
onPaste={handleOnPasteEvent}
/>
<SubmitField
@ -244,11 +260,11 @@ export default function Study() {
<>
<div className="sitePage">
<h1>Studie</h1>
{state === STATES.START ? study_start : null}
{state === STATES.NORMAL ? study_normal : null}
{state === STATES.PHONE ? study_phone : null}
{state === STATES.STANDING ? study_standing : null}
{state === STATES.END ? study_end : null}
{isStepStart ? study_start : null}
{isStepNormal ? study_normal : null}
{isStepPhone ? study_phone : null}
{isStepStanding ? study_standing : null}
{isStepEnd ? study_end : null}
</div>
<Footer />
</>

View file

@ -51,8 +51,8 @@ export default function Umfrage() {
if (!Number(age)) {
setAgeErrorMessage("Das Alter muss als Zahl angegeben werden.");
setIsSurveyValid(false);
setIsAgeOk(false);
//setIsSurveyValid(false);
// setIsAgeOk(false);
}
if (gender === "DEFAULT" || gender === "") {
setGenderErrorMessage(