Compare commits

..

No commits in common. "a373ad4dce0adcbbd4fd5e2c542a16c60c3fbfa7" and "8e6a74d30c50c6943679ba782bca187e570ecc0a" have entirely different histories.

4 changed files with 17 additions and 41 deletions

View file

@ -95,5 +95,4 @@ h1 {
.generated-password { .generated-password {
font-weight: bold; font-weight: bold;
user-select: none;
} }

View file

@ -10,6 +10,7 @@ export default function BehaviorNormal(props) {
Passwort eingeben. Verhalten Sie sich einfach so, als ob Sie sich Passwort eingeben. Verhalten Sie sich einfach so, als ob Sie sich
normalerweise anmelden. normalerweise anmelden.
</p> </p>
{console.log("props", props)}
<GeneratedPassword genPassword={props.genPassword} /> <GeneratedPassword genPassword={props.genPassword} />
</> </>
); );

View file

@ -9,8 +9,9 @@ export default function GeneratedPassword(props) {
return ( return (
<> <>
<p> <p onCopy={handleOnCopyEvent}>
Das Passwort für diese Situation lautet:{" "} Das Passwort für diese Situation lautet:{" "}
{console.log("component genpw, genpassword", props.genPassword)}
<span className="generated-password">{props.genPassword}</span> <span className="generated-password">{props.genPassword}</span>
</p> </p>
</> </>

View file

@ -3,7 +3,6 @@ import "../../App.css";
import Footer from "../../Footer"; import Footer from "../../Footer";
import InputField from "../InputField"; import InputField from "../InputField";
import SubmitField from "../SubmitField"; import SubmitField from "../SubmitField";
import ErrorMessage from "../ErrorMessage";
import { Logger } from "@behametrics/logger-web"; import { Logger } from "@behametrics/logger-web";
import { Button } from "../Button"; import { Button } from "../Button";
import BehaviorStudyInfo from "../BehaviorStudyInfo"; import BehaviorStudyInfo from "../BehaviorStudyInfo";
@ -25,10 +24,6 @@ export default function Study() {
END: "end", END: "end",
}; };
const [state, setState] = useState(STATES.START); const [state, setState] = useState(STATES.START);
const [isInputCorrect, setIsInputCorrect] = useState(true);
const errorText =
"Das Passwort und der Benutzername stimmen nicht überein. Bitte prüfen Sie, dass Sie das Passwort richtig abgetippt und den Benutzernamen richtig eingegeben haben.";
useEffect(() => { useEffect(() => {
_logger.current = new Logger({ _logger.current = new Logger({
@ -78,10 +73,7 @@ export default function Study() {
const handleOnPasteEvent = (e) => { const handleOnPasteEvent = (e) => {
e.preventDefault(); e.preventDefault();
return false; console.log("paste not allowed");
};
const handleOnCopyEvent = (e) => {
e.preventDefault();
return false; return false;
}; };
@ -96,6 +88,7 @@ export default function Study() {
response.json().then((resp) => { response.json().then((resp) => {
console.log(resp.random_password); console.log(resp.random_password);
setGenPassword(resp.random_password); setGenPassword(resp.random_password);
console.log("rcv pw; print genPassword", genPassword);
}); });
}); });
}; };
@ -105,6 +98,7 @@ export default function Study() {
}; };
const checkIfValuesAreCorrect = () => { const checkIfValuesAreCorrect = () => {
console.log(checkIfPasswordIsCorrect());
return checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect(); return checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect();
}; };
@ -114,44 +108,28 @@ export default function Study() {
handleLoggerOn(); handleLoggerOn();
}; };
const resetInputValues = () => {
let inputElements = document.querySelectorAll('div input:not([type="submit"])');
for (let i=0; i < inputElements.length; i++){
inputElements[i].value = ""
}
};
const handleClickAtStepNormal = () => { const handleClickAtStepNormal = () => {
if (checkIfValuesAreCorrect()) { if (checkIfValuesAreCorrect()) {
receiveRandomPassword(); receiveRandomPassword();
setIsInputCorrect(true);
setState(STATES.PHONE); setState(STATES.PHONE);
} else {
setIsInputCorrect(false);
resetInputValues();
} }
}; };
const handleClickAtStepPhone = () => { const handleClickAtStepPhone = () => {
if (checkIfValuesAreCorrect()) { if (checkIfValuesAreCorrect()) {
receiveRandomPassword(); receiveRandomPassword();
setIsInputCorrect(true);
setState(STATES.STANDING); setState(STATES.STANDING);
} else { } else {
setIsInputCorrect(false); console.log("Passwort und Benutzername stimmen nicht.");
resetInputValues();
} }
}; };
const handleClickAtStepStanding = () => { const handleClickAtStepStanding = () => {
if (checkIfValuesAreCorrect()) { if (checkIfValuesAreCorrect()) {
setIsInputCorrect(true);
setState(STATES.END); setState(STATES.END);
handleLoggerOff(); handleLoggerOff();
} else { } else {
setIsInputCorrect(false); console.log("Passwort und Benutzername stimmen nicht.");
resetInputValues();
} }
}; };
@ -172,9 +150,8 @@ export default function Study() {
const study_normal = ( const study_normal = (
<> <>
<BehaviorNormal onCopy={handleOnCopyEvent} genPassword={genPassword} /> <BehaviorNormal genPassword={genPassword} />
{!isInputCorrect && <ErrorMessage message={errorText} />} <form id="behaviorNormal">
<div>
<InputField <InputField
LabelName="Benutzername" LabelName="Benutzername"
onChange={handleUsernameChange} onChange={handleUsernameChange}
@ -188,7 +165,7 @@ export default function Study() {
onChange={handlePasswordChange} onChange={handlePasswordChange}
InputType="password" InputType="password"
InputName="Passwort" InputName="Passwort"
InputPlaceHolder="Passwort" InputPlaceHolder="Benutzername"
onPaste={handleOnPasteEvent} onPaste={handleOnPasteEvent}
/> />
<SubmitField <SubmitField
@ -197,15 +174,14 @@ export default function Study() {
InputName="Weiter" InputName="Weiter"
onClick={handleClickAtStepNormal} onClick={handleClickAtStepNormal}
/> />
</div> </form>
</> </>
); );
const study_phone = ( const study_phone = (
<> <>
<BehaviorPhone genPassword={genPassword} /> <BehaviorPhone genPassword={genPassword} />
{!isInputCorrect && <ErrorMessage message={errorText} />} <form id="behaviorPhone">
<div>
<InputField <InputField
LabelName="Benutzername" LabelName="Benutzername"
onChange={handleUsernameChange} onChange={handleUsernameChange}
@ -219,7 +195,7 @@ export default function Study() {
onChange={handlePasswordChange} onChange={handlePasswordChange}
InputType="password" InputType="password"
InputName="Passwort" InputName="Passwort"
InputPlaceHolder="Passwort" InputPlaceHolder="Benutzername"
onPaste={handleOnPasteEvent} onPaste={handleOnPasteEvent}
/> />
<SubmitField <SubmitField
@ -228,15 +204,14 @@ export default function Study() {
InputName="Weiter" InputName="Weiter"
onClick={handleClickAtStepPhone} onClick={handleClickAtStepPhone}
/> />
</div> </form>
</> </>
); );
const study_standing = ( const study_standing = (
<> <>
<BehaviorStanding genPassword={genPassword} /> <BehaviorStanding genPassword={genPassword} />
{!isInputCorrect && <ErrorMessage message={errorText} />} <form id="behaviorStanding">
<div>
<InputField <InputField
LabelName="Benutzername" LabelName="Benutzername"
onChange={handleUsernameChange} onChange={handleUsernameChange}
@ -259,7 +234,7 @@ export default function Study() {
InputName="quit" InputName="quit"
onClick={handleClickAtStepStanding} onClick={handleClickAtStepStanding}
/> />
</div> </form>
</> </>
); );