-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-info.tsx
More file actions
executable file
·57 lines (55 loc) · 2.04 KB
/
user-info.tsx
File metadata and controls
executable file
·57 lines (55 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use client";
import { createUser } from "@/api/user";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { CreateUserRequest } from "@/types/user";
import { useMutation } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function UserInfoPage({ email }: { email: string }) {
const router = useRouter();
const [payload, setPayload] = useState<CreateUserRequest>({
firstName: "",
lastName: "",
email: email,
phoneNumber: "",
});
const { isPending, error, mutate } = useMutation({
mutationFn: (payload: CreateUserRequest) => createUser(payload),
onSuccess: () => {
router.push("/");
},
});
return (
<div className="max-w-lg w-full space-y-8">
<div className="flex justify-center">
<label className="block text-4xl text-black font-bold"> Sign Up </label>
</div>
<div className="w-full flex flex-col items-center space-y-4">
<Input
id="name"
name="firstName"
type="name"
placeholder="First Name"
required
onChange={(e) => setPayload({ ...payload, firstName: e.target.value })}
/>
<Input
id="name"
name="lastName"
type="name"
placeholder="Last Name"
required
onChange={(e) => setPayload({ ...payload, lastName: e.target.value })}
/>
</div>
<div className="w-full flex flex-col gap-2 items-center">
<Button type="button" onClick={() => mutate(payload)} disabled={isPending}>
Finish Sign Up
</Button>
{error && <p>Something went wrong</p>}
<p> Forgot Password?</p>
</div>
</div>
);
}