#105 some page user tasks

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