import React, { useEffect, useRef, useState } from "react"; import "../../App.css"; import Footer from "../../Footer"; import InputField from "../InputField"; import SubmitField from "../SubmitField"; import { Logger } from "@behametrics/logger-web"; import BehaviorStudyInfo from "../BehaviorStudyInfo"; import BehaviorNormal from "../BehaviorNormal"; import { Button } from "../Button"; import BehaviorPhone from "../BehaviorPhone"; import BehaviorStanding from "../BehaviorStanding"; export default function Study() { const _logger = useRef(0); useEffect(() => { _logger.current = new Logger({ //inputs: ["cursor", "wheel", "keyboard", "touch"], inputs: ["keyboard"], // apiUrl: "https://behavior.marcocamenzind.ch", apiUrl: "http://localhost:5000", logToConsole: true, }); _logger.current.init(); }, []); let username = ""; const setUsername = (tmp_username) => { username = tmp_username; }; let password = ""; const setPassword = (tmp_password) => { 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"); }; const handleLoggerOn = () => { _logger.current.start(); console.log("start logging "); }; const handlePasswordChange = (e) => { setPassword(e.target.value); }; const handleUsernameChange = (e) => { setUsername(e.target.value); }; const handleOnPasteEvent = (e) => { e.preventDefault(); return false; }; const handleClickAtStepStart = () => { setIsStepStart(false); setIsStepNormal(true); handleLoggerOn(); // forceUpdate(); }; const handleClickAtStepNormal = () => { setIsStepNormal(false); setIsStepPhone(true); }; const handleClickAtStepPhone = () => { setIsStepPhone(false); setIsStepStanding(true); }; const handleClickAtStepStanding = () => { setIsStepStanding(false); setIsStepEnd(true); handleLoggerOff(); }; const onSubmitClick = (e) => { e.preventDefault(); let opts = { username: username, password: password, }; fetch("/api/protected/behavior", { method: "post", body: JSON.stringify(opts), }).then((response) => { console.log(response.status); if (response.status === 401) { response.json().then((resp) => { console.log("nicht so wirklich gut"); // setErrorMessage(resp.message); }); } else { response.json().then((token) => { console.log("Alles gut :-)"); }); } }); }; const study_start = ( <> ); const study_normal = ( <>
); const study_phone = ( <>
); const study_standing = ( <>
); const study_end =

Merci :-)

; return ( <>

Studie

{isStepStart ? study_start : null} {isStepNormal ? study_normal : null} {isStepPhone ? study_phone : null} {isStepStanding ? study_standing : null} {isStepEnd ? study_end : null}