mirror of
https://github.com/Ategon/Jamjar.git
synced 2025-02-12 06:16:21 +00:00
Add email to sign up
This commit is contained in:
parent
7a5cbfdfba
commit
eb54bd588a
2 changed files with 37 additions and 1 deletions
|
@ -15,6 +15,7 @@ export default function UserPage() {
|
||||||
const [user, setUser] = useState<UserType>();
|
const [user, setUser] = useState<UserType>();
|
||||||
const [profilePicture, setProfilePicture] = useState<string | null>(null);
|
const [profilePicture, setProfilePicture] = useState<string | null>(null);
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
|
const [email, setEmail] = useState("");
|
||||||
const [bannerPicture, setBannerPicture] = useState<string | null>(null);
|
const [bannerPicture, setBannerPicture] = useState<string | null>(null);
|
||||||
const [bio, setBio] = useState("");
|
const [bio, setBio] = useState("");
|
||||||
const [errors] = useState({});
|
const [errors] = useState({});
|
||||||
|
@ -48,6 +49,7 @@ export default function UserPage() {
|
||||||
setBannerPicture(data.bannerPicture ?? "");
|
setBannerPicture(data.bannerPicture ?? "");
|
||||||
setBio(data.bio ?? "");
|
setBio(data.bio ?? "");
|
||||||
setName(data.name ?? "");
|
setName(data.name ?? "");
|
||||||
|
setEmail(data.email ?? "");
|
||||||
} else {
|
} else {
|
||||||
setUser(undefined);
|
setUser(undefined);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +94,7 @@ export default function UserPage() {
|
||||||
profilePicture: profilePicture,
|
profilePicture: profilePicture,
|
||||||
bannerPicture: bannerPicture,
|
bannerPicture: bannerPicture,
|
||||||
targetUserSlug: user.slug,
|
targetUserSlug: user.slug,
|
||||||
|
email: email,
|
||||||
}),
|
}),
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -124,6 +127,16 @@ export default function UserPage() {
|
||||||
onValueChange={setName}
|
onValueChange={setName}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="Email"
|
||||||
|
labelPlacement="outside"
|
||||||
|
name="email"
|
||||||
|
placeholder="Enter an email"
|
||||||
|
type="text"
|
||||||
|
value={email}
|
||||||
|
onValueChange={setEmail}
|
||||||
|
/>
|
||||||
|
|
||||||
<p>Bio</p>
|
<p>Bio</p>
|
||||||
<Editor content={bio} setContent={setBio} />
|
<Editor content={bio} setContent={setBio} />
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ export default function UserPage() {
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [password2, setPassword2] = useState("");
|
const [password2, setPassword2] = useState("");
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
const [email, setEmail] = useState("");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute flex items-center justify-center top-0 left-0 w-screen h-screen">
|
<div className="absolute flex items-center justify-center top-0 left-0 w-screen h-screen">
|
||||||
|
@ -66,12 +67,24 @@ export default function UserPage() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
const regex = /.+@.+\..+/;
|
||||||
|
if (!email.match(regex)) {
|
||||||
|
setErrors({ email: "Invalid email" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
process.env.NEXT_PUBLIC_MODE === "PROD"
|
process.env.NEXT_PUBLIC_MODE === "PROD"
|
||||||
? "https://d2jam.com/api/v1/user"
|
? "https://d2jam.com/api/v1/user"
|
||||||
: "http://localhost:3005/api/v1/user",
|
: "http://localhost:3005/api/v1/user",
|
||||||
{
|
{
|
||||||
body: JSON.stringify({ username: username, password: password }),
|
body: JSON.stringify({
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
email: email,
|
||||||
|
}),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
|
@ -104,6 +117,16 @@ export default function UserPage() {
|
||||||
onValueChange={setUsername}
|
onValueChange={setUsername}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="Email"
|
||||||
|
labelPlacement="outside"
|
||||||
|
name="email"
|
||||||
|
placeholder="Optional"
|
||||||
|
type="text"
|
||||||
|
value={email}
|
||||||
|
onValueChange={setEmail}
|
||||||
|
/>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
isRequired
|
isRequired
|
||||||
label="Password"
|
label="Password"
|
||||||
|
|
Loading…
Reference in a new issue