diff --git a/README.md b/README.md index 5a343d2..4218c2c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Blueprint Admin ## Overview React Web Application that will serve as an admin dashboard to manage members, and permission of Stevens Blueprint. The main purpose of the web application is to provide a tool for the Blueprint eboard to manage Blueprint members and display statistics about them. Stevens Blueprint uses Authelia as SSO, therefore to log in members should be signed in. - ## Features The Blueprint Admin will provide means for Blueprint members to do the following: diff --git a/src/components/CreateUserButton.tsx b/src/components/CreateUserButton.tsx new file mode 100644 index 0000000..150b59a --- /dev/null +++ b/src/components/CreateUserButton.tsx @@ -0,0 +1,119 @@ +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton, + Button, + FormControl, + FormLabel, + Input, + useDisclosure, + Alert, + AlertIcon +} from '@chakra-ui/react' +import React, { useState } from 'react' + +function CreateUserButton ({ + setDisplaySuccess +}: { + displaySuccess: boolean + setDisplaySuccess: React.Dispatch> +}): JSX.Element { + const { isOpen, onOpen, onClose } = useDisclosure() + const initialRef = React.useRef(null) + const finalRef = React.useRef(null) + const [formData, setFormData] = useState({ email: '', roles: '' }) + const [displayError, setDisplayError] = useState(false) + + const handleChange = (e: React.ChangeEvent): void => { + const { name, value } = e.target + setFormData((prev) => ({ ...prev, [name]: value })) + } + + const handleSubmit = (event: React.MouseEvent): void => { + event.preventDefault() + console.log('Form submitted', formData) + + const simulateApiCall = async (): Promise => { + await new Promise((resolve, reject) => { + const apiState = true + if (!apiState) { + reject(new Error('API call failed')) + } else { + resolve() + } + }) + } + simulateApiCall() + .then(() => { + setDisplaySuccess(true) + onClose() + }) + .catch((error) => { + setDisplayError(true) + console.error(error) + }) + } + + return ( + <> + + + + + + Add User + + + {displayError && ( + + + Request failed + + )} + + Email + + + + + Roles + + + + + + + + + + + + ) +} + +export default CreateUserButton diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx new file mode 100644 index 0000000..e4c49d8 --- /dev/null +++ b/src/pages/DashboardPage.tsx @@ -0,0 +1,26 @@ +import CreateUserButton from '../components/CreateUserButton' +import { Alert, AlertIcon, VStack, Flex, Spacer } from '@chakra-ui/react' +import { useState } from 'react' + +function DashboardPage (): JSX.Element { + const [displaySuccess, setDisplaySuccess] = useState(false) + return ( + + + + + + {displaySuccess && ( + + + + + Request success + + + )} + + ) +} + +export default DashboardPage