вывела в ячейке Дата и время выполнения дату , время старта, время завершения и…

вывела в ячейке Дата и время выполнения дату , время старта, время завершения и количество часов на задачу
parent 2bceb759
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, 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.dateTimeDue).diff(moment(task.dateTimeStart)));
const hours = Math.round(duration.asHours());
if (task) { if (task) {
return ( return (
...@@ -22,32 +26,7 @@ const CustomTableCell = ({task, ...@@ -22,32 +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
placeholder={placeholder}
value={value}
name={name}
onChange={(e) => onChange(e, task)}
style={styles}
/>
) : (
<span>{value}</span>
)}
</TableCell>
</>
);
}
if (task && name=="dateTimeStart") {
return (
<>
<TableCell
onClick={(e) => (onModalOpen ? onModalOpen(e, task) : null)}
align="left"
style={styles}
>
{task.isEditMode && onChange && name==!"author" && task.author.id==user.id ? (
<Input <Input
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
...@@ -55,13 +34,16 @@ const CustomTableCell = ({task, ...@@ -55,13 +34,16 @@ const CustomTableCell = ({task,
onChange={(e) => onChange(e, task)} onChange={(e) => onChange(e, task)}
style={styles} style={styles}
/> />
) : ( ) : name!=="dateTimeStart" ? (
<>
<span>{value}</span> <span>{value}</span>
<div>{"valuehjlhlh"}</div> ):(
<span>{value2}</span> <div style={divStyle}>
</> <span>{value}</span>
)} <span>{value2}</span>
<span>часы:+{hours}</span>
</div>
)
}
</TableCell> </TableCell>
</> </>
); );
......
...@@ -45,7 +45,9 @@ export default function EnhancedTable() { ...@@ -45,7 +45,9 @@ export default function EnhancedTable() {
task: null, task: null,
}); });
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)
} }
} }
...@@ -378,31 +379,21 @@ console.log(tasks) ...@@ -378,31 +379,21 @@ console.log(tasks)
name: "dateTimeStart", name: "dateTimeStart",
value: moment(task.dateTimeStart) value: moment(task.dateTimeStart)
.utc() .utc()
.format("DD-MM-YYYY hh:mm A"), .format("DD-MM-YYYY "),
value2:moment(task.dateTimeStart) value2:moment(task.dateTimeStart)
.utc() .utc()
.format("hh:mm A")+ .format("hh:mm A")+"-"+
"-"+
moment(task.dateTimeDue) moment(task.dateTimeDue)
.utc() .utc()
.format("hh:mm A"), .format("hh:mm A"),
user:user user:user
}}> }}>
<span>"время заершения", {moment(task.dateTimeDue) <span>"время завершения"+ {moment(task.dateTimeDue)
.utc() .utc()
.format("hh:mm A")}</span> .format("hh:mm A")}</span>
</CustomTableCell> </CustomTableCell>
{/* <CustomTableCell
{...{
task,
name: "dateTimeStart",
value: moment(task.dateTimeDue)
.utc()
.format("DD-MM-YYYY hh:mm A"),
user:user
}}
/> */}
</> </>
)} )}
......
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