#110 create task added in users Tasks

parent 2c813db9
......@@ -112,6 +112,7 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=>{
const {user,title,description,project,executor,dateTimeStart,dateTimeDue, dateTimeDeadLine,priority} = req.body;
const newTask = new Task();
console.log('project ', project, )
newTask.title = title;
newTask.description = description;
if (project) {
......@@ -165,11 +166,13 @@ router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=>
newTask.executor= executor;
newTask.priority = priority;
await newTask.save();
const newDateTimeTask = new DateTimeTask();
if(dateTimeDue && dateTimeStart){
const newDateTimeTask = new DateTimeTask();
newDateTimeTask.dateTimeStart = dateTimeStart
newDateTimeTask.dateTimeDue = dateTimeDue
newDateTimeTask.task = newTask
await newDateTimeTask.save()
}
return res.send({newTask});
})
......
......@@ -127,14 +127,7 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
/>
</TableCell>
<CustomTableCell
{...{
task,
name: "createdAt",
value: moment(task.createdAt).format("DD-MM-YYYY hh:mm A"),
width: "15%",
}}
/>
<CustomTableCell
{...{
......@@ -161,14 +154,6 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
/>
</TableCell>
{/* <TableCell>
<MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
/>
</TableCell> */}
<TableCell style={{ width: "20%", paddingLeft: "0" }}>
<MaterialUIPickers
task={task}
......@@ -213,12 +198,6 @@ export const header = [
disablePadding: true,
label: "Приоритет",
},
{
id: "createdAt",
numeric: true,
disablePadding: false,
label: "Дата создания",
},
{
id: "title",
numeric: false,
......
......@@ -11,7 +11,6 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
console.log('select name ', name)
console.log('select task ', task)
console.log('select items ', items)
// console.log('select value ', value)
return (
<Box sx={{ minWidth: 60, m: 0}}>
<FormControl fullWidth>
......@@ -28,7 +27,7 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
<MenuItem key={index} value={item.value}>
{item.title}
</MenuItem>
)):<></>}
)):null}
</Select>
</FormControl>
</Box>
......
......@@ -40,7 +40,7 @@ export default function NewTaskForm({
dateTimeDeadLine: null,
dateTimeTasks: [],
dateTimeDue: null,
project: [],
project: null,
accomplish: "opened",
priority: "B",
author: { id: user.id },
......@@ -48,8 +48,8 @@ export default function NewTaskForm({
executor:null,
isEditMode: true,
});
console.log('NewTaskForm currentProject ', currentProject, 'projects ', projects)
const [modal, setModal] = useState(false);
console.log('NewTaskForm currentProject ', currentProject )
const onModalOpen = (event, task) => {
event.stopPropagation();
......@@ -79,9 +79,12 @@ export default function NewTaskForm({
const onExecutorChange = (e, task) => {
const {value, name} = e.target.value;
const executorMember = currentProject.find((member) => member.user.id === value);
let executorMember = null
const newTask = { ...task };
newTask[{name}] = executorMember.user;
if( name==='executor' && value!==null) {
executorMember = currentProject.find((member) => member.user.id === value);
newTask.executor = executorMember?.user;
}
setTask(newTask);
};
......@@ -142,15 +145,9 @@ export default function NewTaskForm({
/>
</TableCell>
{/* <CustomTableCell
{...{
task,
name: "createdAt",
value: moment(task.createdAt).format("DD-MM-YYYY hh:mm A"),
}}
/> */}
<CustomTableCell
colSpan={2}
colSpan={3}
{...{
task,
name: "title",
......@@ -175,10 +172,10 @@ export default function NewTaskForm({
</TableCell>
<TableCell>
<BasicSelect
items={currentProject?.members.map((member) => ({
items={currentProject?currentProject?.members.map((member) => ({
value: member?.user?.id,
title: member?.user?.displayName,
}))}
})):null}
task={task}
onChange={onExecutorChange}
name="executor"
......@@ -187,13 +184,7 @@ export default function NewTaskForm({
/>
</TableCell>
{/* <TableCell>
<MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
/>
</TableCell> */}
<TableCell>
<MaterialUIPickers
......@@ -245,7 +236,7 @@ export const header = [
numeric: false,
disablePadding: false,
label: "Заголовок",
colSpan:2
colSpan:3
},
{
id: "projectName",
......
......@@ -83,20 +83,6 @@ export default function UsersTasks() {
setRecievedTasks(newTasks);
};
const onAuthorChange = (e, task) => {
const value = e.target.value;
const { id } = task;
const newTasks = recievedTasks.map((task) => {
if (task.id === id) {
const updated = { ...task };
updated.author.displayName = value;
updated.authorDisplayName = value;
return updated;
}
return task;
});
setRecievedTasks(newTasks);
};
const onDateChange = (id, value, property) => {
const newTasks = recievedTasks.map((task) => {
......
......@@ -268,7 +268,7 @@ export const deleteDateTimeTask = (dateTimeTaskId) => {
/** add new task in UserTaslks Table */
/** add new task in UserTasks Table */
const addTaskToUserTasksTableRequest = () => {
return {type: ADD_NEW_TASK_REQUEST}
};
......
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