Create src/auth/Register.tsx
Browse files- src/auth/Register.tsx +41 -0
src/auth/Register.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from "react";
|
| 2 |
+
import api from "../api";
|
| 3 |
+
import { useNavigate } from "react-router-dom";
|
| 4 |
+
|
| 5 |
+
export default function Register() {
|
| 6 |
+
const [email, setEmail] = useState("");
|
| 7 |
+
const [password, setPassword] = useState("");
|
| 8 |
+
const nav = useNavigate();
|
| 9 |
+
|
| 10 |
+
async function submit() {
|
| 11 |
+
await api.post("/auth/register", { email, password });
|
| 12 |
+
nav("/login");
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
return (
|
| 16 |
+
<div className="min-h-screen flex items-center justify-center">
|
| 17 |
+
<div className="bg-zinc-900 p-6 rounded-xl w-80 space-y-4">
|
| 18 |
+
<h1 className="text-xl font-bold">Register</h1>
|
| 19 |
+
|
| 20 |
+
<input
|
| 21 |
+
className="w-full p-2 rounded bg-zinc-800"
|
| 22 |
+
placeholder="Email"
|
| 23 |
+
onChange={(e) => setEmail(e.target.value)}
|
| 24 |
+
/>
|
| 25 |
+
<input
|
| 26 |
+
type="password"
|
| 27 |
+
className="w-full p-2 rounded bg-zinc-800"
|
| 28 |
+
placeholder="Password"
|
| 29 |
+
onChange={(e) => setPassword(e.target.value)}
|
| 30 |
+
/>
|
| 31 |
+
|
| 32 |
+
<button
|
| 33 |
+
onClick={submit}
|
| 34 |
+
className="w-full bg-green-600 p-2 rounded hover:bg-green-500"
|
| 35 |
+
>
|
| 36 |
+
Create account
|
| 37 |
+
</button>
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
);
|
| 41 |
+
}
|