From f6c739bfe1dc3ac97a796aaa7c0ef352dba94bc2 Mon Sep 17 00:00:00 2001 From: C4 Patino Date: Sat, 17 Dec 2022 12:12:00 -0600 Subject: [PATCH] Brought app up to modern standards --- client/package.json | 1 + client/src/App.jsx | 38 +++---- client/src/components/Dashboard.jsx | 73 ++++--------- client/src/components/EditUserForm.jsx | 4 +- client/src/components/Form.jsx | 38 ++++--- client/src/components/LoginForm.jsx | 18 +--- client/src/components/MainPageBase.jsx | 30 ++---- client/src/components/Navbar.jsx | 26 +++-- client/src/components/OrgUnit.jsx | 8 +- ...Organizations.jsx => OrganizationList.jsx} | 6 +- client/src/components/RecordMp3.jsx | 99 +---------------- client/src/components/RecoverForm.jsx | 49 +++------ client/src/components/RegisterForm.jsx | 9 +- client/src/components/ResetForm.jsx | 66 +++++------- client/src/components/StackItem.jsx | 1 - .../src/components/UpdateOrganizationForm.jsx | 8 +- client/src/components/index.js | 31 +++++- client/src/containers/EditUser.jsx | 16 +++ client/src/containers/Login.jsx | 16 +++ client/src/containers/MainPage.jsx | 27 +++++ client/src/containers/MemberOrgs.jsx | 16 +++ client/src/containers/OrgDashboard.jsx | 16 +++ client/src/containers/OwnedOrgs.jsx | 16 +++ client/src/containers/Recover.jsx | 16 +++ client/src/containers/Register.jsx | 16 +++ client/src/containers/Reset.jsx | 16 +++ client/src/containers/UpdateOrganization.jsx | 16 +++ client/src/containers/index.js | 24 ++++- client/src/contexts/UserContext.jsx | 5 + ...gDashboard.jsx => DashboardController.jsx} | 80 +++++--------- client/src/controllers/EditUser.jsx | 75 ------------- .../controllers/EditUserFormController.jsx | 62 +++++++++++ client/src/controllers/Login.jsx | 85 --------------- .../src/controllers/LoginFormController.jsx | 51 +++++++++ client/src/controllers/MainPage.jsx | 101 ------------------ client/src/controllers/MainPageController.jsx | 75 +++++++++++++ client/src/controllers/MemberOrgs.jsx | 27 ----- .../src/controllers/MemberOrgsDashboard.jsx | 20 ++++ client/src/controllers/OwnedOrgs.jsx | 27 ----- client/src/controllers/OwnedOrgsDashboard.jsx | 20 ++++ .../src/controllers/RecordMp3Controller.jsx | 94 ++++++++++++++++ ...{Recover.jsx => RecoverFormController.jsx} | 19 +--- ...egister.jsx => RegisterFormController.jsx} | 34 +++--- .../{Reset.jsx => ResetFormController.jsx} | 30 +++--- ...x => UpdateOrganizationFormController.jsx} | 22 ++-- client/src/controllers/index.js | 26 ++++- client/src/services/orgServices.js | 6 +- client/src/services/userServices.js | 40 ++++--- server/routes/auth/RequestReset.js | 5 +- server/routes/authRouter.js | 2 +- 50 files changed, 812 insertions(+), 794 deletions(-) rename client/src/components/{Organizations.jsx => OrganizationList.jsx} (88%) create mode 100644 client/src/containers/EditUser.jsx create mode 100644 client/src/containers/Login.jsx create mode 100644 client/src/containers/MainPage.jsx create mode 100644 client/src/containers/MemberOrgs.jsx create mode 100644 client/src/containers/OrgDashboard.jsx create mode 100644 client/src/containers/OwnedOrgs.jsx create mode 100644 client/src/containers/Recover.jsx create mode 100644 client/src/containers/Register.jsx create mode 100644 client/src/containers/Reset.jsx create mode 100644 client/src/containers/UpdateOrganization.jsx rename client/src/controllers/{OrgDashboard.jsx => DashboardController.jsx} (50%) delete mode 100644 client/src/controllers/EditUser.jsx create mode 100644 client/src/controllers/EditUserFormController.jsx delete mode 100644 client/src/controllers/Login.jsx create mode 100644 client/src/controllers/LoginFormController.jsx delete mode 100644 client/src/controllers/MainPage.jsx create mode 100644 client/src/controllers/MainPageController.jsx delete mode 100644 client/src/controllers/MemberOrgs.jsx create mode 100644 client/src/controllers/MemberOrgsDashboard.jsx delete mode 100644 client/src/controllers/OwnedOrgs.jsx create mode 100644 client/src/controllers/OwnedOrgsDashboard.jsx create mode 100644 client/src/controllers/RecordMp3Controller.jsx rename client/src/controllers/{Recover.jsx => RecoverFormController.jsx} (55%) rename client/src/controllers/{Register.jsx => RegisterFormController.jsx} (55%) rename client/src/controllers/{Reset.jsx => ResetFormController.jsx} (58%) rename client/src/controllers/{UpdateOrganization.jsx => UpdateOrganizationFormController.jsx} (53%) diff --git a/client/package.json b/client/package.json index 638f0bf..170ebb2 100644 --- a/client/package.json +++ b/client/package.json @@ -12,6 +12,7 @@ "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^13.5.0", "axios": "^0.26.1", + "buffer": "^6.0.3", "js-cookie": "^3.0.1", "mic-recorder-to-mp3": "^2.2.2", "react": "^17.0.2", diff --git a/client/src/App.jsx b/client/src/App.jsx index a6678ff..cd75970 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,20 +1,20 @@ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'; -import { Layout } from './containers'; +import { + Layout, + Login, + Register, + MainPage, + EditUser, + Recover, + Reset, + OwnedOrgs, + MemberOrgs, + OrgDashboard, +} from './containers'; import { ContextProvider } from './contexts'; -import MainPage from './controllers/MainPage'; -import Form from './components/Form'; -import Login from './controllers/Login'; -import Register from './controllers/Register'; -import EditUser from './controllers/EditUser'; -import Recover from './controllers/Recover'; -import Reset from './controllers/Reset'; - -import OwnedOrgs from './controllers/OwnedOrgs'; -import MemberOrgs from './controllers/MemberOrgs'; -import OrgDashboard from './controllers/OrgDashboard'; -import UpdateOrganization from './controllers/UpdateOrganization'; +import UpdateOrganization from './controllers/UpdateOrganizationFormController'; function App() { return ( @@ -22,24 +22,24 @@ function App() { }> - {/* } /> */} + } /> } /> } /> - {/* } /> */} - {/* }> + } /> + } /> } /> - */} + - {/* + } /> } /> } /> } /> - */} + } /> diff --git a/client/src/components/Dashboard.jsx b/client/src/components/Dashboard.jsx index a7821f0..21ecab6 100644 --- a/client/src/components/Dashboard.jsx +++ b/client/src/components/Dashboard.jsx @@ -1,4 +1,3 @@ -import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import { Accordion, @@ -18,11 +17,13 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import PlayArrowIcon from '@mui/icons-material/PlayArrow'; import { DataGrid } from '@mui/x-data-grid'; -import MemberUnit from './MemberUnit'; +import { MemberUnit } from '.'; import { DynamicPaper, DynamicStack } from './StyledElements'; function Dashboard({ rows, + open, + handleOpen, setSelection, onClick, org, @@ -37,8 +38,6 @@ function Dashboard({ const sm = useMediaQuery((theme) => theme.breakpoints.only('sm')); const md = useMediaQuery((theme) => theme.breakpoints.only('md')); - const [open, setOpen] = useState(false); - const linkStyle = { textDecoration: 'none', color: 'inherit' }; const columns = [ { field: 'id', headerName: 'ID', flex: 1 }, @@ -67,10 +66,6 @@ function Dashboard({ { field: 'email', headerName: 'Email', flex: 10, sortable: false }, ]; - function handleOpen() { - setOpen((initial) => (initial ? false : true)); - } - const buttonGroupOrientation = () => { if (xs) return 'vertical'; }; @@ -86,25 +81,19 @@ function Dashboard({ } return ( - + <> }> - - Organizations/{org.name} - + Organizations / {org.name} - + - Organization ID: {org.orgID} + Organization ID: {org.id} Members: {org.memberCount} @@ -117,8 +106,7 @@ function Dashboard({ - Owner:{' '} - {`${org.owner.firstName} ${org.owner.lastName}`} + Owner: {`${org.owner.firstName} ${org.owner.lastName}`} Email: {org.owner.email} @@ -128,23 +116,17 @@ function Dashboard({ {status ? ( - + <> - @@ -152,31 +134,19 @@ function Dashboard({ variant='outlined' orientation={buttonGroupOrientation()} > - - - - + ) : ( - )} @@ -187,16 +157,11 @@ function Dashboard({ - + {(xs || sm) && rows.map((member) => { - return ( - - ); + return ; })} {md && ( @@ -214,7 +179,7 @@ function Dashboard({ )} - + ); } diff --git a/client/src/components/EditUserForm.jsx b/client/src/components/EditUserForm.jsx index 5cf0c3a..9881b4a 100644 --- a/client/src/components/EditUserForm.jsx +++ b/client/src/components/EditUserForm.jsx @@ -2,8 +2,8 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { Box, Typography } from '@mui/material'; -import Form from './Form'; -import RecordMp3 from './RecordMp3'; +import { Form } from '.'; +import { RecordMp3 } from '../controllers'; import { FormSubmit, FormTextField } from './StyledElements'; function EditUserForm({ form, error, handleSubmit, handleChange }) { diff --git a/client/src/components/Form.jsx b/client/src/components/Form.jsx index 50d4e1d..621cc44 100644 --- a/client/src/components/Form.jsx +++ b/client/src/components/Form.jsx @@ -1,22 +1,17 @@ import React from 'react'; import { Outlet } from 'react-router-dom'; -import { Box, Grid, Paper, Typography } from '@mui/material'; +import { Box, Grid, Card, Typography, CardContent, Alert } from '@mui/material'; import { useTheme } from '@mui/material/styles'; -function Form({ children, text }) { +function Form({ children, text, error }) { const theme = useTheme(); return ( - + - - {text && ( - - {text} - - )} - {children} - - + + {text && ( + + {text} + + )} + {children} + + {error && {error}} + + diff --git a/client/src/components/LoginForm.jsx b/client/src/components/LoginForm.jsx index c75119a..2172d55 100644 --- a/client/src/components/LoginForm.jsx +++ b/client/src/components/LoginForm.jsx @@ -1,17 +1,14 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import { Box, Checkbox, FormControlLabel, Typography } from '@mui/material'; +import { Checkbox, FormControlLabel, Typography } from '@mui/material'; -import Form from './Form'; +import { Form } from '.'; import { FormSubmit, FormTextField } from './StyledElements'; -function Login({ form, error, handleSubmit, handleChange, handleCheckboxChange }) { +function Login({ form, handleSubmit, handleChange, handleCheckboxChange, error }) { return ( -
+ - - Login - - {error && ( - - - {error} - - - )} Login diff --git a/client/src/components/MainPageBase.jsx b/client/src/components/MainPageBase.jsx index 9f7c97c..aea0096 100644 --- a/client/src/components/MainPageBase.jsx +++ b/client/src/components/MainPageBase.jsx @@ -6,24 +6,12 @@ import OrgUnit from './OrgUnit'; import StackItem from './StackItem'; import { Form, FormButton, FormField } from './StyledElements'; -function MainPageBase({ - form, - orgs, - ownedOrgs, - joinOrg, - createOrg, - handleChange, -}) { +function MainPageBase({ form, orgs, ownedOrgs, joinOrg, createOrg, handleChange }) { const linkStyle = { textDecoration: 'none', color: 'inherit' }; return ( - + @@ -36,10 +24,7 @@ function MainPageBase({ value={form.id} onChange={handleChange} /> - + Join Organization @@ -54,10 +39,7 @@ function MainPageBase({ value={form.name} onChange={handleChange} /> - + Create Organization @@ -76,7 +58,7 @@ function MainPageBase({ )} {ownedOrgs.map((org) => ( - + ))} @@ -92,7 +74,7 @@ function MainPageBase({ )} {orgs.map((org) => ( - + ))} diff --git a/client/src/components/Navbar.jsx b/client/src/components/Navbar.jsx index 93b98f1..c201808 100644 --- a/client/src/components/Navbar.jsx +++ b/client/src/components/Navbar.jsx @@ -1,22 +1,26 @@ import DarkModeIcon from '@mui/icons-material/DarkMode'; import LightModeIcon from '@mui/icons-material/LightMode'; -import MailIcon from '@mui/icons-material/Mail'; import MenuIcon from '@mui/icons-material/Menu'; import { AppBar, Box, Button, IconButton, Toolbar, Typography } from '@mui/material'; import { Link } from 'react-router-dom'; export default function Navbar({ logout, userData, mode, toggleMode }) { function NavbarControls() { - return userData.username ? ( - + return userData.email ? ( + <> + + + ) : ( <>