#105 added newTaskFrom

parent c42c74d2
...@@ -23,6 +23,8 @@ import TaskModal from "./TaskModal/TaskModal"; ...@@ -23,6 +23,8 @@ import TaskModal from "./TaskModal/TaskModal";
export default function NewTaskForm({ export default function NewTaskForm({
projects, projects,
currentProject,
setAddTaskForm, setAddTaskForm,
}) { }) {
const dispatch = useDispatch(); const dispatch = useDispatch();
...@@ -43,9 +45,9 @@ export default function NewTaskForm({ ...@@ -43,9 +45,9 @@ export default function NewTaskForm({
priority: "B", priority: "B",
author: { id: user.id }, author: { id: user.id },
authorDisplayName: user.displayName, authorDisplayName: user.displayName,
executors: [], executor:null,
isEditMode: true, isEditMode: true,
}); });
const [modal, setModal] = useState(false); const [modal, setModal] = useState(false);
...@@ -73,6 +75,14 @@ export default function NewTaskForm({ ...@@ -73,6 +75,14 @@ export default function NewTaskForm({
setTask(newTask); setTask(newTask);
}; };
const onExecutorChange = (e, task) => {
const value = e.target.value;
const executor = projects.find((e) => e.id === value);
const newTask = { ...task };
newTask.executor = executor;
setTask(newTask);
};
const onDateChange = (id, value, property) => { const onDateChange = (id, value, property) => {
const newTask = { const newTask = {
...task, ...task,
...@@ -159,6 +169,18 @@ export default function NewTaskForm({ ...@@ -159,6 +169,18 @@ export default function NewTaskForm({
value={task.project?.id} value={task.project?.id}
/> />
</TableCell> </TableCell>
<TableCell>
<BasicSelect
items={currentProject.members.map((member) => ({
value: member?.id,
title: member?.displayName,
}))}
task={task}
onChange={onExecutorChange}
name="executor"
value={task.executor?.id}
/>
</TableCell>
{/* <TableCell> {/* <TableCell>
<MaterialUIPickers <MaterialUIPickers
...@@ -231,7 +253,12 @@ export const header = [ ...@@ -231,7 +253,12 @@ export const header = [
disablePadding: false, disablePadding: false,
label: "Проект", label: "Проект",
}, },
{
id: "executorName",
numeric: false,
disablePadding: false,
label: "Исполнитель",
},
{ {
id: "dateTimeDue", id: "dateTimeDue",
numeric: true, numeric: true,
......
...@@ -24,6 +24,8 @@ export default function UsersTasks() { ...@@ -24,6 +24,8 @@ export default function UsersTasks() {
const tasks = useSelector((state) => state.tasks.tasks); const tasks = useSelector((state) => state.tasks.tasks);
const user = useSelector((state) => state.users.user); const user = useSelector((state) => state.users.user);
const [executors, setExecutors]=useState([])
const [projects,setProjects]=useState([])
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");
...@@ -34,7 +36,7 @@ export default function UsersTasks() { ...@@ -34,7 +36,7 @@ export default function UsersTasks() {
open: false, open: false,
task: null, task: null,
}); });
const [projects,setProjects]=useState(['1','2'])
useEffect(() => { useEffect(() => {
dispatch(fetchAllTasks()); dispatch(fetchAllTasks());
...@@ -136,7 +138,6 @@ useEffect(() => { ...@@ -136,7 +138,6 @@ useEffect(() => {
} }
return task; return task;
}); });
setRecievedTasks(newTasks);
}; };
...@@ -263,6 +264,7 @@ console.log('tasks', tasks) ...@@ -263,6 +264,7 @@ console.log('tasks', tasks)
{addTaskForm ? ( {addTaskForm ? (
<NewTaskForm <NewTaskForm
projects={uniqueProjects} projects={uniqueProjects}
currentProject={currentProject}
setAddTaskForm={()=>setAddTaskForm(false)} setAddTaskForm={()=>setAddTaskForm(false)}
/> />
) : null} ) : null}
...@@ -293,6 +295,7 @@ console.log('tasks', tasks) ...@@ -293,6 +295,7 @@ console.log('tasks', tasks)
onChange={onChange} onChange={onChange}
onModalOpen={onModalOpen} onModalOpen={onModalOpen}
onProjectChange={onProjectChange} onProjectChange={onProjectChange}
executors={executors}
onExecutorChange={onExecutorChange} onExecutorChange={onExecutorChange}
uniqueProjects={uniqueProjects} uniqueProjects={uniqueProjects}
onAuthorChange={onAuthorChange} onAuthorChange={onAuthorChange}
......
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