Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project dashboard #21

Merged
merged 7 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
split allprojects to a seperate component
  • Loading branch information
jackie-ng committed Feb 2, 2022
commit c672cfe11cb420fde7ba4c521a7a761779dfcd01
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function App() {
{!user && <Redirect to="/login" />}
{user && <CreateProject />}
</Route>
<Route path="/projects/:id">
{!user && <Redirect to="/login" />}
{/* {user && <AllProjects />} */}
</Route>
</Switch>

</BrowserRouter>
Expand Down
39 changes: 29 additions & 10 deletions src/components/Dashboard/AllProjects.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import React from 'react';
function AllProjects({projects}) {
return ( <>
{projects.length === 0 && <p>No projects yet!</p>}
{projects.map(project => (
<div key={project.id}>{project.name}</div>
))}
</> );
}
import { Link } from 'react-router-dom'
import Avatar from '../UI/Avatar'

export default function AllProjects({ projects }) {
console.log(projects)

export default AllProjects;
return (
<div className="project-list">
{projects.length === 0 && <p>No projects yet!</p>}
{projects.map(project => (
<Link to={`/projects/${project.id}`} key={project.id}>
<h4>{project.name}</h4>
<p>Due by
{/* {project.dueDate.toDate().toDateString()} */}
</p>
<div className="assigned-to">
<p><strong>Assigned to:</strong></p>
<ul>
{/* {project.assignedUsersList.map(user => (
<li key={user.photoURL}>
<Avatar src={user.photoURL} />
</li>
))} */}
</ul>
</div>
</Link>
))}
</div>
)
}
2 changes: 1 addition & 1 deletion src/components/Dashboard/CreateProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function CreateProject() {
dueDate: timestamp.fromDate(new Date(dueDate)),
comments: [],
createdBy,
assignedUsersList
dueDate
}
// console.log(name, details, dueDate, category.value, assignedUsers)
// console.log('project object', project);
Expand Down
28 changes: 13 additions & 15 deletions src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React from 'react';
import { useCollection } from '../../hooks/useCollection';
import AllProjects from './AllProjects';
import Card from './Card';
import Sidebar from './Sidebar';
import { useCollection } from '../../hooks/useCollection'

function Dashboard() {
const {documents, error} = useCollection('projects')
// components
import AllProjects from './AllProjects'

return (<div>
{/* <Sidebar/> */}
<h2 className="page-title">Dashboard</h2>
{error && <p>{error}</p>}
{documents && <AllProjects projects={documents}/>}
</div>);
}
export default function Dashboard() {
const { documents, error } = useCollection('projects')

export default Dashboard;
return (
<div>
<h2 className="page-title">Dashboard</h2>
{error && <p className="error">{error}</p>}
{documents && <AllProjects projects={documents} />}
</div>
)
}