Merge branch 'task-89-fix/DE_and_cosmetic_fix' into 'development'

Task 89 fix/de and cosmetic fix

See merge request !61
parents d02f5e73 7aab4e6b
...@@ -63,15 +63,16 @@ router.put("/change-copy", authAuthorOrExecutorOfTask, async(req:Request, res: R ...@@ -63,15 +63,16 @@ router.put("/change-copy", authAuthorOrExecutorOfTask, async(req:Request, res: R
}) })
/**delete copyTask by dateTimeTaskId */ /**delete copyTask by dateTimeTaskId */
router.delete('/:id', authAuthorOrExecutorOfTask, async(req:Request, res:Response):Promise<Response>=>{ router.delete('/:dateTimeTaskId', async(req:Request, res:Response):Promise<Response>=>{
const {id} = req.params // router.delete('/:dateTimeTaskId', authAuthorOrExecutorOfTask, async(req:Request, res:Response):Promise<Response>=>{
const {dateTimeTaskId} = req.params
await myDataSource await myDataSource
.createQueryBuilder() .createQueryBuilder()
.delete() .delete()
.from(DateTimeTask) .from(DateTimeTask)
.where("id = :id", { id }) .where("id = :dateTimeTaskId", { dateTimeTaskId })
.execute() .execute()
return res.send({message:"delete succesfully"}) return res.send({message:"copyTask delete succesfully"})
} }
) )
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
} from "@mui/material"; } from "@mui/material";
import { Done, Edit } from "@mui/icons-material"; import { Done, Edit } from "@mui/icons-material";
import RemoveIcon from '@mui/icons-material/Remove';
import DeleteIcon from "@mui/icons-material/Delete"; import DeleteIcon from "@mui/icons-material/Delete";
import moment from "moment"; import moment from "moment";
import CustomTableCell from "../CustomTableCell"; import CustomTableCell from "../CustomTableCell";
...@@ -22,13 +23,15 @@ import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; ...@@ -22,13 +23,15 @@ import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
const weekDays = ["Вс","Пн","Вт","Ср","Чт","Пт","Сб" ];
const TableRowTask= ({ const TableRowTask= ({
user, user,
task, task,
deleteHandle, deleteHandle,
handleEditTask, handleEditTask,
deleteDateTimeTask,
handleEditDateTimeTask,
onChange, onChange,
onModalOpen, onModalOpen,
onProjectChange, onProjectChange,
...@@ -40,16 +43,21 @@ const TableRowTask= ({ ...@@ -40,16 +43,21 @@ const TableRowTask= ({
})=>{ })=>{
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const dateTimeTransform =(dateIso)=>{
const event = new Date(dateIso); const roudHourUp =(dateIso)=>{
return event.toLocaleString('ru-KZ', { timeZone: 'UTC' }) let m = moment(dateIso);
} let roundUp = m.minute() || m.second() || m.millisecond() ? m.add(1, 'hour').startOf('hour') : m.startOf('hour');
const dateTransform =(dateIso) => { return roundUp
let date = new Date(dateIso);
return date.getDate()+'-' + (date.getMonth()+1) + '-'+ date.getFullYear().toString().slice(-2);
} }
const timeTransform = (dateIso)=>{ const timeTransform = (dateIso)=>{
return moment.utc(dateIso).format("HH:"+"00"); const exp = roudHourUp(moment.utc(dateIso)).format("HH:"+"00")
return exp;
}
const getDayOfWeek = (dateIso) => {
const date = moment.utc(dateIso);
return weekDays[date.day()];
} }
return ( return (
...@@ -298,23 +306,30 @@ const TableRowTask= ({ ...@@ -298,23 +306,30 @@ const TableRowTask= ({
<Typography variant="h6" gutterBottom component="div"> <Typography variant="h6" gutterBottom component="div">
Расписание Расписание
</Typography> </Typography>
<Table size="small" aria-label="purchases"> <Table size="small" aria-label="purchases" sx={{
backgroundColor: "#ebebeb"}}>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell colSpan={10} >Дата создания события</TableCell> <TableCell colSpan={10} >Дата создания</TableCell>
<TableCell align="right">дд-мм-гг</TableCell> <TableCell align="right">День недели</TableCell>
<TableCell align="right">Начало</TableCell> <TableCell align="right">Начало</TableCell>
<TableCell align="center" colSpan={1}>Окончание</TableCell> <TableCell align="center" colSpan={1}>Окончание</TableCell>
<TableCell align="center" ></TableCell>
<TableCell align="center" ></TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{task.dateTimeTasks.map((dateTimeTask, index) => ( {task.dateTimeTasks.map((dateTimeTask, index) => (
<TableRow key={index}> <TableRow key={index}>
<TableCell component="th" scope="row" colSpan={10}> <TableCell component="th" scope="row" colSpan={10}>
{dateTimeTransform(dateTimeTask.createdAt)} {moment(task.createdAt)
.utc()
.format("DD/MM")}
</TableCell> </TableCell>
<TableCell align="right"> <TableCell align="right">
{dateTransform(dateTimeTask.dateTimeStart)} {getDayOfWeek(dateTimeTask.dateTimeStart)}, {moment(dateTimeTask.dateTimeStart)
.utc()
.format("DD/MM")}
</TableCell> </TableCell>
<TableCell align="right"> <TableCell align="right">
{timeTransform(dateTimeTask.dateTimeStart)} {timeTransform(dateTimeTask.dateTimeStart)}
...@@ -322,6 +337,46 @@ const TableRowTask= ({ ...@@ -322,6 +337,46 @@ const TableRowTask= ({
<TableCell align="center" colSpan={1}> <TableCell align="center" colSpan={1}>
{timeTransform(dateTimeTask.dateTimeDue)} {timeTransform(dateTimeTask.dateTimeDue)}
</TableCell> </TableCell>
{/* Edit option datetimeTask */}
<TableCell style={{width:'0%'}}>
<Tooltip title="Редактировать Копию">
{task.isEditMode ? (
<IconButton
aria-label="done"
onClick={() => {
onToggleEditModeDone(dateTimeTask.id);
handleEditDateTimeTask(dateTimeTask);
}}
>
<Done />
</IconButton>
) : (
<IconButton
aria-label="edit"
onClick={() => onToggleEditMode(dateTimeTask.id)}
>
<Edit />
</IconButton>
)}
</Tooltip>
</TableCell >
{/* delete option datetimeTask */}
{task.author.id===user.id ?
(<TableCell style={{width:'0%'}}>
<Tooltip title="Удалить Копию">
<IconButton
onClick={(id) => {
deleteDateTimeTask(dateTimeTask.id);
}}
>
<RemoveIcon />
</IconButton>
</Tooltip>
</TableCell>):null}
</TableRow> </TableRow>
))} ))}
</TableBody> </TableBody>
......
...@@ -162,6 +162,16 @@ useEffect(() => { ...@@ -162,6 +162,16 @@ useEffect(() => {
dispatch(deleteTask(id)); dispatch(deleteTask(id));
}; };
const deleteDateTimeTask=(dateTImeTaskId)=>{
console.log('delete by dateTImeTaskId')
// dispatch(deleteDateTimeTask(dateTImeTaskId))
}
const handleEditDateTimeTask=(dateTimeTask)=>{
console.log('edit by dateTImeTask')
// dispatch(handleEditDateTimeTask(dateTimeTask))
}
const onModalOpen = (event, task) => { const onModalOpen = (event, task) => {
event.stopPropagation(); event.stopPropagation();
...@@ -261,6 +271,8 @@ console.log('tasks', tasks) ...@@ -261,6 +271,8 @@ console.log('tasks', tasks)
task={task} task={task}
deleteHandle={deleteHandle} deleteHandle={deleteHandle}
handleEditTask ={handleEditTask} handleEditTask ={handleEditTask}
handleEditDateTimeTask={handleEditDateTimeTask}
deleteDateTimeTask={deleteDateTimeTask}
onChange={onChange} onChange={onChange}
onModalOpen={onModalOpen} onModalOpen={onModalOpen}
onProjectChange={onProjectChange} onProjectChange={onProjectChange}
......
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