Add: Simple user login/register function

This commit is contained in:
2021-12-11 18:47:25 +08:00
parent c580ca245f
commit f3a95973e9
11 changed files with 379 additions and 13 deletions

View File

@@ -1,6 +1,9 @@
import { useState } from "react";
import { useNavigate } from "react-router";
function Manage(props) {
let navigate = useNavigate();
function Manage() {
const [token, setToken] = useState("");
const [walkPath, setWalkPath] = useState("");
@@ -25,6 +28,20 @@ function Manage() {
return (
<div>
<h2>Manage</h2>
<p>Hi, {props.user.username}</p>
{props.user.role === 0 && (
<button
onClick={() => {
navigate("/manage/login");
}}
>
Login
</button>
)}
{props.user.role !== 0 && (
<button onClick={() => props.setUser({})}>Logout</button>
)}
<hr />
<input
type="text"
value={token}