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
+Username
+ + { + setUser({ ...user, username: e.target.value }); + }} + maxLength={20} + /> +Password
+ + { + setUser({ ...user, password: e.target.value }); + }} + maxLength={20} + /> +{feedback}
+