#110 create task added in users Tasks

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