From ba4c2da716f2d0ccba51cc445b180a8151e68d19 Mon Sep 17 00:00:00 2001 From: Boris Blagojevic Date: Sun, 11 Feb 2024 21:31:29 +0100 Subject: [PATCH] #73: Detailed task FE BE Introducing Detailed task page --- app/web/src/App.js | 2 + app/web/src/components/pages/task/Task.js | 50 +++++++++++++++++++ .../src/components/ui/grid/GridController.js | 3 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 app/web/src/components/pages/task/Task.js diff --git a/app/web/src/App.js b/app/web/src/App.js index 6cb56ab..d63e108 100644 --- a/app/web/src/App.js +++ b/app/web/src/App.js @@ -10,6 +10,7 @@ import Settings from './components/pages/settings/Settings'; import Login from './components/pages/auth/login/Login'; import Register from './components/pages/auth/register/Register'; import HandleSession from './components/pages/auth/HandleSession'; +import Task from './components/pages/task/Task'; const App = () => { @@ -49,6 +50,7 @@ const App = () => : } /> + : } /> : } /> : } /> : } /> diff --git a/app/web/src/components/pages/task/Task.js b/app/web/src/components/pages/task/Task.js new file mode 100644 index 0000000..acc2615 --- /dev/null +++ b/app/web/src/components/pages/task/Task.js @@ -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 <> +
+ +}; + +export default Task; \ No newline at end of file diff --git a/app/web/src/components/ui/grid/GridController.js b/app/web/src/components/ui/grid/GridController.js index 692e596..4f23d16 100644 --- a/app/web/src/components/ui/grid/GridController.js +++ b/app/web/src/components/ui/grid/GridController.js @@ -13,7 +13,6 @@ const HomeController = () => const btoken = useSelector(state => state.user.btoken); const status = useSelector(state => state.task.statusDefinition); - const getData = async (teamId) => { axios.get('http://localhost:8080/tasks/team/' + ( teamId ?? -1 ), @@ -28,7 +27,7 @@ const HomeController = () => .catch(e => dispatch(teamActions.setTeamTasks([]))); }; - const _handleClick = (id) => nav('tasks/' + id); + const _handleClick = (id) => nav('task/' + id); const changeStatus = (e, id) => {