frontend/src/pages/SignUp.jsx

78 lines
1.7 KiB
React
Raw Normal View History

2025-04-16 12:02:42 -07:00
import React from "react";
function SignUpForm() {
2025-04-28 11:12:10 -07:00
const authUrl = import.meta.env.VITE_AUTH_URL;
2025-04-16 12:02:42 -07:00
const [state, setState] = React.useState({
name: "",
email: "",
password: "",
});
const handleChange = (evt) => {
const value = evt.target.value;
setState({
...state,
[evt.target.name]: value,
});
};
const handleOnSubmit = (evt) => {
evt.preventDefault();
const { name, email, password } = state;
alert(
`You are signed in with name: ${name} email: ${email} and password: ${password}`
2025-04-16 12:02:42 -07:00
);
for (const key in state) {
setState({
...state,
[key]: "",
});
}
};
2025-04-21 18:32:13 -07:00
const googleAuth = () => {
2025-04-28 11:12:10 -07:00
window.open(authUrl, "_self");
2025-04-21 18:32:13 -07:00
};
2025-04-16 12:02:42 -07:00
return (
<div className="form-container sign-up-container">
<form onSubmit={handleOnSubmit}>
<h1>Instructor</h1>
2025-04-16 12:02:42 -07:00
<div className="social-container">
2025-04-21 18:32:13 -07:00
<a href="#" className="social" onClick={googleAuth}>
2025-04-16 12:02:42 -07:00
<i className="fab fa-google-plus-g" />
</a>
</div>
<span>or use your email for registration</span>
<input
type="text"
name="name"
value={state.name}
onChange={handleChange}
placeholder="Name"
/>
<input
type="email"
name="email"
value={state.email}
onChange={handleChange}
placeholder="Email"
/>
<input
type="password"
name="password"
value={state.password}
onChange={handleChange}
placeholder="Password"
/>
<button>Sign in</button>
2025-04-16 12:02:42 -07:00
</form>
</div>
);
}
export default SignUpForm;