#105 added newTaskFrom

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