From 661ffda0ebe68b4d49888e8b14bc85f1f3140326 Mon Sep 17 00:00:00 2001 From: Aaron Williams Date: Wed, 24 Jun 2020 18:13:59 -0700 Subject: [PATCH 1/5] Update updateUser --- src/actions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/actions.js b/src/actions.js index 1753cf9..d8abc8a 100644 --- a/src/actions.js +++ b/src/actions.js @@ -145,7 +145,7 @@ export function updateUser(payload, id) { } axios - .put(` https://get2itpt9.herokuapp.com/api/auth/edit-profile/${id}`, payload, { headers }) + .put(` https://get2itpt9.herokuapp.com/api/auth/users/${id}`, payload, { headers }) .then(res => { dispatch({ type: UPDATE_USER_SUCCESS, payload: payload, id: id }); }) @@ -170,7 +170,10 @@ export function createTask(payload, user_id, category_id) { dispatch({ type: CREATE_TASK_SUCCESS, payload: payload}); let task_id = res.data.id; console.log(task_id, user_id, category_id); - return axios.post(`https://get2itpt9.herokuapp.com/api/categories/${category_id}/tasks`, {task_id: task_id}, {headers}) + return axios.post(`https://get2itpt9.herokuapp.com/api/categories/${category_id}/tasks`, + {task_id: task_id}, + {headers} + ) }) .then(res => console.log(res)) .catch(err => { From 95ee8f54e5027fb06210a3259fa7eaf63167f29b Mon Sep 17 00:00:00 2001 From: Aaron Williams Date: Wed, 24 Jun 2020 19:37:05 -0700 Subject: [PATCH 2/5] Put missing categoryID variable in fxns createTask --- src/Components/NewTask/NewTask.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/NewTask/NewTask.js b/src/Components/NewTask/NewTask.js index 04ff72c..b22895e 100644 --- a/src/Components/NewTask/NewTask.js +++ b/src/Components/NewTask/NewTask.js @@ -112,7 +112,7 @@ class NewTask extends React.Component { notificationId: notificationId }; - createTask(payload, id) + createTask(payload, id, categoryID) .then(() => { this.props.updateFilteredTask([]); this.props.timePeriod('Today'); @@ -135,7 +135,7 @@ class NewTask extends React.Component { notificationId: notificationId }; - createTask(payload, id) + createTask(payload, id, categoryID) .then(() => { this.props.updateFilteredTask([]); this.props.timePeriod('Today'); @@ -157,7 +157,7 @@ class NewTask extends React.Component { end_time, notificationId: notificationId }; - createTask(payload, id) + createTask(payload, id, categoryID) .then(() => { this.props.updateFilteredTask([]); this.props.timePeriod('Today'); From 840ad113ef0d617fdc2cbd383c25c4924175b299 Mon Sep 17 00:00:00 2001 From: Aaron Williams Date: Wed, 24 Jun 2020 20:04:04 -0700 Subject: [PATCH 3/5] Added async await to fxn complete --- src/Components/TaskList/index.js | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Components/TaskList/index.js b/src/Components/TaskList/index.js index e0009c6..01169ab 100644 --- a/src/Components/TaskList/index.js +++ b/src/Components/TaskList/index.js @@ -37,7 +37,8 @@ class editTaskList extends React.Component { taskList: list }) } - itemArr = [] + + itemArr = []; check = item => { var task = item.id console.log(task) @@ -58,6 +59,7 @@ class editTaskList extends React.Component { this.classBTN(item) console.log(this.itemArr) } + classBTN = item => { console.log("hitting check") $("#containter") @@ -66,7 +68,7 @@ class editTaskList extends React.Component { } arrar = [] - complete = () => { + complete = async () => { for (var i = 0; i < this.itemArr.length; i++) { this.arrar.push(this.itemArr[i]) } @@ -75,7 +77,7 @@ class editTaskList extends React.Component { this.getTaskById(id) }) - setTimeout(() => { + await setTimeout(() => { window.location.reload(true) }, 500) } @@ -87,14 +89,11 @@ class editTaskList extends React.Component { this.tasksById.push(task) } }) - // console.log(this.tasksById) this.setState( { retrievedTasks: this.tasksById }, () => { - // console.log(this.state.retrievedTasks); - this.state.retrievedTasks.map(task => { const id = task.id const payload = { @@ -109,18 +108,18 @@ class editTaskList extends React.Component { ) } - deleted = id => { + deleted = async (id) => { this.props.deleteTask(id) - this.setState( - { - taskList: this.props.userTasks.filter(task => { - return task.status === false - }) - }, - setTimeout(() => { - window.location.reload(true) - }, 100) - ) + // await this.setState( + // { + // taskList: this.props.userTasks.filter(task => { + // return task.status === false + // }) + // }, + // await setTimeout(() => { + // window.location.reload(true) + // }, 500) + // ) } componentDidMount() { @@ -133,7 +132,6 @@ class editTaskList extends React.Component { return task.status === true }) - // render content to page render() { return (
From ff4f89e0c9338e9291e37accf805d958917e5ca6 Mon Sep 17 00:00:00 2001 From: Aaron Williams Date: Wed, 24 Jun 2020 20:25:45 -0700 Subject: [PATCH 4/5] Fixed CSS class that is called --- src/Components/Home/Filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Home/Filter.js b/src/Components/Home/Filter.js index 184bb81..3549c55 100644 --- a/src/Components/Home/Filter.js +++ b/src/Components/Home/Filter.js @@ -19,7 +19,7 @@ export const Filter = props => { let alert; if (incompleteTasks.length === 0) { - alert = 'noAlert' + alert = 'filterButton' } else { alert = 'Alert' } From 0a58a828fe0965cd5d9bf7a16fd3abd1799d1b1a Mon Sep 17 00:00:00 2001 From: Aaron Williams Date: Thu, 25 Jun 2020 00:32:04 -0700 Subject: [PATCH 5/5] Removed commenting out deleted fxn --- src/Components/TaskList/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Components/TaskList/index.js b/src/Components/TaskList/index.js index 01169ab..27dc3d1 100644 --- a/src/Components/TaskList/index.js +++ b/src/Components/TaskList/index.js @@ -108,18 +108,18 @@ class editTaskList extends React.Component { ) } - deleted = async (id) => { + deleted = id => { this.props.deleteTask(id) - // await this.setState( - // { - // taskList: this.props.userTasks.filter(task => { - // return task.status === false - // }) - // }, - // await setTimeout(() => { - // window.location.reload(true) - // }, 500) - // ) + this.setState( + { + taskList: this.props.userTasks.filter(task => { + return task.status === false + }) + }, + setTimeout(() => { + window.location.reload(true) + }, 500) + ) } componentDidMount() {