Skip to content

Commit 9de0063

Browse files
committed
removed console.logs and added comments to navbar
1 parent 7a299b7 commit 9de0063

File tree

4 files changed

+40
-153
lines changed

4 files changed

+40
-153
lines changed

app/src/Dashboard/NavbarDash.tsx

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useContext } from 'react';
22
import {
3-
withStyles,
43
createStyles,
54
makeStyles,
65
Theme,
@@ -10,18 +9,8 @@ import AppBar from '@material-ui/core/AppBar';
109
import Avatar from '@material-ui/core/Avatar';
1110
import Toolbar from '@material-ui/core/Toolbar';
1211
import Typography from '@material-ui/core/Typography';
13-
import IconButton from '@material-ui/core/IconButton';
14-
import MenuIcon from '@material-ui/icons/Menu';
15-
import Menu from '@material-ui/core/Menu';
16-
import MenuItem from '@material-ui/core/MenuItem';
17-
import List from '@material-ui/core/List';
18-
import ListItem from '@material-ui/core/ListItem';
19-
import ListItemText from '@material-ui/core/ListItemText';
20-
import ListItemIcon from '@material-ui/core/ListItemIcon';
21-
// ROUTING TO DASHBOARD
2212
import { Link } from 'react-router-dom';
2313
import { styleContext } from '../containers/AppContainer';
24-
import StateContext from '../../context/context';
2514
import logo from '../../../resources/icon.png';
2615

2716

@@ -45,38 +34,22 @@ const useStyles = makeStyles((theme: Theme) => createStyles({
4534
},
4635
}));
4736

48-
// --------------------------Sorting Buttons------------------------------------//
49-
const sortByRating = (props) => {
50-
51-
52-
// should change state to true: then in the return for project container, a conditional rendering will occur
53-
54-
// generate a sorted array of public projects based on likes
55-
// const sortedProjects = projects.sort((a, b) => ((a.likes > b.likes) ? 1 : -1));
56-
};
57-
58-
const sortByDate = (props) => {
59-
console.log('date');
60-
};
61-
62-
const sortByUser = (props) => {
63-
console.log('user');
64-
};
65-
37+
// sorting options
6638
const sortMethods = ['rating', 'date', 'user'];
6739

68-
export default function NavBar(props) {
40+
// TO DO: set types of props validation
6941

42+
export default function NavBar(props) {
43+
// TO DO: import setStyle
7044
const classes = useStyles();
7145
const { style, setStyle } = useContext(styleContext);
7246

7347

74-
// toggle dropdown sorting menu
48+
// toggle to open and close dropdown sorting menu
7549
const [isOpen, setIsOpen] = useState(false);
7650

7751
const toggling = () => setIsOpen(!isOpen);
7852

79-
8053
return (
8154
<div className={classes.root} style={style}>
8255
<AppBar position="static">
@@ -86,15 +59,15 @@ export default function NavBar(props) {
8659
ReacType
8760
</Typography>
8861

89-
{/* ==================================Sort by Button================================================== */}
62+
{/* ==========================================Sort by Button================================================== */}
9063

9164
<div style ={ { textDecoration: 'none' } }>
9265
<Button onClick={toggling}
93-
variant="contained"
94-
color="primary"
95-
style={{ minWidth: '137.69px' }}
96-
className="navbarButton"
97-
id="navbarButtonDash"
66+
variant="contained"
67+
color="primary"
68+
style={{ minWidth: '137.69px' }}
69+
className="navbarButton"
70+
id="navbarButtonDash"
9871
>
9972
Sort documents
10073
</Button>
@@ -107,12 +80,12 @@ export default function NavBar(props) {
10780
props.optionClicked(option);
10881
toggling();
10982
}}
110-
variant="contained"
111-
color="primary"
112-
style={{ minWidth: '137.69px' }}
113-
className="navbarButton"
114-
key={index}
115-
> {option}
83+
variant="contained"
84+
color="primary"
85+
style={{ minWidth: '137.69px' }}
86+
className="navbarButton"
87+
key={index}
88+
> {option}
11689
</Button>
11790
))};
11891
</div>
@@ -121,6 +94,7 @@ export default function NavBar(props) {
12194
</div>
12295

12396
{/* ====================================Home Button============================================== */}
97+
12498
<div style ={ { textDecoration: 'none' } }>
12599
<Link to="/">
126100
<Button
Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React, { useState, useEffect } from 'react';
2-
import { Link } from 'react-router-dom';
32
import { useQuery } from '@apollo/client';
4-
53
import { GET_PROJECTS } from './gqlStrings';
64
import Project from './Project.tsx';
75
import NavBar from './NavbarDash';
@@ -20,52 +18,42 @@ const ProjectContainer = () => {
2018
// }
2119

2220
// --------------------------Sorting Buttons------------------------------------//
21+
2322
// hook for sorting menu
2423
const [selectedOption, setSelectedOption] = useState(null);
2524

2625
const sortByRating = (projects) => {
27-
// console.log('sort by rating :', projects);
2826
// generate a sorted array of public projects based on likes
29-
const sortedRatings = projects.sort((a, b) => b.likes - a.likes );
30-
// console.log('sort by rating result >>>', sortedRatings);
31-
32-
// setRenderedOption(sortedRatings);
27+
const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
3328
return sortedRatings;
3429
};
3530

3631
const sortByDate = (projects) => {
37-
console.log('sort by date', projects);
38-
32+
// generate a sorted array of public projects based on date
3933
const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
40-
console.log('sort by date result >>>', sortedRatings);
41-
4234
return sortedRatings;
4335
};
4436

4537
const sortByUser = (projects) => {
46-
console.log('sort by user', projects);
38+
// generate a sorted array of public projects based on username
4739
const sortedRatings = projects.sort((a, b) => b.user - a.user);
48-
console.log('sort by rating result >>>', sortedRatings);
49-
5040
return sortedRatings;
5141
};
52-
53-
5442
// ===================================================================================== //
5543

5644
// useQuery hook abstracts fetch request
57-
// Need to find where the userId is stored for the logged in user.
58-
const { loading, error, data } = useQuery(GET_PROJECTS, { pollInterval: 2000, variables: myVar });
45+
const { loading, error, data } = useQuery(GET_PROJECTS, { pollInterval: 2000, variables: myVar });
5946
if (loading) return <p>Loading...</p>;
6047
if (error) return <p>Error :{error}</p>;
48+
6149
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
6250
const projects = data.getAllProjects;
63-
console.log("projects >>>>>>", projects);
51+
52+
// create array to hold the data recieved in the public dashboard the will be conditionally rendered
6453
let sortedProjects = [];
65-
// console.log('Projects >>> ', projects);
66-
// generate an array of Project components based on data
67-
let publicDisplay = [];
54+
// create array to hold the components Project of loggin-in users
6855
const userDisplay = [];
56+
// generate an array of Project components based on queried data
6957
projects.forEach((proj, index) => {
7058
const component = <Project
7159
key= { index }
@@ -77,34 +65,27 @@ const ProjectContainer = () => {
7765
createdAt = {proj.createdAt}
7866
id = {proj.id}
7967
/>;
68+
// sorting the public and private dashboards based on the user's username
8069
if (username === proj.username) userDisplay.push(component);
8170
if (proj.published) {
82-
// publicDisplay.push(component);
71+
8372
sortedProjects.push(proj);
8473
}
8574
});
8675

8776

88-
// function for sorting menu in nav bar
89-
77+
// function for selecting drop down sorting menu
9078
const optionClicked = (value) => {
91-
console.log('value', value);
9279
setSelectedOption(value);
9380
};
94-
95-
96-
97-
console.log('SortedProject >>> ', sortedProjects);
98-
99-
// if selectedOption === null, displaySorted = publicProjects
100-
// else displaySorted = convert to components from return value of a sortBy function)
81+
// checking which sorting method was selected from drop down menu and invoking correct sorting function
10182
if (selectedOption === 'date') sortedProjects = sortByDate(sortedProjects);
10283
else if (selectedOption === 'user') sortedProjects = sortByUser(sortedProjects);
10384
else if (selectedOption === 'rating') sortedProjects = sortByRating(sortedProjects);
10485

86+
// create an array of components Project that will be conditionally rendered
10587
const sortedDisplay = [];
10688
sortedProjects.forEach((proj, index) => {
107-
console.log('Pushing to displayProjects >>> ', proj);
10889
sortedDisplay.push(<Project
10990
key= { index }
11091
name = {proj.name}
@@ -116,29 +97,20 @@ const ProjectContainer = () => {
11697
id = {proj.id}
11798
/>);
11899
});
119-
console.log('displaySorted >>> ', sortedDisplay);
120-
121-
122-
// if (selectedOption === 'date') sortByDate(publicProjects);
123-
// if (selectedOption === 'user') sortByUser(publicProjects);
124-
// console.log('selectedOption', selectedOption);
125-
126-
127-
100+
128101
return (
129102
<div>
130-
<NavBar optionClicked = {optionClicked}/>
131-
<h1> Public Dashboard </h1>
103+
<NavBar optionClicked = {optionClicked}/>
104+
<h1> Public Dashboard </h1>
132105
<div className = "projectContainer">
133106
{sortedDisplay}
134107
</div>
135-
<hr></hr>
108+
<hr></hr>
136109
<h1> User Dashboard </h1>
137110
<div className = "projectContainer">
138-
{userDisplay}
139-
</div>
140-
111+
{userDisplay}
141112
</div>
113+
</div>
142114
);
143115
};
144116
export default ProjectContainer;

app/src/Dashboard/SortMenu.jsx

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dist-windows": "npm run prod-build && electron-builder --windows",
5252
"dist-all": "npm run prod-build && electron-builder --mac --linux --windows",
5353
"test": "cross-env NODE_ENV=test jest --verbose",
54-
"server": "nodemon server/index.js",
54+
"server": "nodemon server/server.js",
5555
"electron": "cross-env NODE_ENV=development electron ."
5656
},
5757
"repository": {

0 commit comments

Comments
 (0)