diff --git a/front-end/src/App.css b/front-end/src/App.css deleted file mode 100644 index e69de29b..00000000 diff --git a/front-end/src/App.js b/front-end/src/App.js index bac06d19..8d7c2616 100644 --- a/front-end/src/App.js +++ b/front-end/src/App.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; -import './App.css'; import Login from './pages/Login'; import Home from './pages/Home'; import Profile from './pages/Profile'; @@ -202,13 +201,13 @@ export default function App() {
( - + )}/> ( - + )}/> {isAdmin ? ( - + )}/> : null}
diff --git a/front-end/src/components/AddKudo.js b/front-end/src/components/AddKudo.js index beec6288..5ed7566c 100644 --- a/front-end/src/components/AddKudo.js +++ b/front-end/src/components/AddKudo.js @@ -1,6 +1,17 @@ -import { Button, Card, CardContent, Chip, TextField, Grid } from '@material-ui/core'; +import { Button, Card, CardContent, Chip, TextField, Grid, Modal, Fade } from '@material-ui/core'; import Autocomplete from '@material-ui/lab/Autocomplete'; import React, { useState, useEffect } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; + +const useStyles = makeStyles({ + modalCenter: { + position: 'absolute', + top: '30%', + left: '50%', + transform: 'translate(-50%, -50%)', + outline: '0', + }, +}); // props: getKudos, optional: toggleShowAddKudos export default function AddKudo(props) { @@ -11,7 +22,15 @@ export default function AddKudo(props) { const [uid, setUid] = useState(''); const [nameMapUid, setNameMapUid] = useState(''); const [coreValues, setCoreValues] = useState(['loading']); + const [showAddSuccess, toggleShowAddSuccess] = useState(false); const [tags, updateTags] = useState(''); + const classes = useStyles(); + + useEffect(() => { + if(showAddSuccess) { + setTimeout(() => toggleShowAddSuccess(false), 1500) + } + }, [showAddSuccess]) useEffect(() => { const uri = localStorage.getItem('uri'); @@ -78,6 +97,11 @@ export default function AddKudo(props) { if (props.toggleShowAddKudo) { props.toggleShowAddKudo(false); } + if (props.toggleShowAddSuccess) { + props.toggleShowAddSuccess(true); + } else { + toggleShowAddSuccess(true) + } }); setName(''); updateKudo(''); @@ -85,75 +109,91 @@ export default function AddKudo(props) { } return ( - - -
{e.preventDefault(); handleSumbit();}}> - - - option} - onChange={(event, newValue) => { - setName(newValue); - }} - renderInput={(params) => } - /> - - - updateKudo(e.target.value)} - /> - - - option.value} - renderTags={() => ( - tags.map((option, index) => ( - - )) - )} - onChange={(event, newValue) => { - updateTags(newValue) - }} - renderInput={(params) => ( - - )} - /> - - - +
+ toggleShowAddSuccess(false)} + aria-labelledby="report-confirmed" + aria-describedby="report-kudo" + > + +
+ +

Kudo Submitted Succesfully

+
+
+
+
+ + + {e.preventDefault(); handleSumbit();}}> + + + option} + onChange={(event, newValue) => { + setName(newValue); + }} + renderInput={(params) => } + /> + + + updateKudo(e.target.value)} + /> + + + option.value} + renderTags={() => ( + tags.map((option, index) => ( + + )) + )} + onChange={(event, newValue) => { + updateTags(newValue) + }} + renderInput={(params) => ( + + )} + /> + + + + - - - - + + + +
); } diff --git a/front-end/src/components/Kudo.js b/front-end/src/components/Kudo.js index 067a56a8..56773d28 100644 --- a/front-end/src/components/Kudo.js +++ b/front-end/src/components/Kudo.js @@ -1,31 +1,31 @@ -import React from 'react' -import {Grid, Card, CardContent, Typography, CardActions, Chip, Avatar} from '@material-ui/core' -import { makeStyles } from '@material-ui/core/styles'; -import { withStyles } from '@material-ui/core/styles'; +import React, { useEffect } from 'react' +import {Grid, Card, CardContent, Typography, CardActions, Chip, Avatar, Modal, Menu, MenuItem, Fade} from '@material-ui/core' +import { makeStyles, withStyles } from '@material-ui/core/styles'; import MuiAccordion from '@material-ui/core/Accordion'; import MuiAccordionSummary from '@material-ui/core/AccordionSummary'; import MuiAccordionDetails from '@material-ui/core/AccordionDetails'; import Reactions from './Reactions'; +import ReportModal from './ReportModal'; +import { useState } from 'react' +import MoreHorizIcon from '@material-ui/icons/MoreHoriz'; const useStyles = makeStyles({ root: { display: 'flex', }, recv: { -// <<<<<<< reactions -// display:'inline', -// color:'#a1a1a1', -// marginRight:'5px', -// paddingLeft: '2px', -// paddingRight: '2px', -// ======= - display:'inline', - backgroundColor:'#F2F2F2', - color:'#616161', - marginRight:'5px', - paddingLeft: '2px', - paddingRight: '2px', -// >>>>>>> main + display:'inline', + color:'#A1A1A1', + marginRight:'5px', + paddingLeft: '2px', + paddingRight: '2px', + }, + modalCenter: { + position: 'absolute', + top: '30%', + left: '50%', + transform: 'translate(-50%, -50%)', + outline: '0', }, }); @@ -73,14 +73,120 @@ const Accordion = withStyles({ //to, from, message, tags, kudoID, kudoReactions, compReactions export default function Kudo(props) { const classes = useStyles(); - const [expanded, setExpanded] = React.useState(false); + const [expanded, setExpanded] = useState(false); + const [showReport, toggleShowReport] = useState(false); + const [anchorEl, setAnchorEl] = useState(null); + const [showSuccessReport, toggleShowSuccessReport] = useState(false); + const [showSuccessDelete, toggleShowSuccessDelete] = useState(false); + + useEffect(() => { + if(showSuccessReport) { + setTimeout(() => toggleShowSuccessReport(false), 1500) + } + }, [showSuccessReport]) + + useEffect(() => { + if(showSuccessDelete) { + setTimeout(() => { + props.getKudos(); + toggleShowSuccessDelete(false); + if(props.getReportedKudos) { + props.getReportedKudos() + } + }, 1500) + } + }, [showSuccessDelete]) + + const handleClick = event => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + const handleChange = (panel) => (event, isExpanded) => { setExpanded(isExpanded ? panel : false); }; + function deleteSelf() { + const kid = props.kudoID + const uri = localStorage.getItem('uri') + fetch('http://localhost:5000/api/data/delete_kudo', + { + method: 'POST', + headers: { + "Accept": "application/json", + "Content-Type": "application/json" + }, + body: JSON.stringify({uri, kid}) + }) + .then(response => response.json()).then(data => { + if(data) { + handleClose(); + toggleShowSuccessDelete(true) + } + }); + } + return( +
+ toggleShowReport(false)} + aria-labelledby="report-modal" + aria-describedby="report-kudo" + > + +
+ +
+
+
+ toggleShowSuccessReport(false)} + aria-labelledby="report-confirmed" + aria-describedby="report-kudo" + > + +
+ +

Kudo Reported Successfully

+
+
+
+
+ toggleShowSuccessDelete(false)} + aria-labelledby="delete-confirmed" + aria-describedby="delete-kudo" + > + +
+ +

Kudo Deleted Successfully

+
+
+
+
+ + { handleClose(); toggleShowReport(true)}}>Report + {props.isAdmin ? deleteSelf()}>Delete + : null} + +
+ +
+
) } diff --git a/front-end/src/components/Navbar.js b/front-end/src/components/Navbar.js index 7cc6b728..9fa5f8bf 100644 --- a/front-end/src/components/Navbar.js +++ b/front-end/src/components/Navbar.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import { makeStyles } from '@material-ui/core/styles'; -import {Drawer, CssBaseline, List, MenuList, MenuItem , Button, Avatar, Box, Grid, Typography, Modal} from '@material-ui/core' +import {Drawer, CssBaseline, List, MenuList, MenuItem , Button, Avatar, Box, Grid, Typography, Modal, Card, Fade} from '@material-ui/core' import Emoji from '../components/Emoji'; import AddKudo from "./AddKudo"; import { useHistory } from "react-router-dom"; @@ -16,6 +16,7 @@ const useStyles = makeStyles((theme) => ({ width: drawerWidth, backgroundColor: theme.palette.background.default, paddingLeft: '80px', + overflowX: 'hidden', }, menuItem: { marginLeft: '0px', @@ -54,6 +55,7 @@ export default function Navbar(props) { const [position, setEmployeePosition] = useState(''); const [avatar, setAvatar] = useState(''); const [showAddKudo, toggleShowAddKudo] = useState(false); + const [showAddSuccess, toggleShowAddSuccess] = useState(false); let history = useHistory(); useEffect(() => { @@ -64,6 +66,12 @@ export default function Navbar(props) { } }, [props.employees]); + useEffect(() => { + if(showAddSuccess) { + setTimeout(() => toggleShowAddSuccess(false), 1500) + } + }, [showAddSuccess]) + return (
@@ -73,9 +81,25 @@ export default function Navbar(props) { aria-labelledby="add-kudo-modal" aria-describedby="add-kudo" > -
- -
+ +
+ +
+
+ + toggleShowAddSuccess(false)} + aria-labelledby="report-confirmed" + aria-describedby="report-kudo" + > + +
+ +

Kudo Submitted Succesfully

+
+
+
({ + contained: { + color: theme.palette.getContrastText(red[500]), + backgroundColor: red[500], + "&:hover": { + backgroundColor: red[700], + "@media (hover: none)": { + backgroundColor: red[500] + } + } + } +}) + +// props: classes, kid={props.kudoID}, toggleShowReport={toggleShowReport} +function ReportModal(props) { + const { classes, kid, toggleShowReport, toggleShowSuccess } = props; + const [reason, updateReason] = useState('') + + function handleSumbit() { + const uri = localStorage.getItem('uri'); + const uid = JSON.parse(localStorage.getItem('data')).uid + fetch('http://localhost:5000/api/data/report_kudo', + { + method: 'POST', + headers: { + "Accept": "application/json", + "Content-Type": "application/json" + }, + body: JSON.stringify({uri, uid, kid, reason}) + }) + .then(response => { + if (toggleShowReport) { + toggleShowReport(false); + toggleShowSuccess(true); + } + }); + updateReason(''); + } + + return ( + + +
{e.preventDefault(); handleSumbit();}}> + + + updateReason(e.target.value)} + /> + + + + + +
+
+
+ ); +} + +ReportModal.propTypes = { + classes: PropTypes.object.isRequired, + kid: PropTypes.string.isRequired, + toggleShowReport: PropTypes.func.isRequired, + toggleShowSuccess: PropTypes.func.isRequired, +}; + +export default withStyles(styles)(ReportModal) \ No newline at end of file diff --git a/front-end/src/pages/Admin.js b/front-end/src/pages/Admin.js index c3393355..4fbfedec 100644 --- a/front-end/src/pages/Admin.js +++ b/front-end/src/pages/Admin.js @@ -1,43 +1,46 @@ import React, { useState, useEffect } from "react"; import { AppBar, + Card, Divider, Grid, + Paper, Toolbar, Typography, } from "@material-ui/core"; import { makeStyles } from '@material-ui/core/styles'; -import Navbar from '../components/Navbar'; -import Rockstar from '../components/Rockstar'; -import Kudo from '../components/Kudo'; import Values from "../components/Values"; import Emojis from "../components/Emojis"; import ExportData from "../components/ExportData"; +import Kudo from "../components/Kudo" const useStyles = makeStyles(theme => ({ - kudos: { - paddingTop: theme.spacing(3), - paddingLeft: theme.spacing(6), - }, appBar: { backgroundColor: theme.palette.background.default, color: theme.palette.text.primary, }, stop: { backgroundColor: theme.palette.background.default, + }, + reported: { + padding: theme.spacing(2), + }, + reports: { + border: '1px solid rgba(255, 255, 255, 0.12)' + }, + reasons: { + margin: theme.spacing(1), + padding: theme.spacing(1), } })); export default function Home(props) { const [company, setCompany] = useState(''); + const [reportedKudos, setReportedKudos] = useState('') const classes = useStyles(); - // runs on reload/first visit, calls getKudos() and - // sets company name from uri useEffect(() => { - console.log(props.data); - console.log(props.uri); - props.getKudos(); + getReportedKudos(); const companies = { 'starship-entertainment': 'Starship Entertainment', 'outback-tech': 'Outback Technology', @@ -46,6 +49,24 @@ export default function Home(props) { setCompany(companies[props.uri]); }, []); + function getReportedKudos() { + const uri = props.uri + fetch('http://localhost:5000/api/data/reported_kudo', + { + method: 'POST', + headers: { + "Accept": "application/json", + "Content-Type": "application/json" + }, + body: JSON.stringify({uri}) + }) + .then(response => response.json()).then(data => { + if(data) { + setReportedKudos(data) + } + }); + } + return (
@@ -54,28 +75,65 @@ export default function Home(props) { - + + justify="center" alignItems="center" + > - + + + + {props.employees && reportedKudos && reportedKudos.length !== 0 ? reportedKudos.map((kudo, index) => { + return ( +
+
+ + {kudo.report.map((value, index) => { + return ( +
+ + + + Reported by: {props.employees[value.by].name} + + + Reason: {value.reason} + + +
+ ) + })} +
+
+ ) + }) + :
+ No Reported Kudos +
+ } +
+
); diff --git a/front-end/src/pages/Home.js b/front-end/src/pages/Home.js index 899e4a74..b08edf7d 100644 --- a/front-end/src/pages/Home.js +++ b/front-end/src/pages/Home.js @@ -40,7 +40,6 @@ export default function Home(props) { 'greenlife-consulting': 'Greenlife Consulting' } setCompany(companies[props.uri]); - // console.log(props.employees); }, []); return ( @@ -72,6 +71,8 @@ export default function Home(props) { compReactions={props.reactions} key={kudo._id} timestamp={kudo.time} + getKudos={props.getKudos} + isAdmin={props.isAdmin} /> }) :
} diff --git a/front-end/src/pages/Profile.js b/front-end/src/pages/Profile.js index 70fbd05e..e9269be4 100644 --- a/front-end/src/pages/Profile.js +++ b/front-end/src/pages/Profile.js @@ -282,7 +282,9 @@ export default function Profile(props) { kudoReactions={kudo.reactions} compReactions={props.reactions} timestamp={kudo.time} - avatar={employees[kudo.to].avatar} + avatar={employees[kudo.to].avatar} + getKudos={props.getKudos} + isAdmin={props.isAdmin} /> }) : 'loading' } {outgoing && employees ? outgoing.map((kudo, index) => { @@ -297,6 +299,8 @@ export default function Profile(props) { key={kudo._id} timestamp={kudo.time} avatar={employees[kudo.to].avatar} + getKudos={props.getKudos} + isAdmin={props.isAdmin} /> }) : 'loading' }