mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2024-11-17 06:29:28 +08:00
Added activation page
This commit is contained in:
parent
4caf7479fd
commit
115b8b207f
3 changed files with 58 additions and 0 deletions
|
@ -65,3 +65,21 @@ export function UserInfo() {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface activation {
|
||||||
|
uid: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UserActivate(activation: activation) {
|
||||||
|
return axios
|
||||||
|
.post("http://localhost:8000/api/v1/accounts/users/activation/", activation)
|
||||||
|
.then(async (response) => {
|
||||||
|
console.log("Activation Success");
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log("Activation failed: " + error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
35
src/Routes/Activation/Activation.tsx
Normal file
35
src/Routes/Activation/Activation.tsx
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import styles from "../../styles";
|
||||||
|
import Header from "../../Components/Header/Header";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { UserActivate } from "../../Components/Api/Api";
|
||||||
|
|
||||||
|
export interface activation {
|
||||||
|
uid: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
export default function Activation() {
|
||||||
|
let { uid, token } = useParams();
|
||||||
|
const [activationStatus, setStatus] = useState("Activating...");
|
||||||
|
async function verify(activation: activation) {
|
||||||
|
let status = await UserActivate(activation);
|
||||||
|
if (status) {
|
||||||
|
setStatus("Success!");
|
||||||
|
} else {
|
||||||
|
setStatus("Invalid Activation Link");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uid && token) {
|
||||||
|
verify({ uid, token });
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div style={styles.background}>
|
||||||
|
<Header />
|
||||||
|
<div style={styles.note}>
|
||||||
|
<p style={styles.text_medium}>User ID: {uid}</p>
|
||||||
|
<p style={styles.text_medium}>Activation Token: {token}</p>
|
||||||
|
<p style={styles.text_medium}>{activationStatus}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
import Home from "./Routes/Home/Home";
|
import Home from "./Routes/Home/Home";
|
||||||
import NewNote from "./Routes/NewNote/NewNote";
|
import NewNote from "./Routes/NewNote/NewNote";
|
||||||
import Login from "./Routes/Login/Login";
|
import Login from "./Routes/Login/Login";
|
||||||
|
import Activation from "./Routes/Activation/Activation";
|
||||||
|
|
||||||
import { QueryClient, QueryClientProvider } from "react-query";
|
import { QueryClient, QueryClientProvider } from "react-query";
|
||||||
|
|
||||||
|
@ -28,6 +29,10 @@ const router = createBrowserRouter([
|
||||||
path: "/Login",
|
path: "/Login",
|
||||||
element: <Login />,
|
element: <Login />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/Activation/:uid/:token",
|
||||||
|
element: <Activation />,
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
|
|
Loading…
Reference in a new issue