Commit 07a8101b authored by ethan's avatar ethan
Browse files

Added welcome message; filtering pending project tasks in the Dashboard [BG, EW]

parent 6882e79a
......@@ -28,6 +28,16 @@ def get_tasks_for_user(username):
return jsonify(task_list)
@assigned_task.route('/assigned_task/pending/username/<username>', methods=['GET'])
def get_pending_tasks_for_user(username):
entries = AssignedTask.query.filter_by(username=username)
task_list = [{"description": task.description,
"priority": task.priority,
"due_date": task.due_date} for task in (Task.query.get(x.task_id) for x in entries) if not task.completed]
return jsonify(task_list)
@assigned_task.route('/assigned_task', methods=['POST'])
def assign_task_to_user():
username, task_id = (request.json['username'], request.json['task_id'])
......
......@@ -45,6 +45,13 @@ def get_id(username):
interests = user.interests
)
@user.route('/users/name/<username>', methods=['GET'])
def get_name(username):
user = User.query.get(username)
return jsonify(
firstname = user.firstname,
surname = user.surname
)
@user.route('/users', methods=['POST'])
def add_user():
......
......@@ -11,6 +11,10 @@ const Home = () => {
const { setToken, token } = useToken();
const { data: projects, errorRProjects, isPendingRProjects } = useFetch("/user_project/username/" + token);
const { data: {firstname, surname}} = useFetch("/users/name/" + token);
const { data: project_tasks, errorProjectTasks, isPendingProjectTasks} = useFetch("/assigned_task/pending/username/" + token);
const myTodos = todos.filter(todo => todo.username === token);
// const project_tasks = [
// {
// "description": "This is example 1",
......@@ -38,22 +42,25 @@ const Home = () => {
// }
// ]
const {data: project_tasks, errorProjectTasks, isPendingProjectTasks} = useFetch("/assigned_task/username/" + token)
return (
<div className="home">
<h1>Dashboard</h1>
<h1>Welcome to your Dashboard, {firstname}</h1>
{console.log("Firstname: " )}
<div className="home-projects" style={{ float: "left", width: "600px" }}>
{isPendingRProjects && <h2>Loading...</h2>}
{projects && <ProjectList projects={projects} title="My Projects" />}
{projects && (Object.keys(projects).length === 0) && <h2>You are not currently part of any projects</h2>}
</div>
<div className="homeTodos">
<div className="homeTodos" style={{ float: "right", width: "300px" }}>
{isPendingTodos && <h2>Loading...</h2>}
{todos && <PersonalToDo todos={todos.filter(todo => todo.username === token)} title="Personal ToDo items" />}
{todos && <PersonalToDo todos={myTodos} title="Personal ToDo items" />}
{todos && (Object.keys(myTodos).length === 0) && <h2>Well done you have no ToDo items</h2>}
</div>
<div className="home-project-tasks" style={{ float: "left", width: "600px" }}>
{isPendingRProjects && <h2>Loading...</h2>}
{projects && <MyProjectTasks tasks={project_tasks} title="My tasks from all projects" />}
{projects && (Object.keys(project_tasks).length === 0) && <h2>Well done you have no project tasks</h2>}
</div>
</div>
......
......@@ -11,6 +11,7 @@ const MyProjectTasks = ({ tasks, title }) => {
<div className="task-preview" key={task.id}>
<h2>{task.description}</h2>
<h3><strong>Priority level:</strong> {task.priority}</h3>
<h3><strong></strong> {task.priority}</h3>
<h3><strong>To be done by:</strong> {task.due_date}</h3>
</div>
))}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment