diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 68c8eb8..ee3deba 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -2106,6 +2106,11 @@
"@babel/types": "^7.3.0"
}
},
+ "@types/component-emitter": {
+ "version": "1.2.10",
+ "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz",
+ "integrity": "sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg=="
+ },
"@types/eslint": {
"version": "7.2.6",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.2.6.tgz",
@@ -3334,6 +3339,11 @@
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",
"integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ=="
},
+ "backo2": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
+ "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
+ },
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@@ -3389,6 +3399,11 @@
}
}
},
+ "base64-arraybuffer": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz",
+ "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI="
+ },
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -5250,6 +5265,38 @@
"once": "^1.4.0"
}
},
+ "engine.io-client": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-4.1.0.tgz",
+ "integrity": "sha512-OUmn4m71/lW3ixICv4h3DuBRuh3ri0w3cDuepjsrINSbbqbni4Xw1shTFiKhl0v58lEtNpwJTpSKJJ3fondu5Q==",
+ "requires": {
+ "base64-arraybuffer": "0.1.4",
+ "component-emitter": "~1.3.0",
+ "debug": "~4.3.1",
+ "engine.io-parser": "~4.0.1",
+ "has-cors": "1.1.0",
+ "parseqs": "0.0.6",
+ "parseuri": "0.0.6",
+ "ws": "~7.4.2",
+ "xmlhttprequest-ssl": "~1.5.4",
+ "yeast": "0.1.2"
+ },
+ "dependencies": {
+ "ws": {
+ "version": "7.4.2",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
+ "integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
+ }
+ }
+ },
+ "engine.io-parser": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-4.0.2.tgz",
+ "integrity": "sha512-sHfEQv6nmtJrq6TKuIz5kyEKH/qSdK56H/A+7DnAuUPWosnIZAS2NHNcPLmyjtY3cGS/MqJdZbUjW97JU72iYg==",
+ "requires": {
+ "base64-arraybuffer": "0.1.4"
+ }
+ },
"enhanced-resolve": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz",
@@ -6932,6 +6979,11 @@
"function-bind": "^1.1.1"
}
},
+ "has-cors": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
+ "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
+ },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -9260,6 +9312,11 @@
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
+ "lottie-web": {
+ "version": "5.7.6",
+ "resolved": "https://registry.npmjs.org/lottie-web/-/lottie-web-5.7.6.tgz",
+ "integrity": "sha512-qn/KYMI4QQvFDhtoxs0RPkn9uZKhDB9keE5BKgbJlSRfNEZpRiDlwBE9ibYz4nPhbyE+NUlt8IRIVR7g5OSX3w=="
+ },
"lower-case": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
@@ -10286,6 +10343,16 @@
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
"integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug=="
},
+ "parseqs": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
+ "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w=="
+ },
+ "parseuri": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
+ "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
+ },
"parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@@ -12026,6 +12093,15 @@
"resolved": "https://registry.npmjs.org/react-layout-effect/-/react-layout-effect-1.0.5.tgz",
"integrity": "sha512-zdRXHuch+OBHU6bvjTelOGUCM+UDr/iCY+c0wXLEAc+G4/FlcJruD/hUOzlKH5XgO90Y/BUJPNhI/g9kl+VAsA=="
},
+ "react-lottie": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/react-lottie/-/react-lottie-1.2.3.tgz",
+ "integrity": "sha512-qLCERxUr8M+4mm1LU0Ruxw5Y5Fn/OmYkGfnA+JDM/dZb3oKwVAJCjwnjkj9TMHtzR2U6sMEUD3ZZ1RaHagM7kA==",
+ "requires": {
+ "babel-runtime": "^6.26.0",
+ "lottie-web": "^5.1.3"
+ }
+ },
"react-refresh": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz",
@@ -13579,6 +13655,30 @@
}
}
},
+ "socket.io-client": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-3.1.0.tgz",
+ "integrity": "sha512-T4qPOL80KnoBwkdR70zMpiR6aH6zv3ZqLNriofHqsO9wvQllNTOez0mpV4GdVqo1Y55Z+h8YOlBo7c8pOxDlHw==",
+ "requires": {
+ "@types/component-emitter": "^1.2.10",
+ "backo2": "~1.0.2",
+ "component-emitter": "~1.3.0",
+ "debug": "~4.3.1",
+ "engine.io-client": "~4.1.0",
+ "parseuri": "0.0.6",
+ "socket.io-parser": "~4.0.4"
+ }
+ },
+ "socket.io-parser": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
+ "integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
+ "requires": {
+ "@types/component-emitter": "^1.2.10",
+ "component-emitter": "~1.3.0",
+ "debug": "~4.3.1"
+ }
+ },
"sockjs": {
"version": "0.3.20",
"resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.20.tgz",
@@ -16369,6 +16469,11 @@
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="
},
+ "xmlhttprequest-ssl": {
+ "version": "1.5.5",
+ "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
+ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4="
+ },
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
@@ -16423,6 +16528,11 @@
}
}
},
+ "yeast": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
+ "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
+ },
"yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index ffae583..3139c87 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -19,11 +19,13 @@
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-html5-camera-photo": "^1.5.4",
+ "react-lottie": "^1.2.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"react-social": "^1.10.0",
"react-swipeable-views": "^0.13.9",
"react-webcam": "^5.2.2",
+ "socket.io-client": "^3.1.0",
"web-vitals": "^0.2.4",
"yup": "^0.32.8"
},
diff --git a/frontend/src/AdminLogin.jsx b/frontend/src/AdminLogin.jsx
deleted file mode 100644
index 8f2dc66..0000000
--- a/frontend/src/AdminLogin.jsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import React from 'react';
-import { ArrowForward } from '@material-ui/icons';
-import { Formik, Form } from 'formik';
-import * as Yup from "yup";
-import { Grid, TextField, Container, makeStyles, CssBaseline, Button, Typography, Avatar } from '@material-ui/core';
-
-import ErrorMessage from './components/ErrorMessage';
-
-
-const validationSchema = Yup.object().shape({
- email: Yup.string().required().email().label("Email"),
- password: Yup.string().required().label("Password"),
-});
-
-const useStyles = makeStyles((theme) => ({
- paper: {
- marginTop: theme.spacing(8),
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- },
- avatar: {
- backgroundColor: theme.palette.secondary.main,
- color: 'white',
- margin: 20,
- width: theme.spacing(7),
- height: theme.spacing(7),
- },
- form: {
- justifyContent: 'center',
- width: '100%',
- },
- submit: {
- margin: theme.spacing(3, 0, 2),
- },
- TextField: {
- width: '100%',
- marginTop: 10,
- backgroundColor: '#fafafa',
- },
-}));
-
-export default function AdminLogin() {
- const classes = useStyles();
-
- return (
-
-
-
-
-
-
-
- Login
-
-
console.log(values)}
- >
- {({ setFieldValue, errors, touched, values }) => (
-
- )}
-
-
-
- );
-}
diff --git a/frontend/src/App.js b/frontend/src/App.js
index b5529d7..74459a0 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -1,18 +1,21 @@
-import React, { useState } from "react";
+import React from "react";
import "./App.css";
-import UserNav from "./navigation/userNavigation";
-import AdminNav from "./navigation/AdminNavigation";
-import AuthContext from "./api/authContext";
+import AppNavigation from "./navigation/userNavigation";
+import { AuthProvider } from "./api/authContext";
+import { BrowserRouter, Switch } from "react-router-dom";
function App() {
- const [user, setUser] = useState();
return (
-
+
-
+
);
}
diff --git a/frontend/src/UserRegistration.jsx b/frontend/src/UserRegistration.jsx
deleted file mode 100644
index 4b8d2bf..0000000
--- a/frontend/src/UserRegistration.jsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import React from 'react';
-import { LockOutlined } from '@material-ui/icons';
-import { Formik, Form } from 'formik';
-import * as Yup from "yup";
-import { Grid, TextField, Container, makeStyles, CssBaseline, Button, Typography } from '@material-ui/core';
-
-import ErrorMessage from './components/ErrorMessage';
-
-const validationSchema = Yup.object().shape({
- username: Yup.string().required().label("User name"),
- email: Yup.string().required().email().label("Email"),
- age: Yup.number().min(18).required().label("Age"),
-});
-
-const useStyles = makeStyles((theme) => ({
- paper: {
- marginTop: theme.spacing(8),
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- },
- avatar: {
- backgroundColor: theme.palette.secondary.main,
- padding: 10,
- color: 'white',
- borderRadius: 30,
- margin: 20,
- },
- form: {
- justifyContent: 'center',
- padding: 10,
- alignItems: 'center',
- },
- submit: {
- margin: theme.spacing(3, 0, 2),
- },
- error: {
- fontSize: 14,
- color: 'red',
- },
- TextField: {
- width: '100%',
- backgroundColor: '#fafafa',
- }
-}));
-
-export default function UserRegistration() {
-
- const classes = useStyles();
-
- return (
-
-
-
-
-
-
-
- Register
-
-
console.log(values)}
- >
- {({ setFieldValue, errors, touched }) => (
-
- )}
-
-
-
- );
-}
diff --git a/frontend/src/admin/AdminMission.jsx b/frontend/src/admin/AdminMission.jsx
index 820db53..33a56b6 100644
--- a/frontend/src/admin/AdminMission.jsx
+++ b/frontend/src/admin/AdminMission.jsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import AdminMissionListItem from './AdminMissionListItem';
@@ -6,6 +6,8 @@ import AddIcon from '@material-ui/icons/Add';
import Fab from '@material-ui/core/Fab';
import colors from '../utils/colors';
import Routes from '../utils/routes'
+import { withRouter } from 'react-router-dom'
+import client from '../api/client';
const useStyles = makeStyles((theme) => ({
root: {
@@ -28,7 +30,15 @@ const useStyles = makeStyles((theme) => ({
function AdminMission(props) {
const { history } = props;
const classes = useStyles();
- const [dense, setDense] = React.useState(false);
+ const [dense, setDense] = useState(false);
+ const [data, setData] = useState([]);
+ useEffect(() => {
+ const fetchData = async () => {
+ const result = await client.get('api/admin/mission')
+ setData(result.data.Missions);
+ }
+ fetchData();
+ }, []);
return (
-
-
-
-
-
-
-
-
-
+ {data.map((mission, index) => (
+
+ ))}
@@ -61,4 +67,4 @@ function AdminMission(props) {
)
}
-export default AdminMission;
\ No newline at end of file
+export default withRouter(AdminMission);
\ No newline at end of file
diff --git a/frontend/src/admin/AdminMissionListItem.jsx b/frontend/src/admin/AdminMissionListItem.jsx
index 15b3994..a455863 100644
--- a/frontend/src/admin/AdminMissionListItem.jsx
+++ b/frontend/src/admin/AdminMissionListItem.jsx
@@ -11,40 +11,85 @@ import LocationOnIcon from '@material-ui/icons/LocationOn';
import TextFormatIcon from '@material-ui/icons/TextFormat';
import EditIcon from '@material-ui/icons/Edit';
import colors from '../utils/colors';
+import Dialog from '@material-ui/core/Dialog';
+import DialogActions from '@material-ui/core/DialogActions';
+import DialogContent from '@material-ui/core/DialogContent';
+import DialogContentText from '@material-ui/core/DialogContentText';
+import DialogTitle from '@material-ui/core/DialogTitle';
+import Button from '@material-ui/core/Button';
+import client from '../api/client';
+import { withRouter } from 'react-router-dom';
function AdminMissionListItem(props) {
const [secondary, setSecondary] = React.useState(false);
- const renderType = (type) => {
- if (type === "1") {
- return (
);
+ const [open, setOpen] = React.useState(false);
+ const { history } = props;
+ const handleClickOpen = () => {
+ setOpen(true);
+ };
+
+ const handleClose = () => {
+ setOpen(false);
+ };
+ const handleDeleteConfirm = () => {
+ setOpen(false);
+ const confirmDelete = async () => {
+ const response = await client.delete(`api/admin/mission/delete/${props.values._id}`);
+ console.log(response);
}
- else if (type === "2") {
- return (
);
+ confirmDelete();
+ }
+ const renderType = (type) => {
+ const object = {
+ 'Picture':
,
+ 'Text':
,
+ 'Picture and Location':
,
+ 'Video':
}
- else
- return (
);
+ return object[type];
}
return (
- {renderType(props.type)}
+ {renderType(props.values.Category)}
-
+ { history.push(`edit/${props.values._id}`) }}>
-
+
+
)
}
-export default AdminMissionListItem;
\ No newline at end of file
+export default withRouter(AdminMissionListItem);
\ No newline at end of file
diff --git a/frontend/src/admin/Drawer.jsx b/frontend/src/admin/Drawer.jsx
index ac386ba..2f68583 100644
--- a/frontend/src/admin/Drawer.jsx
+++ b/frontend/src/admin/Drawer.jsx
@@ -1,4 +1,4 @@
-import React from "react";
+import React, { useContext } from "react";
import {
Drawer as MUIDrawer,
ListItem,
@@ -19,6 +19,7 @@ import Avatar from '@material-ui/core/Avatar';
import { deepOrange } from '@material-ui/core/colors';
import colors from '../utils/colors';
import Routes from '../utils/routes';
+import { AuthContext } from "../api/authContext";
const useStyles = makeStyles((theme) => ({
drawer: {
@@ -39,13 +40,13 @@ const useStyles = makeStyles((theme) => ({
const Drawer = props => {
const { history } = props;
+ const authContext = useContext(AuthContext);
const classes = useStyles();
const itemsList = [
{
text: "Mission",
icon:
,
onClick: () => {
- props.onTitleChange('Missions')
history.push(Routes.ADMIN_MISSIONS);
}
},
@@ -53,7 +54,6 @@ const Drawer = props => {
text: "Activity",
icon:
,
onClick: () => {
- props.onTitleChange('Activity feed')
history.push(Routes.ADMIN_ACTIVITY_FEED);
}
},
@@ -61,14 +61,16 @@ const Drawer = props => {
text: "Score Board",
icon:
,
onClick: () => {
- props.onTitleChange('Score Board')
history.push(Routes.ADMIN_LEADERBOARD)
}
},
{
text: "Logout",
icon:
,
- onClick: () => history.push("/logout")
+ onClick: () => {
+ authContext.logout();
+ history.push(Routes.USER_LOGIN);
+ }
}
];
const adminList = [
@@ -76,7 +78,6 @@ const Drawer = props => {
text: "Admin List",
icon:
,
onClick: () => {
- props.onTitleChange('Admin List');
history.push(Routes.ADMIN_LIST);
}
},
@@ -84,8 +85,7 @@ const Drawer = props => {
text: "Missions",
icon:
,
onClick: () => {
- props.onTitleChange('Missions');
- history.push(Routes.ADMIN_MISSION_EDIT);
+ history.push(Routes.ADMIN_MISSION_UPDATE);
}
}
]
@@ -111,6 +111,8 @@ const Drawer = props => {
);
})}
+ {authContext.isSuperAdmin() && (
+ <>
{
);
})}
+ >
+ )}
);
};
diff --git a/frontend/src/admin/DrawerHeader.jsx b/frontend/src/admin/DrawerHeader.jsx
new file mode 100644
index 0000000..55db995
--- /dev/null
+++ b/frontend/src/admin/DrawerHeader.jsx
@@ -0,0 +1,128 @@
+import React from 'react';
+import CssBaseline from '@material-ui/core/CssBaseline';
+import clsx from 'clsx';
+import AppBar from '@material-ui/core/AppBar';
+import Toolbar from '@material-ui/core/Toolbar';
+import IconButton from '@material-ui/core/IconButton';
+import Typography from '@material-ui/core/Typography';
+import Badge from '@material-ui/core/Badge';
+import MenuIcon from '@material-ui/icons/Menu';
+import NotificationsActiveIcon from '@material-ui/icons/NotificationsActive';
+import { makeStyles } from "@material-ui/core/styles";
+
+const drawerWidth = 190;
+
+const useStyles = makeStyles((theme) => ({
+ root: {
+ display: "flex"
+ },
+ toolbar: {
+ paddingRight: 24,
+ },
+ toolbarIcon: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'flex-end',
+ padding: '0 8px',
+ ...theme.mixins.toolbar,
+ },
+ appBar: {
+ zIndex: theme.zIndex.drawer + 1,
+ transition: theme.transitions.create(['width', 'margin'], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen,
+ }),
+ },
+ appBarShift: {
+ marginLeft: drawerWidth,
+ width: `calc(100% - ${drawerWidth}px)`,
+ transition: theme.transitions.create(['width', 'margin'], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen,
+ }),
+ },
+ menuButton: {
+ marginRight: 36,
+ },
+ menuButtonHidden: {
+ display: 'none',
+ },
+ title: {
+ flexGrow: 1,
+ },
+ drawerPaper: {
+ position: 'relative',
+ whiteSpace: 'nowrap',
+ width: drawerWidth,
+ transition: theme.transitions.create('width', {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen,
+ }),
+ },
+ drawerPaperClose: {
+ overflowX: 'hidden',
+ transition: theme.transitions.create('width', {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen,
+ }),
+ width: theme.spacing(7),
+ [theme.breakpoints.up('sm')]: {
+ width: theme.spacing(9),
+ },
+ },
+ appBarSpacer: theme.mixins.toolbar,
+ content: {
+ flexGrow: 1,
+ height: '100vh',
+ overflow: 'auto',
+ },
+ container: {
+ paddingTop: theme.spacing(4),
+ paddingBottom: theme.spacing(4),
+ },
+ paper: {
+ padding: theme.spacing(2),
+ display: 'flex',
+ overflow: 'auto',
+ flexDirection: 'column',
+ },
+ fixedHeight: {
+ height: 240,
+ },
+}));
+
+const DrawerHeader = (props) => {
+ const classes = useStyles();
+ const [open, setOpen] = React.useState(true);
+ const handleDrawerOpen = () => {
+ setOpen(true);
+ };
+ return (
+
+
+
+
+
+
+
+
+ {props.title}
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default DrawerHeader;
\ No newline at end of file
diff --git a/frontend/src/admin/EditMission.jsx b/frontend/src/admin/EditMission.jsx
new file mode 100644
index 0000000..6f57168
--- /dev/null
+++ b/frontend/src/admin/EditMission.jsx
@@ -0,0 +1,228 @@
+import React, { useEffect, useState } from 'react';
+import { useFormik } from 'formik';
+import ArrowBackIcon from '@material-ui/icons/ArrowBack';
+import Button from '@material-ui/core/Button';
+import TextField from '@material-ui/core/TextField';
+import Select from '@material-ui/core/Select';
+import client from '../api/client';
+import { withRouter } from 'react-router-dom';
+
+const dummyData = {
+ "id": "5ff7bac89b8b6a46c011b200",
+ "Category": "Picture",
+ "clue": "uhugyfytfytfyfyfyfug jgyfyfddtd gfgugufigi vugfyfyfy",
+ "answer_Type": "Picture",
+ "answer": ["base64string"],
+ "Location": {
+ "Lat": "12.334543656",
+ "Long": "34.56456756"
+ },
+ "Other_Info": "vdhvdsvfdvfhdsvfjdvfvdvdsjvadv bjdvdsvdsv vcvdhcvjdsvcdsv",
+ "Feed": "true",
+ "ServerEvaluation": "false",
+ "maxPoints": "100",
+ "MissionName": "IESFHORIG",
+ "Hints": [
+ {
+ "Content": "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ "MaxPoints": "123"
+ }, {
+ "Content": "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ "MaxPoints": "123"
+ }, {
+ "Content": "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ "MaxPoints": "123"
+ },
+ {
+ "Content": "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ "MaxPoints": "123"
+ }
+ ]
+};
+
+const EditMission = (props) => {
+ const { history } = props;
+ const [data, setData] = useState(dummyData);
+ const formik = useFormik({
+ initialValues: {
+ Category: data['Category'],
+ clue: data['clue'],
+ answer: data['answer'].join(','),
+ Other_Info: data['Other_Info'],
+ answer_Type: '',
+ maxPoints: data['maxPoints'],
+ Lat: data.Location.Lat,
+ Long: data.Location.Long,
+ MissionName: data['Category']
+ },
+ enableReinitialize: true,
+ onSubmit: async (values) => {
+ const { Category, clue, answer, answer_Type, Other_Info, Lat, Long, maxPoints, MissionName } = values;
+ const answerArray = [];
+ answerArray.push(answer);
+ const object = {
+ id: props.match.params.id,
+ Category,
+ clue,
+ answer: answerArray,
+ answer_Type,
+ Other_Info,
+ Location: {
+ Lat,
+ Long
+ },
+ MissionName,
+ Feed: true,
+ ServerEvaluation: false,
+ maxPoints,
+ Hints: [
+ {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }, {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }, {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }
+ ]
+ };
+ const response = await client.patch('api/admin/mission/update', object);
+ console.log(response);
+ },
+ });
+ useEffect(() => {
+ const fetchData = async () => {
+ const result = await client.get(`api/mission/${props.match.params.id}`);
+ setData(result.data);
+ }
+ fetchData()
+ }, []);
+ return (
+
+
history.push('/admin/mission/update')}>
+
+
+
+
Edit
+
+
+
+ );
+};
+
+
+export default withRouter(EditMission);
+
diff --git a/frontend/src/admin/Mission.jsx b/frontend/src/admin/Mission.jsx
index 7197ad6..940744e 100644
--- a/frontend/src/admin/Mission.jsx
+++ b/frontend/src/admin/Mission.jsx
@@ -1,34 +1,22 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import MissionCard from './MissionCard'
+import client from '../api/client';
+import { Link } from 'react-router-dom';
const Mission = () => {
+ const [data, setData] = useState([]);
+ useEffect(() => {
+ const fetchData = async () => {
+ const result = await client.get('api/admin/mission')
+ setData(result.data.Missions);
+ }
+ fetchData();
+ }, []);
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {data.map((mission, index) => (
+
+ ))}
);
}
diff --git a/frontend/src/admin/MissionCard.jsx b/frontend/src/admin/MissionCard.jsx
index c237897..bf1ec93 100644
--- a/frontend/src/admin/MissionCard.jsx
+++ b/frontend/src/admin/MissionCard.jsx
@@ -4,29 +4,25 @@ import LocationOnIcon from '@material-ui/icons/LocationOn';
import TextFormatIcon from '@material-ui/icons/TextFormat';
import { withRouter } from 'react-router-dom'
import './admin.css'
-import Routes from '../utils/routes'
-
const MissionCard = (props) => {
const { history } = props;
const renderType = (type) => {
- if (type === "1") {
- return ();
- }
- else if (type === "2") {
- return ();
- }
- else {
- return ();
+ const object = {
+ 'Picture': ,
+ 'Text': ,
+ 'Picture and Location': ,
+ 'Video':
}
+ return object[type];
}
return (
- { history.push(Routes.ADMIN_MISSION_DETAILS) }}>
+
- {renderType(props.type)}
+ {renderType(props.values.Category)}
-
Mission 1
+
{`Mission ${props.index}`}
);
diff --git a/frontend/src/admin/MissionDetail.jsx b/frontend/src/admin/MissionDetail.jsx
index 47b76c1..0845223 100644
--- a/frontend/src/admin/MissionDetail.jsx
+++ b/frontend/src/admin/MissionDetail.jsx
@@ -1,7 +1,8 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { makeStyles } from "@material-ui/core/styles";
import MissionListItem from './MissionListItem'
-import CameraAltIcon from '@material-ui/icons/CameraAlt';
+import ArrowBackIcon from '@material-ui/icons/ArrowBack';
+import client from '../api/client';
const useStyles = makeStyles((theme) => ({
root: {
@@ -17,33 +18,61 @@ const useStyles = makeStyles((theme) => ({
},
}))
+const dummyData = {
+ Location: { Lat: 23, Long: 24 },
+ Category: 'Picture and Location',
+ clue: 'I am clueless yaaar',
+ answer_Type: 'Picture and Location',
+ answer: ['orange', 'apple', 'mango'],
+ Other_Info: 'I am orange'
+}
function MissionDetail(props) {
const classes = useStyles();
+ const [data, setData] = useState(dummyData);
+ const { history } = props;
+ useEffect(() => {
+ const fetchData = async () => {
+ const result = await client.get(`api/mission/${props.match.params.id}`);
+ console.log(result.data);
+ setData(result.data);
+ }
+ fetchData();
+ }, [props.match.params.id]);
return (
-
+
-
Mission 1
+ position: 'absolute',
+ left: '28%',
+ top: '20%',
+ cursor: 'pointer',
+ }} onClick={() => history.push('/admin')}>
+
-
-
diff --git a/frontend/src/admin/MissionListItem.jsx b/frontend/src/admin/MissionListItem.jsx
index c29ba7e..9f43ff6 100644
--- a/frontend/src/admin/MissionListItem.jsx
+++ b/frontend/src/admin/MissionListItem.jsx
@@ -15,7 +15,7 @@ function MissionListItem(props) {
const classes = useStyles();
return (
-
{props.title} Lorem ipsum dolor sit amet, consectetur adipis
+
{props.title} {props.value}
)
}
diff --git a/frontend/src/admin/NewMission.jsx b/frontend/src/admin/NewMission.jsx
index 3adccfb..a5add8a 100644
--- a/frontend/src/admin/NewMission.jsx
+++ b/frontend/src/admin/NewMission.jsx
@@ -1,131 +1,183 @@
import React from 'react';
import { useFormik } from 'formik';
-
+import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import Select from '@material-ui/core/Select';
+import client from '../api/client';
+import { withRouter } from 'react-router-dom';
-
-const NewMission = () => {
+const NewMission = (props) => {
+ const { history } = props;
const formik = useFormik({
initialValues: {
- category: '',
+ Category: '',
clue: '',
- password: '',
answer: '',
- otherinfo: '',
- answertype: '',
+ Other_Info: '',
+ answer_Type: '',
},
- onSubmit: (values) => {
- console.log(values);
+ onSubmit: async (values) => {
+ const { Category, clue, answer, answer_Type, Other_Info, Lat, Long, maxPoints, MissionName } = values;
+ const answerArray = [];
+ answerArray.push(answer);
+ const object = {
+ Category,
+ clue,
+ answer: answerArray,
+ answer_Type,
+ Other_Info,
+ Location: {
+ Lat,
+ Long
+ },
+ MissionName,
+ Feed: true,
+ ServerEvaluation: false,
+ maxPoints,
+ Hints: [
+ {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }, {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }, {
+ Content: "hfbfrbfrfrfgrfbrjbfjrbgjrbgbr",
+ MaxPoints: 123
+ }
+ ]
+ };
+ const response = await client.post('api/admin/mission/add', object);
+ console.log(response);
},
});
return (
-