-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing Detailed task page
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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
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,50 @@ | ||
import { useSelector } from 'react-redux'; | ||
import axios from 'axios'; | ||
import Header from '../../layout/header/Header'; | ||
|
||
const getTask = (tasks) => | ||
{ | ||
const id = document.URL.split('/').pop(); | ||
let t; | ||
|
||
if (tasks) | ||
{ | ||
t = tasks[tasks.findIndex(t => t.id === Number.parseInt(id))]; | ||
} | ||
|
||
if (t === undefined) | ||
{ | ||
axios.get('http://localhost:8080/tasks/' + id) | ||
.then(res => | ||
{ | ||
if (res.status === 200 && res.data.status) | ||
{ | ||
console.log(res.data) | ||
t = res.data | ||
} | ||
}) | ||
.catch(e => | ||
{ | ||
console.warn(e) | ||
t = null; | ||
}) | ||
} | ||
|
||
return t | ||
} | ||
const Task = () => | ||
{ | ||
|
||
const task = getTask(useSelector(state => state.team.teamTasks)); | ||
|
||
console.log(task) | ||
|
||
return <> | ||
<Header | ||
titleTxt={ '#' + task.id + ' / t' + task.teamId + ': ' + task.title } | ||
subtitleTxt={ `Created by ` + task.creatorId + ' Created on: ' + task.createdDate } | ||
/> | ||
</> | ||
}; | ||
|
||
export default Task; |
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