diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx index b0ad2bf..a9478b3 100644 --- a/src/Components/Api/Api.tsx +++ b/src/Components/Api/Api.tsx @@ -26,6 +26,24 @@ export function DeleteNote(id: number) { } // User APIs +export interface register { + email: string; + username: string; + password: string; +} + +export function UserRegister(register: register) { + return axios + .post("http://localhost:8000/api/v1/accounts/users/", register) + .then(async (response) => { + console.log(response.data); + return true; + }) + .catch((error) => { + console.log("Registration failed: " + error); + return false; + }); +} export interface user { username: string; diff --git a/src/Routes/Register/Register.tsx b/src/Routes/Register/Register.tsx new file mode 100644 index 0000000..ecff80a --- /dev/null +++ b/src/Routes/Register/Register.tsx @@ -0,0 +1,83 @@ +import * as React from "react"; +import styles from "../../styles"; + +import { useNavigate } from "react-router-dom"; +import Header from "../../Components/Header/Header"; +import { useState } from "react"; +import { Button } from "@mui/material"; +import { UserInfo, UserLogin } from "../../Components/Api/Api"; + +import { UserRegister } from "../../Components/Api/Api"; + +export default function Register() { + const navigate = useNavigate(); + const [user, setUser] = useState({ + email: "", + username: "", + password: "", + }); + const [feedback, setFeedback] = useState(""); + return ( +
+
+
+

Create an Account

+
+

Email

+
+ { + setUser({ ...user, email: e.target.value }); + }} + maxLength={20} + /> +
+
+

Username

+
+ { + setUser({ ...user, username: e.target.value }); + }} + maxLength={20} + /> +
+
+

Password

+
+ { + setUser({ ...user, password: e.target.value }); + }} + maxLength={20} + /> +
+ +

{feedback}

+
+
+ ); +} diff --git a/src/index.tsx b/src/index.tsx index a2f5a4d..2adba04 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,6 +8,7 @@ import Home from "./Routes/Home/Home"; import NewNote from "./Routes/NewNote/NewNote"; import Login from "./Routes/Login/Login"; import Activation from "./Routes/Activation/Activation"; +import Register from "./Routes/Register/Register"; import { QueryClient, QueryClientProvider } from "react-query"; @@ -29,6 +30,10 @@ const router = createBrowserRouter([ path: "/Login", element: , }, + { + path: "/Register", + element: , + }, { path: "/Activation/:uid/:token", element: ,