Admin verification
This commit is contained in:
@@ -3,6 +3,10 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
|
Dropdown,
|
||||||
|
DropdownItem,
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownTrigger,
|
||||||
ScrollShadow,
|
ScrollShadow,
|
||||||
} from "@nextui-org/react";
|
} from "@nextui-org/react";
|
||||||
import {
|
import {
|
||||||
@@ -14,6 +18,7 @@ import {
|
|||||||
GiftTopIcon,
|
GiftTopIcon,
|
||||||
ChatBubbleOvalLeftIcon,
|
ChatBubbleOvalLeftIcon,
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
|
ArrowRightStartOnRectangleIcon,
|
||||||
} from "../icons";
|
} from "../icons";
|
||||||
import EcoconnectFullLogo from "./EcoconnectFullLogo";
|
import EcoconnectFullLogo from "./EcoconnectFullLogo";
|
||||||
import { retrieveUserInformation } from "../security/users";
|
import { retrieveUserInformation } from "../security/users";
|
||||||
@@ -176,26 +181,42 @@ export default function AdministratorNavigationPanel() {
|
|||||||
</div>
|
</div>
|
||||||
</ScrollShadow>
|
</ScrollShadow>
|
||||||
<div className="bg-primary-500 p-1">
|
<div className="bg-primary-500 p-1">
|
||||||
<Button variant="light" className="h-full w-full p-2">
|
<Dropdown placement="top-start">
|
||||||
<div className="flex flex-row w-full justify-start">
|
<DropdownTrigger>
|
||||||
<div className="flex flex-row w-full gap-3 *:my-auto text-white">
|
<Button variant="light" className="h-full w-full p-2">
|
||||||
<Avatar src={userProfileImageURL} />
|
<div className="flex flex-row w-full justify-start">
|
||||||
<div className="flex flex-col h-full text-left">
|
<div className="flex flex-row w-full gap-3 *:my-auto text-white">
|
||||||
<p className="font-semibold">
|
<Avatar src={userProfileImageURL} />
|
||||||
{userInformation.firstName +
|
<div className="flex flex-col h-full text-left">
|
||||||
" " +
|
<p className="font-semibold">
|
||||||
userInformation.lastName}
|
{userInformation.firstName +
|
||||||
</p>
|
" " +
|
||||||
<p className="text-sm opacity-70">
|
userInformation.lastName}
|
||||||
{userInformation.email}
|
</p>
|
||||||
</p>
|
<p className="text-sm opacity-70">
|
||||||
<p className="text-sm opacity-70">
|
{userInformation.email}
|
||||||
+65 {userInformation.phoneNumber}
|
</p>
|
||||||
</p>
|
<p className="text-sm opacity-70">
|
||||||
|
+65 {userInformation.phoneNumber}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Button>
|
||||||
</div>
|
</DropdownTrigger>
|
||||||
</Button>
|
<DropdownMenu>
|
||||||
|
<DropdownItem
|
||||||
|
key="signout"
|
||||||
|
startContent={<ArrowRightStartOnRectangleIcon />}
|
||||||
|
color="danger"
|
||||||
|
title="Sign out"
|
||||||
|
onPress={() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.reload();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</DropdownMenu>
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import NextUIFormikInput from "./NextUIFormikInput";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { ChevronLeftIcon } from "../icons";
|
import { ChevronLeftIcon } from "../icons";
|
||||||
import { popErrorToast } from "../utilities";
|
import { popErrorToast } from "../utilities";
|
||||||
|
import { retrieveUserInformation } from "../security/users";
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
email: Yup.string()
|
email: Yup.string()
|
||||||
@@ -39,7 +40,13 @@ export default function SignInModule() {
|
|||||||
.post(config.serverAddress + "/users/login", values)
|
.post(config.serverAddress + "/users/login", values)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
localStorage.setItem("accessToken", response.data.accessToken);
|
localStorage.setItem("accessToken", response.data.accessToken);
|
||||||
navigate("/springboard/");
|
retrieveUserInformation().then((value) => {
|
||||||
|
if (value.accountType == 2) {
|
||||||
|
navigate("/admin");
|
||||||
|
} else {
|
||||||
|
navigate("/springboard/");
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
popErrorToast(error);
|
popErrorToast(error);
|
||||||
|
|||||||
@@ -29,9 +29,12 @@ export default function AdministratorSpringboard() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
retrieveUserInformation()
|
retrieveUserInformation()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
if (response.accountType != 2) {
|
||||||
|
navigate("/");
|
||||||
|
}
|
||||||
setUserInformation(response);
|
setUserInformation(response);
|
||||||
})
|
})
|
||||||
.catch((_) => {
|
.catch(() => {
|
||||||
navigate("/signin");
|
navigate("/signin");
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user