Skip to content

Commit 2137b17

Browse files
MadinventorZerojonocrbuddhajjigaexkevinparkwilliamdyoon
committed
Refactored Dash to Utilize Tabs.
Co-authored-by: jonocr <[email protected]> Co-authored-by: buddhajjigae <[email protected]> Co-authored-by: xkevinpark <[email protected]> Co-authored-by: williamdyoon <[email protected]>
1 parent 9e5d274 commit 2137b17

File tree

2 files changed

+13
-92
lines changed

2 files changed

+13
-92
lines changed

app/src/Dashboard/ProjectContainer.tsx

Lines changed: 8 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ import AppBar from '@material-ui/core/AppBar';
1010
import Tabs from '@material-ui/core/Tabs';
1111
import Tab from '@material-ui/core/Tab';
1212

13-
// import {Tab, Tabs} from '@material-ui/core'
14-
1513
import Box from '@material-ui/core/Box';
1614
import { GET_PROJECTS } from './gqlStrings';
1715
import Project from './Project';
1816
import NavBarDash from './NavbarDash';
1917

20-
21-
import AppContainer from '../containers/AppContainer';
2218
import { theme1, theme2 } from '../public/styles/theme';
2319
// Implement Apollo Client useQuery hook to retrieve data from the server through graphQL. This includes 2 steps:
2420
// 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
4541
id = {proj.id}
4642
comments = {proj.comments}
4743
/>);
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-
// }
11744
const a11yProps = (index: any) => ({
11845
id: `vertical-tab-${index}`,
11946
'aria-controls': `vertical-tabpanel-${index}`,
@@ -160,6 +87,7 @@ const useStyles = makeStyles((theme) => ({
16087
flexGrow: 1,
16188
backgroundColor: theme.palette.background.paper,
16289
display: 'flex',
90+
// height: 224,
16391
},
16492
tabs: {
16593
borderRight: `1px solid ${theme.palette.divider}`,
@@ -184,8 +112,6 @@ const ProjectContainer = (): JSX.Element => {
184112
const initialStyle = useContext(styleContext);
185113
const [style, setStyle] = useState(initialStyle);
186114

187-
// --------------------------Sorting Buttons------------------------------------//
188-
189115
// hook for sorting menu
190116
const [selectedOption, setSelectedOption] = useState('RATING');
191117

@@ -206,23 +132,16 @@ const ProjectContainer = (): JSX.Element => {
206132
const sortedRatings = projects.sort((a, b) => b.username - a.username);
207133
return sortedRatings;
208134
};
209-
// ===================================================================================== //
210-
211135
// function for selecting drop down sorting menu
212136
const optionClicked = (value) => {
213137
setSelectedOption(value);
214138
};
215-
// ===================================================================================== //
216-
217-
218139
// useQuery hook abstracts fetch request
219140
const { loading, error, data } = useQuery(GET_PROJECTS, { pollInterval: 2000, variables: myVar });
220141
if (loading) return <p>Loading...</p>;
221142
if (error) return <p>Error :{error}</p>;
222-
223143
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
224144
const projects = data.getAllProjects;
225-
console.log('projects data', projects);
226145
// create array to hold the data recieved in the public dashboard the will be conditionally rendered
227146
let sortedProjects = projects.filter(proj => {
228147
return proj.published
@@ -240,17 +159,15 @@ const ProjectContainer = (): JSX.Element => {
240159
// create array to hold the components Project of loggin-in users
241160
// generate an array of Project components based on queried data
242161
const userDisplay = arrToComponent(userProjects);
243-
console.log('This is the userDisplay', userDisplay);
244162
// create an array of components Project that will be conditionally rendered
245163
const sortedDisplay = arrToComponent(sortedProjects);
246-
console.log('This is the sortedDisplay', sortedDisplay);
247164
return (
248165
<div className={classes.root}>
249166
<MuiThemeProvider theme={isThemeLight ? lightTheme : darkTheme}>
250-
<div >
167+
<div className= {'dashboardContainer'}>
251168
<NavBarDash setTheme={setTheme} styles={[style, setStyle]} isThemeLight={isThemeLight} optionClicked={optionClicked}/>
252-
<div >
253-
<AppBar position="static">
169+
<div className={'userDashboard'}>
170+
{/* <AppBar position="static"> */}
254171
<Tabs
255172
variant="scrollable"
256173
orientation="vertical"
@@ -262,14 +179,14 @@ const ProjectContainer = (): JSX.Element => {
262179
<LinkTab label="Shared Dashboard" {...a11yProps(0)} />
263180
<LinkTab label="Private Dashboard" {...a11yProps(1)} />
264181
</Tabs>
265-
</AppBar>
266-
<TabPanelItem value={value} index={0}>
182+
{/* </AppBar> */}
183+
<TabPanelItem className= {'projectPanel'} value={value} index={0}>
267184
<h1> Shared Dashboard </h1>
268-
<div >
185+
<div className="projectContainer">
269186
{sortedDisplay}
270187
</div>
271188
</TabPanelItem>
272-
<TabPanelItem value={value} index={1}>
189+
<TabPanelItem className= {'projectPanel'} value={value} index={1}>
273190
<h1> Private Dashboard </h1>
274191
<div className="projectContainer">
275192
{userDisplay}

app/src/Dashboard/styles.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
.userDashboard {
2121
display: flex;
22-
flex-direction: column;
22+
flex-direction: row;
23+
}
24+
25+
.projectPanel {
26+
width: 100%;
2327
}
2428

2529
.projectContainer{

0 commit comments

Comments
 (0)