#105 some page user tasks

parent c45fea41
...@@ -11,6 +11,7 @@ import Projects from "./containers/Projects/Projects"; ...@@ -11,6 +11,7 @@ import Projects from "./containers/Projects/Projects";
import FullProject from "./containers/FullProject/FullProject"; import FullProject from "./containers/FullProject/FullProject";
import NewProject from "./containers/NewProject/NewProject"; import NewProject from "./containers/NewProject/NewProject";
import WeekCalendar from "./containers/WeekCalendar/WeekCalendar"; import WeekCalendar from "./containers/WeekCalendar/WeekCalendar";
import UsersTasks from "./containers/UsersTasks/UsersTasks";
const ProtectedRoute = ({ isAllowed, roles, redirectUrl, children }) => { const ProtectedRoute = ({ isAllowed, roles, redirectUrl, children }) => {
const user = useSelector(state => state.users?.user); const user = useSelector(state => state.users?.user);
...@@ -117,10 +118,11 @@ const App = () => { ...@@ -117,10 +118,11 @@ const App = () => {
<Route path={"/workers-tasks"} element={ <Route path={"/workers-tasks"} element={
<ProtectedRoute <ProtectedRoute
roles={["superuser"]}
isAllowed={user}
redirectUrl={"/"} redirectUrl={"/"}
> >
<h1>workers tasks page</h1> <UsersTasks/>
</ProtectedRoute> </ProtectedRoute>
} /> } />
......
...@@ -180,7 +180,7 @@ const TableRowTask= ({ ...@@ -180,7 +180,7 @@ const TableRowTask= ({
task, task,
name: "author", name: "author",
value: task.author.displayName, value: task.author.displayName,
onChange: onAuthorChange, // onChange: onAuthorChange,
user:user user:user
}} }}
/> />
......
...@@ -29,7 +29,7 @@ export default function MyTaskToolBar({projects,onClose,projectName,setProjectNa ...@@ -29,7 +29,7 @@ export default function MyTaskToolBar({projects,onClose,projectName,setProjectNa
<AppBar position="static"> <AppBar position="static">
<Toolbar> <Toolbar>
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
Мои задачи Задачи сотрудников
</Typography> </Typography>
{projectsFilter} {projectsFilter}
......
...@@ -11,7 +11,7 @@ import { useState, useEffect } from "react"; ...@@ -11,7 +11,7 @@ import { useState, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import TaskModal from "../../components/UsersTasksCompoments/TaskModal/TaskModal"; import TaskModal from "../../components/UsersTasksCompoments/TaskModal/TaskModal";
import moment from "moment"; import moment from "moment";
import MyTaskToolBar from "../../components/UsersTasksCompoments/MyTaskToolBar"; import MyTaskToolBar from "../../components/UsersTasksCompoments/UsersTaskToolBar";
import { fetchAllTasks, deleteTask,editTask, deleteDateTimeTask} from "../../store/actions/tasksActions"; import { fetchAllTasks, deleteTask,editTask, deleteDateTimeTask} from "../../store/actions/tasksActions";
import NewTaskForm from "../../components/UsersTasksCompoments/NewTaskForm"; import NewTaskForm from "../../components/UsersTasksCompoments/NewTaskForm";
import TableRowTask from "../../components/UsersTasksCompoments/TableRowTask/TableRowTask"; import TableRowTask from "../../components/UsersTasksCompoments/TableRowTask/TableRowTask";
...@@ -26,6 +26,7 @@ export default function UsersTasks() { ...@@ -26,6 +26,7 @@ export default function UsersTasks() {
const user = useSelector((state) => state.users.user); const user = useSelector((state) => state.users.user);
const [executors, setExecutors]=useState([]) const [executors, setExecutors]=useState([])
const [projects,setProjects]=useState([]) const [projects,setProjects]=useState([])
const [currentProject, setCurrentProject] = useState(null);
const [recievedTasks, setRecievedTasks] = useState([]); const [recievedTasks, setRecievedTasks] = useState([]);
const [addTaskForm, setAddTaskForm] = useState(false); const [addTaskForm, setAddTaskForm] = useState(false);
const [order, setOrder] = useState("asc"); const [order, setOrder] = useState("asc");
...@@ -72,7 +73,7 @@ useEffect(() => { ...@@ -72,7 +73,7 @@ useEffect(() => {
const name = e.target.name; const name = e.target.name;
const { id } = task; const { id } = task;
const newTasks = recievedTasks.map((task) => { const newTasks = recievedTasks.map((task) => {
console.log(task) console.log('recievedTasks.map ',task)
if (task.id === id) { if (task.id === id) {
return { ...task, [name]: value }; return { ...task, [name]: value };
} }
...@@ -110,8 +111,8 @@ useEffect(() => { ...@@ -110,8 +111,8 @@ useEffect(() => {
}; };
const onProjectChange = (e, task) => { const onProjectChange = (e, task) => {
const value = e.target.value; const projectId = e.target.value;
const project = uniqueProjects.find((e) => e.id === value); const project = uniqueProjects.find((uniqueProject) => uniqueProject.id === projectId);
const { id } = task; const { id } = task;
const newTasks = recievedTasks.map((task) => { const newTasks = recievedTasks.map((task) => {
if (task.id === id) { if (task.id === id) {
...@@ -126,8 +127,8 @@ useEffect(() => { ...@@ -126,8 +127,8 @@ useEffect(() => {
}; };
const onExecutorChange = (e, task) => { const onExecutorChange = (e, task) => {
const value = e.target.value; const executorId = e.target.value;
const executor = uniqueExecutors.find((e) => e.id === value); const executor = executors.find((executor) => executor.id === executorId);
const { id } = task; const { id } = task;
const newTasks = recievedTasks.map((task) => { const newTasks = recievedTasks.map((task) => {
if (task.id === id) { if (task.id === id) {
...@@ -138,6 +139,7 @@ useEffect(() => { ...@@ -138,6 +139,7 @@ useEffect(() => {
} }
return task; return task;
}); });
setRecievedTasks(newTasks);
}; };
...@@ -298,7 +300,7 @@ console.log('tasks', tasks) ...@@ -298,7 +300,7 @@ console.log('tasks', tasks)
executors={executors} executors={executors}
onExecutorChange={onExecutorChange} onExecutorChange={onExecutorChange}
uniqueProjects={uniqueProjects} uniqueProjects={uniqueProjects}
onAuthorChange={onAuthorChange} // onAuthorChange={onAuthorChange}
onDateChange={onDateChange} onDateChange={onDateChange}
onToggleEditMode={onToggleEditMode} onToggleEditMode={onToggleEditMode}
onToggleEditModeDone={onToggleEditModeDone} onToggleEditModeDone={onToggleEditModeDone}
......
...@@ -118,7 +118,7 @@ export default function UsersTasksHeader({ order, orderBy, rowCount, onRequestSo ...@@ -118,7 +118,7 @@ export default function UsersTasksHeader({ order, orderBy, rowCount, onRequestSo
); );
} }
EnhancedTableHead.propTypes = { UsersTasksHeader.propTypes = {
onRequestSort: PropTypes.func.isRequired, onRequestSort: PropTypes.func.isRequired,
order: PropTypes.oneOf(["asc", "desc"]).isRequired, order: PropTypes.oneOf(["asc", "desc"]).isRequired,
orderBy: PropTypes.string.isRequired, orderBy: PropTypes.string.isRequired,
......
...@@ -53,7 +53,7 @@ export const fetchProjects = () => { ...@@ -53,7 +53,7 @@ export const fetchProjects = () => {
return async dispatch => { return async dispatch => {
dispatch(fetchProjectsRequest()); dispatch(fetchProjectsRequest());
try { try {
const response = await axios.get("/projects"); const response = await axios.get("/projects/my");
dispatch(fetchProjectsSuccess(response.data)); dispatch(fetchProjectsSuccess(response.data));
} catch(e) { } catch(e) {
dispatch(fetchProjectsError(e)); dispatch(fetchProjectsError(e));
......
Markdown is supported
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