@@ -10,15 +10,11 @@ import AppBar from '@material-ui/core/AppBar';
10
10
import Tabs from '@material-ui/core/Tabs' ;
11
11
import Tab from '@material-ui/core/Tab' ;
12
12
13
- // import {Tab, Tabs} from '@material-ui/core'
14
-
15
13
import Box from '@material-ui/core/Box' ;
16
14
import { GET_PROJECTS } from './gqlStrings' ;
17
15
import Project from './Project' ;
18
16
import NavBarDash from './NavbarDash' ;
19
17
20
-
21
- import AppContainer from '../containers/AppContainer' ;
22
18
import { theme1 , theme2 } from '../public/styles/theme' ;
23
19
// Implement Apollo Client useQuery hook to retrieve data from the server through graphQL. This includes 2 steps:
24
20
// 1) Impliment Apollo Provider in the top component in ./src/index.js, this allows children components access to the queried data
@@ -45,75 +41,6 @@ const arrToComponent = arr => arr.map((proj, index) => <Project
45
41
id = { proj . id }
46
42
comments = { proj . comments }
47
43
/> ) ;
48
-
49
-
50
- // const ProjectContainerDetails = () => {
51
- // const myVar = {};
52
- // // Need this for the individual user dasboard, for now, dashboard shows all projects from all users
53
- // const userSSID = window.localStorage.getItem('ssid') || 'unavailable';
54
- // const username = window.localStorage.getItem('username') || 'unavailable';
55
-
56
- // const [isThemeLight, setTheme] = useState(true);
57
-
58
- // const initialStyle = useContext(styleContext);
59
- // const [style, setStyle] = useState(initialStyle);
60
-
61
- // // --------------------------Sorting Buttons------------------------------------//
62
-
63
- // // hook for sorting menu
64
- // const [selectedOption, setSelectedOption] = useState('RATING');
65
-
66
- // const sortByRating = (projects) => {
67
- // // generate a sorted array of public projects based on likes
68
- // const sortedRatings = projects.sort((a, b) => b.likes - a.likes);
69
- // return sortedRatings;
70
- // };
71
-
72
- // const sortByDate = (projects) => {
73
- // // generate a sorted array of public projects based on date
74
- // const sortedRatings = projects.sort((a, b) => b.createdAt - a.createdAt);
75
- // return sortedRatings;
76
- // };
77
-
78
- // const sortByUser = (projects) => {
79
- // // generate a sorted array of public projects based on username
80
- // const sortedRatings = projects.sort((a, b) => b.username - a.username);
81
- // return sortedRatings;
82
- // };
83
- // // ===================================================================================== //
84
-
85
- // // function for selecting drop down sorting menu
86
- // const optionClicked = (value) => {
87
- // setSelectedOption(value);
88
- // };
89
- // // ===================================================================================== //
90
-
91
-
92
- // // useQuery hook abstracts fetch request
93
- // const { loading, error, data } = useQuery(GET_PROJECTS, { pollInterval: 2000, variables: myVar });
94
- // if (loading) return <p>Loading...</p>;
95
- // if (error) return <p>Error :{error}</p>;
96
-
97
- // // based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
98
- // const projects = data.getAllProjects;
99
-
100
- // // create array to hold the data recieved in the public dashboard the will be conditionally rendered
101
- // let sortedProjects = projects.filter(proj => proj.published);
102
- // const userProjects = projects.filter(proj => proj.username === username);
103
-
104
- // // checking which sorting method was selected from drop down menu and invoking correct sorting function
105
- // if (selectedOption === 'DATE') sortedProjects = sortByDate(sortedProjects);
106
- // else if (selectedOption === 'USER') sortedProjects = sortByUser(sortedProjects);
107
- // else if (selectedOption === 'RATING') sortedProjects = sortByRating(sortedProjects);
108
-
109
-
110
- // // create array to hold the components Project of loggin-in users
111
- // // generate an array of Project components based on queried data
112
- // const userDisplay = arrToComponent(userProjects);
113
-
114
- // // create an array of components Project that will be conditionally rendered
115
- // const sortedDisplay = arrToComponent(sortedProjects);
116
- // }
117
44
const a11yProps = ( index : any ) => ( {
118
45
id : `vertical-tab-${ index } ` ,
119
46
'aria-controls' : `vertical-tabpanel-${ index } ` ,
@@ -160,6 +87,7 @@ const useStyles = makeStyles((theme) => ({
160
87
flexGrow : 1 ,
161
88
backgroundColor : theme . palette . background . paper ,
162
89
display : 'flex' ,
90
+ // height: 224,
163
91
} ,
164
92
tabs : {
165
93
borderRight : `1px solid ${ theme . palette . divider } ` ,
@@ -184,8 +112,6 @@ const ProjectContainer = (): JSX.Element => {
184
112
const initialStyle = useContext ( styleContext ) ;
185
113
const [ style , setStyle ] = useState ( initialStyle ) ;
186
114
187
- // --------------------------Sorting Buttons------------------------------------//
188
-
189
115
// hook for sorting menu
190
116
const [ selectedOption , setSelectedOption ] = useState ( 'RATING' ) ;
191
117
@@ -206,23 +132,16 @@ const ProjectContainer = (): JSX.Element => {
206
132
const sortedRatings = projects . sort ( ( a , b ) => b . username - a . username ) ;
207
133
return sortedRatings ;
208
134
} ;
209
- // ===================================================================================== //
210
-
211
135
// function for selecting drop down sorting menu
212
136
const optionClicked = ( value ) => {
213
137
setSelectedOption ( value ) ;
214
138
} ;
215
- // ===================================================================================== //
216
-
217
-
218
139
// useQuery hook abstracts fetch request
219
140
const { loading, error, data } = useQuery ( GET_PROJECTS , { pollInterval : 2000 , variables : myVar } ) ;
220
141
if ( loading ) return < p > Loading...</ p > ;
221
142
if ( error ) return < p > Error :{ error } </ p > ;
222
-
223
143
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
224
144
const projects = data . getAllProjects ;
225
- console . log ( 'projects data' , projects ) ;
226
145
// create array to hold the data recieved in the public dashboard the will be conditionally rendered
227
146
let sortedProjects = projects . filter ( proj => {
228
147
return proj . published
@@ -240,17 +159,15 @@ const ProjectContainer = (): JSX.Element => {
240
159
// create array to hold the components Project of loggin-in users
241
160
// generate an array of Project components based on queried data
242
161
const userDisplay = arrToComponent ( userProjects ) ;
243
- console . log ( 'This is the userDisplay' , userDisplay ) ;
244
162
// create an array of components Project that will be conditionally rendered
245
163
const sortedDisplay = arrToComponent ( sortedProjects ) ;
246
- console . log ( 'This is the sortedDisplay' , sortedDisplay ) ;
247
164
return (
248
165
< div className = { classes . root } >
249
166
< MuiThemeProvider theme = { isThemeLight ? lightTheme : darkTheme } >
250
- < div >
167
+ < div className = { 'dashboardContainer' } >
251
168
< NavBarDash setTheme = { setTheme } styles = { [ style , setStyle ] } isThemeLight = { isThemeLight } optionClicked = { optionClicked } />
252
- < div >
253
- < AppBar position = "static" >
169
+ < div className = { 'userDashboard' } >
170
+ { /* <AppBar position="static"> */ }
254
171
< Tabs
255
172
variant = "scrollable"
256
173
orientation = "vertical"
@@ -262,14 +179,14 @@ const ProjectContainer = (): JSX.Element => {
262
179
< LinkTab label = "Shared Dashboard" { ...a11yProps ( 0 ) } />
263
180
< LinkTab label = "Private Dashboard" { ...a11yProps ( 1 ) } />
264
181
</ Tabs >
265
- </ AppBar >
266
- < TabPanelItem value = { value } index = { 0 } >
182
+ { /* </AppBar> */ }
183
+ < TabPanelItem className = { 'projectPanel' } value = { value } index = { 0 } >
267
184
< h1 > Shared Dashboard </ h1 >
268
- < div >
185
+ < div className = "projectContainer" >
269
186
{ sortedDisplay }
270
187
</ div >
271
188
</ TabPanelItem >
272
- < TabPanelItem value = { value } index = { 1 } >
189
+ < TabPanelItem className = { 'projectPanel' } value = { value } index = { 1 } >
273
190
< h1 > Private Dashboard </ h1 >
274
191
< div className = "projectContainer" >
275
192
{ userDisplay }
0 commit comments