Skip to content

Commit d8bda37

Browse files
authored
Merge pull request #7 from slhoehn/navbar
Add sorting functionality to dashboard nav bar
2 parents 1deb1b2 + 47ee144 commit d8bda37

File tree

19 files changed

+525
-369
lines changed

19 files changed

+525
-369
lines changed

__tests__/projects.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
const app = require('../server/server');
12
const request = require('supertest');
23
let server = 'https://reactype.herokuapp.com';
34
const isDev = process.env.NODE_ENV === 'development';
45
if (isDev) {
5-
server = 'http://localhost:5000';
6+
// server = 'http://localhost:5000';
7+
server = require('..server/server');
68
}
79

810
// save and get projects endpoint testing
@@ -41,7 +43,7 @@ describe('Project endpoints tests', () => {
4143
.send(projectToSave)
4244
.expect('Content-Type', /json/)
4345
.expect(200)
44-
.then((res) => expect(res.body.project.name).toBe('test'));
46+
.then(res => expect(res.body.project.name).toBe('test'));
4547
});
4648
});
4749
});
@@ -73,7 +75,7 @@ describe('Project endpoints tests', () => {
7375
.send({ name, userId })
7476
.expect(200)
7577
.expect('Content-Type', /json/)
76-
.then((res) => expect(res.body.name).toBe('test'));
78+
.then(res => expect(res.body.name).toBe('test'));
7779
});
7880
});
7981
});

app/src/Dashboard/Form.jsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

app/src/Dashboard/FormsContainer.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import { Link } from 'react-router-dom';
33

44
import { gql, useQuery } from '@apollo/client';
5+
6+
57
import Form from './Form.jsx';
68

79
// Implement Apollo Client useQuery hook to retrieve data from the server through graphQL. This includes 2 steps:

app/src/Dashboard/NavbarDash.tsx

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import React, { useState, useContext } from 'react';
2+
import {
3+
createStyles,
4+
makeStyles,
5+
Theme,
6+
} from '@material-ui/core/styles';
7+
import Button from '@material-ui/core/Button';
8+
import AppBar from '@material-ui/core/AppBar';
9+
import Avatar from '@material-ui/core/Avatar';
10+
import Toolbar from '@material-ui/core/Toolbar';
11+
import Typography from '@material-ui/core/Typography';
12+
import { Link } from 'react-router-dom';
13+
import { styleContext } from '../containers/AppContainer';
14+
import logo from '../../../resources/icon.png';
15+
16+
17+
// NavBar text and button styling
18+
const useStyles = makeStyles((theme: Theme) => createStyles({
19+
root: {
20+
flexGrow: 1,
21+
width: '100%',
22+
},
23+
menuButton: {
24+
marginRight: theme.spacing(2),
25+
color: 'white',
26+
},
27+
title: {
28+
flexGrow: 1,
29+
color: 'white',
30+
},
31+
manageProject: {
32+
display: 'flex',
33+
justifyContent: 'center',
34+
},
35+
}));
36+
37+
// sorting options
38+
const sortMethods = ['rating', 'date', 'user'];
39+
40+
// TO DO: set types of props validation
41+
42+
export default function NavBar(props) {
43+
// TO DO: import setStyle
44+
const classes = useStyles();
45+
const { style, setStyle } = useContext(styleContext);
46+
47+
48+
// toggle to open and close dropdown sorting menu
49+
const [isOpen, setIsOpen] = useState(false);
50+
51+
const toggling = () => setIsOpen(!isOpen);
52+
53+
return (
54+
<div className={classes.root} style={style}>
55+
<AppBar position="static">
56+
<Toolbar>
57+
<Avatar src={logo}></Avatar>
58+
<Typography variant="h6" style={{ marginLeft: '1rem' }} className={classes.title}>
59+
ReacType
60+
</Typography>
61+
62+
{/* ==========================================Sort by Button================================================== */}
63+
64+
<div style ={ { textDecoration: 'none' } }>
65+
<Button onClick={toggling}
66+
variant="contained"
67+
color="primary"
68+
style={{ minWidth: '137.69px' }}
69+
className="navbarButton"
70+
id="navbarButtonDash"
71+
>
72+
Sort documents
73+
</Button>
74+
75+
{
76+
isOpen && (
77+
<div className="sortDoc">
78+
{sortMethods.map((option, index) => (
79+
<Button onClick={() => {
80+
props.optionClicked(option);
81+
toggling();
82+
}}
83+
variant="contained"
84+
color="primary"
85+
style={{ minWidth: '137.69px' }}
86+
className="navbarButton"
87+
key={index}
88+
> {option}
89+
</Button>
90+
))};
91+
</div>
92+
)
93+
}
94+
</div>
95+
96+
{/* ====================================Home Button============================================== */}
97+
98+
<div style ={ { textDecoration: 'none' } }>
99+
<Link to="/">
100+
<Button
101+
variant="contained"
102+
color="primary"
103+
style={{ minWidth: '137.69px' }}
104+
className="navbarButton"
105+
id="ratingButton"
106+
> Home
107+
</Button>
108+
</Link>
109+
</div>
110+
</Toolbar>
111+
</AppBar>
112+
</div>
113+
);
114+
}

app/src/Dashboard/Project.jsx

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)