Skip to content

Commit

Permalink
#73: Detailed task FE BE
Browse files Browse the repository at this point in the history
Introducing Detailed task page
  • Loading branch information
Blagoja95 committed Feb 14, 2024
1 parent 4dc60bc commit ba4c2da
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
{
Expand Down Expand Up @@ -49,6 +50,7 @@ const App = () =>

<Routes>
<Route path='/' element={activeUser ? <Home /> : <Login />} />
<Route path='/task/*' element={activeUser ? <Task /> : <Login />} />
<Route path='/settings' element={activeUser ? <Settings /> : <Login />} />
<Route path='/auth/login' element={activeUser ? <Home /> : <Login />} />
<Route path='/auth/register' element={activeUser ? <Home /> : <Register />} />
Expand Down
50 changes: 50 additions & 0 deletions app/web/src/components/pages/task/Task.js
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;
3 changes: 1 addition & 2 deletions app/web/src/components/ui/grid/GridController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand All @@ -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) =>
{
Expand Down

0 comments on commit ba4c2da

Please sign in to comment.