Skip to content

Commit

Permalink
improved user feedback for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Brennan authored and Jon Brennan committed Nov 18, 2023
1 parent aa2b9af commit bec74b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const DungeonThrowdown = {

const movementRoll = random.D6(2);
const movementTotal = movementRoll[0] + movementRoll[1];
// currentPlayer.moveTiles = movementTotal;
currentPlayer.moveTiles = movementTotal;
// console.log(
// `${currentPlayer.name} rolled ${movementRoll[0]} and ${movementRoll[1]} for a total of ${movementTotal} movement tiles`
// );
Expand Down
11 changes: 8 additions & 3 deletions src/components/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const Login = () => {
password: "",
});

const [message, setMessage] = useState("LOGIN");

const handleInputChange = (event) => {
setFormData((currentFormData) => {
return {
Expand All @@ -30,7 +32,7 @@ const Login = () => {
body: JSON.stringify(formData),
});

// console.log(response);
console.log(response);

if (response.ok) {
console.log("Login successful!");
Expand All @@ -40,12 +42,15 @@ const Login = () => {
localStorage.setItem("currentUser", JSON.stringify(data));
navigate("/game");
}
} else {
console.log("Login failed.");
setMessage("Something went wrong, please try again");
}
};

return (
<div className="auth-component">
<h1>LOGIN</h1>
<h1>{message}</h1>
<form onSubmit={handleLogin}>
<input
type="text"
Expand All @@ -61,7 +66,7 @@ const Login = () => {
/>
<button type="submit">Login</button>
</form>
<p> </p>
<p></p>
</div>
);
};
Expand Down
7 changes: 3 additions & 4 deletions src/components/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Signup = () => {
confirmPassword: "",
});

const [signupStatus, setSignupStatus] = useState(null);
const [signupStatus, setSignupStatus] = useState("CREATE ACCOUNT");

const handleSignup = async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -38,7 +38,7 @@ const Signup = () => {
console.log(response);

if (response.ok) {
setSignupStatus("You can now login!");
setSignupStatus("SUCCESS! You can now login");
} else {
setSignupStatus("Something went wrong...");
}
Expand All @@ -55,7 +55,7 @@ const Signup = () => {

return (
<div className="auth-component">
<h1>CREATE ACCOUNT</h1>
<h1>{signupStatus}</h1>
<form onSubmit={handleSignup}>
<input
type="text"
Expand All @@ -77,7 +77,6 @@ const Signup = () => {
/>
<button type="submit">Signup</button>
</form>
<p>{signupStatus}</p>
</div>
);
};
Expand Down

0 comments on commit bec74b1

Please sign in to comment.