-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Eevee-Elites-Capstone/project-dashboard
Project dashboard
- Loading branch information
Showing
19 changed files
with
17,288 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"editor.tokenColorCustomizations": { | ||
"comments": "", | ||
"textMateRules": [] | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Link } from 'react-router-dom' | ||
import Avatar from '../UI/Avatar' | ||
|
||
export default function AllProjects({ projects }) { | ||
console.log(projects) | ||
|
||
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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
function Calendar() { | ||
return ( <> | ||
|
||
</> ); | ||
} | ||
|
||
export default Calendar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.create-form { | ||
max-width: 600px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { useEffect, useState } from 'react' | ||
import { useHistory } from 'react-router-dom' | ||
import Select from 'react-select' | ||
import { timestamp } from '../../firebase/fbConfig' | ||
import { useAuthContext } from '../../hooks/useAuthContext' | ||
import { useCollection } from '../../hooks/useCollection' | ||
import { useFirestore } from '../../hooks/useFirestore' | ||
|
||
|
||
// styles | ||
import './Create.css' | ||
|
||
const categories = [ | ||
{ value: 'development', label: 'Development' }, | ||
{ value: 'design', label: 'Design' }, | ||
{ value: 'sales', label: 'Sales' }, | ||
{ value: 'marketing', label: 'Marketing' }, | ||
] | ||
|
||
export default function CreateProject() { | ||
/**history hooks from react-router-dom */ | ||
const history = useHistory() | ||
/**Add project collection to firestore */ | ||
const { addDocument, response } = useFirestore('projects') | ||
/*Assign function*/ | ||
const { documents } = useCollection('users') | ||
// console.log('All users', documents); | ||
const [users, setUsers] = useState([]) | ||
const { user } = useAuthContext() | ||
|
||
/*map through the array of all users*/ | ||
useEffect(() => { | ||
if(documents) { | ||
const userOptions = documents.map(user => { | ||
return { value: {...user, id: user.id}, label: user.displayName } | ||
}) | ||
setUsers(userOptions) | ||
} | ||
}, [documents]) | ||
// console.log(users) | ||
|
||
// form field values | ||
const [name, setName] = useState('') | ||
const [details, setDetails] = useState('') | ||
const [dueDate, setDueDate] = useState('') | ||
const [category, setCategory] = useState('') | ||
const [assignedUsers, setAssignedUsers] = useState([]) | ||
const [formError, setFormError] = useState(null) | ||
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault() | ||
setFormError(null) | ||
/**Catching form error */ | ||
if(!category) { | ||
setFormError('Please select a project category') | ||
return | ||
} | ||
// if(assignedUsers.length < 1) { | ||
// setFormError('Please assign the project to at least 1 user') | ||
// return | ||
// } | ||
const assignedUsersList = assignedUsers.map(u => { | ||
return { | ||
displayName: u.value.displayName, | ||
photoURL: u.value.photoURL, | ||
id: u.value.id | ||
} | ||
}) | ||
const createdBy = { | ||
displayName: user.displayName, | ||
photoURL: user.photoURL, | ||
id: user.uid | ||
} | ||
const project = { | ||
name, | ||
details, | ||
category: category.value, | ||
dueDate: timestamp.fromDate(new Date(dueDate)), | ||
comments: [], | ||
createdBy, | ||
dueDate | ||
} | ||
// console.log(name, details, dueDate, category.value, assignedUsers) | ||
// console.log('project object', project); | ||
/**Add document to firestore */ | ||
await addDocument(project) | ||
if(!response.error) { | ||
history.push('/dashboard') | ||
} | ||
} | ||
|
||
|
||
return ( | ||
<div className="create-form"> | ||
<h2 className="page-title">Create a new Project</h2> | ||
<form onSubmit={handleSubmit}> | ||
<label> | ||
<span>Project name:</span> | ||
<input | ||
required | ||
type="text" | ||
onChange={(e) => setName(e.target.value)} | ||
value={name} | ||
/> | ||
</label> | ||
<label> | ||
<span>Project Details:</span> | ||
<textarea | ||
required | ||
onChange={(e) => setDetails(e.target.value)} | ||
value={details} | ||
></textarea> | ||
</label> | ||
<label> | ||
<span>Set due date:</span> | ||
<input | ||
required | ||
type="date" | ||
onChange={(e) => setDueDate(e.target.value)} | ||
value={dueDate} | ||
/> | ||
</label> | ||
<label> | ||
<span>Project category:</span> | ||
<Select | ||
onChange={(option) => setCategory(option)} | ||
options={categories} | ||
/> | ||
</label> | ||
<label> | ||
<span>Assign to:</span> | ||
<Select | ||
onChange={(userOption) => setAssignedUsers(userOption)} | ||
options={users} | ||
isMulti | ||
/> | ||
</label> | ||
|
||
<button className="btn">Add Project</button> | ||
|
||
{formError && <p className="error">{formError}</p>} | ||
</form> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import React from 'react'; | ||
import Card from './Card'; | ||
import Sidebar from './Sidebar'; | ||
import { useCollection } from '../../hooks/useCollection' | ||
|
||
function Dashboard() { | ||
return (<div> | ||
<Sidebar /> | ||
// components | ||
import AllProjects from './AllProjects' | ||
|
||
export default function Dashboard() { | ||
const { documents, error } = useCollection('projects') | ||
|
||
return ( | ||
<div> | ||
<Card/> | ||
<h2 className="page-title">Dashboard</h2> | ||
{error && <p className="error">{error}</p>} | ||
{documents && <AllProjects projects={documents} />} | ||
</div> | ||
</div>); | ||
) | ||
} | ||
|
||
export default Dashboard; |
Oops, something went wrong.