Commit 3d1e05fc authored by Нелли Ибрагимова's avatar Нелли Ибрагимова

Merge branch 'task-64-reconstruction-of-table-My-task' into 'development'

Task 64 reconstruction of table my task

See merge request !48
parents 461c5497 814f9521
import * as React from "react"; import * as React from "react";
import TableCell from "@mui/material/TableCell"; import TableCell from "@mui/material/TableCell";
import Input from "@mui/material/Input"; import Input from "@mui/material/Input";
import moment from "moment";
const CustomTableCell = ({task, const CustomTableCell = ({task,
name, name,
value, value,
value2,
value3,
onChange, onChange,
onModalOpen, onModalOpen,
placeholder, placeholder,
user user
}) => { }) => {
const styles = { width: "auto", height: "10px"}; const styles = { width: "auto", height: "10px"};
const divStyle={display:"flex",justifyContent:"space-between", flexDirection:"column",fontSize:"12px"}
const duration = moment.duration(moment(task.dateTimeTasks[0]?.dateTimeDue).diff(moment(task.dateTimeTasks[0]?.dateTimeStart)));
const hours = Math.round(duration.asHours());
if (task) { if (task) {
return ( return (
...@@ -21,7 +26,7 @@ const CustomTableCell = ({task, ...@@ -21,7 +26,7 @@ const CustomTableCell = ({task,
align="left" align="left"
style={styles} style={styles}
> >
{task.isEditMode && onChange && name==!"author" && task.author.id==user.id ? ( {task.isEditMode && onChange && name!=="author" && task.author.id===user.id ? (
<Input <Input
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
...@@ -29,9 +34,16 @@ const CustomTableCell = ({task, ...@@ -29,9 +34,16 @@ const CustomTableCell = ({task,
onChange={(e) => onChange(e, task)} onChange={(e) => onChange(e, task)}
style={styles} style={styles}
/> />
) : ( ) : name!=="dateTimeStart" ? (
<span>{value}</span>
):(
<div style={divStyle}>
<span>{value}</span> <span>{value}</span>
)} <span>{value2}</span>
<span>часы:+{hours}</span>
</div>
)
}
</TableCell> </TableCell>
</> </>
); );
......
...@@ -25,7 +25,7 @@ import MaterialUIPickers from "../../components/MyTasksCompoments/DateTimePicker ...@@ -25,7 +25,7 @@ import MaterialUIPickers from "../../components/MyTasksCompoments/DateTimePicker
import BasicSelect from "../../components/UI/Select/Select"; import BasicSelect from "../../components/UI/Select/Select";
import { fetchAllTasks, deleteTask,editTask} from "../../store/actions/tasksActions"; import { fetchAllTasks, deleteTask,editTask} from "../../store/actions/tasksActions";
import NewTaskForm from "../../components/MyTasksCompoments/NewTaskForm"; import NewTaskForm from "../../components/MyTasksCompoments/NewTaskForm";
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
export default function EnhancedTable() { export default function EnhancedTable() {
...@@ -46,6 +46,8 @@ export default function EnhancedTable() { ...@@ -46,6 +46,8 @@ export default function EnhancedTable() {
}); });
const [projects,setProjects]=useState(['1','2']) const [projects,setProjects]=useState(['1','2'])
useEffect(() => { useEffect(() => {
dispatch(fetchAllTasks()); dispatch(fetchAllTasks());
filterProjectsNamesFromTasks() filterProjectsNamesFromTasks()
...@@ -207,7 +209,6 @@ useEffect(() => { ...@@ -207,7 +209,6 @@ useEffect(() => {
} }
let uniqueTitlesProjects = [...new Set(rawSetProjectNames)]; let uniqueTitlesProjects = [...new Set(rawSetProjectNames)];
setProjects(uniqueTitlesProjects) setProjects(uniqueTitlesProjects)
} }
} }
...@@ -221,7 +222,7 @@ useEffect(() => { ...@@ -221,7 +222,7 @@ useEffect(() => {
return results; return results;
}, []); }, []);
console.log(tasks)
if ( if (
tasks && tasks &&
tasks?.length > 0 && tasks?.length > 0 &&
...@@ -353,17 +354,58 @@ useEffect(() => { ...@@ -353,17 +354,58 @@ useEffect(() => {
user:user user:user
}} }}
/> />
{task.isEditMode && task.author.id===user.id ? (
<TableCell>
{/* <MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
user={user}
/> */}
<TableCell> <TableCell>
<Tooltip title="Перейти в календарь">
<IconButton
onClick={(id) => { deleteHandle(task.id);}}
>
<CalendarMonthIcon />
</IconButton>
</Tooltip>
</TableCell>
</TableCell>
) : (<>
<CustomTableCell
{...{
task,
name: "dateTimeStart",
value: moment(task.dateTimeTasks[0]?.dateTimeStart)
.utc()
.format("DD-MM-YYYY "),
value2:moment(task.dateTimeTasks[0]?.dateTimeStart)
.utc()
.format("hh:mm A")+"-"+
moment(task.dateTimeTasks[0]?.dateTimeDue)
.utc()
.format("hh:mm A"),
user:user
}}>
{/* <span>"время завершения"+ {moment(task.dateTimeDue)
.utc()
.format("hh:mm A")}</span> */}
</CustomTableCell>
</>
)}
{/* <TableCell>
<MaterialUIPickers <MaterialUIPickers
task={task} task={task}
name="dateTimeStart" name="dateTimeStart"
onChange={onDateChange} onChange={onDateChange}
user={user} user={user}
/> />
</TableCell> */}
</TableCell> {task.isEditMode && task.author.id===user.id ? (
<TableCell> <TableCell>
<MaterialUIPickers <MaterialUIPickers
task={task} task={task}
...@@ -372,7 +414,19 @@ useEffect(() => { ...@@ -372,7 +414,19 @@ useEffect(() => {
user={user} user={user}
/> />
</TableCell> </TableCell>
) : (
<CustomTableCell
{...{
task,
name: "dateTimeDeadLine",
value: moment(task.dateTimeDeadLine
)
.utc()
.format("DD-MM-YYYY hh:mm A"),
user:user
}}
/>
)}
{task.isEditMode ? ( {task.isEditMode ? (
<TableCell> <TableCell>
<BasicSelect <BasicSelect
......
...@@ -49,13 +49,13 @@ const headCells = [ ...@@ -49,13 +49,13 @@ const headCells = [
id: "dateTimeStart", id: "dateTimeStart",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: "Дата начала", label: "Дата и время выполнения",
}, },
{ {
id: "dateTimeDue", id: "dateTimeDue",
numeric: true, numeric: true,
disablePadding: false, disablePadding: false,
label: ата завершения", label: едлайн",
}, },
{ {
id: "accomplish", id: "accomplish",
......
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