Skip to content

Commit ab95470

Browse files
committed
Implement public dashboard and user dashboard with in seprate view
1 parent ccfcf4d commit ab95470

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

app/src/Dashboard/ProjectContainer.jsx

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,40 @@ const ProjectContainer = () => {
3333
if (loading) return <p>Loading...</p>;
3434
if (error) return <p>Error :{error}</p>;
3535
// based on resolver(getAllProject) for this query, the data is stored in the data object with the key 'getAllProjects'
36-
const myProjs = data.getAllProjects;
37-
console.log('Projects >>> ', myProjs);
36+
const projects = data.getAllProjects;
37+
console.log('Projects >>> ', projects);
3838
// generate an array of Project components based on data
39-
const projects = myProjs.map((proj, index) => <Project
40-
key= { index }
41-
name = {proj.name}
42-
likes = {proj.likes}
43-
userId = {proj.userId}
44-
username = {proj.username}
45-
id = {proj.id}
46-
/>);
39+
const publicProjects = [];
40+
const userProjects = [];
41+
projects.forEach((proj, index) => {
42+
const component = <Project
43+
key= { index }
44+
name = {proj.name}
45+
likes = {proj.likes}
46+
userId = {proj.userId}
47+
username = {proj.username}
48+
id = {proj.id}
49+
/>;
50+
if (username === proj.username) userProjects.push(component);
51+
else publicProjects.push(component);
52+
});
4753

4854
return (
4955
<div>
50-
<h1> Public Dashboard </h1>
5156
<Link to="/">
5257
<button type="button">Go Back</button>
5358
</Link>
59+
<h1> Public Dashboard </h1>
60+
<div className = "projectContainer">
61+
{publicProjects}
62+
</div>
63+
<hr></hr>
64+
<h1> User Dashboard </h1>
5465
<div className = "projectContainer">
55-
{projects}
66+
{userProjects}
67+
</div>
68+
5669
</div>
57-
</div>
5870
);
5971
};
6072

server/graphQL/resolvers/mutation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const Project = {
104104
const filter = { _id: projId };
105105
const options = { strict: true };
106106
const resp = await Projects.findOneAndDelete(filter, options);
107-
console.log("resp", resp);
107+
// console.log("resp", resp);
108108
if (resp) {
109109
return ({
110110
name: resp.name,

server/models/reactypeModels.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const projectSchema = new Schema({
6666
},
6767
username: {type: String, required: true },
6868
createdAt: { type: Date, default: Date.now }
69-
}, { minimize: false });
69+
}, { minimize: false }
70+
);
7071
// option 'minimize' prevent Mongoose from removing empty 'style' value in the copy
7172

7273
// Test schema for implementing GraphQL

0 commit comments

Comments
 (0)