add task tooltip informations
This commit is contained in:
@@ -4,15 +4,17 @@ import {
|
|||||||
IconButton,
|
IconButton,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
ListItemText
|
ListItemText,
|
||||||
|
Tooltip,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { formatDate } from "../../../../utils/formatDate";
|
||||||
|
|
||||||
export type Task = {
|
export type Task = {
|
||||||
id: number;
|
id: number;
|
||||||
description: string;
|
description: string;
|
||||||
createdAt: Date;
|
createdAt: string;
|
||||||
finishedAt?: Date;
|
finishedAt?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TasksListItemProps = {
|
export type TasksListItemProps = {
|
||||||
@@ -42,19 +44,38 @@ export const TasksListItem = ({
|
|||||||
const blockInteration = finished || isLoading;
|
const blockInteration = finished || isLoading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<Tooltip
|
||||||
secondaryAction={
|
title={`
|
||||||
finished ? null : (
|
${
|
||||||
<IconButton onClick={handleDelete} disabled={blockInteration} edge="end" aria-label="delete">
|
task.finishedAt ? `Finished at: ${formatDate(task.finishedAt)} |` : ""
|
||||||
<DeleteIcon />
|
}
|
||||||
</IconButton>
|
${`Created at: ${formatDate(task.createdAt)}`}
|
||||||
)
|
`}
|
||||||
}
|
placement="top-start"
|
||||||
>
|
>
|
||||||
<ListItemAvatar>
|
<ListItem
|
||||||
<Checkbox onChange={handleCheck} disabled={blockInteration} checked={blockInteration} />
|
secondaryAction={
|
||||||
</ListItemAvatar>
|
finished ? null : (
|
||||||
<ListItemText primary="Single-line item" />
|
<IconButton
|
||||||
</ListItem>
|
onClick={handleDelete}
|
||||||
|
disabled={blockInteration}
|
||||||
|
edge="end"
|
||||||
|
aria-label="delete"
|
||||||
|
>
|
||||||
|
<DeleteIcon />
|
||||||
|
</IconButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ListItemAvatar>
|
||||||
|
<Checkbox
|
||||||
|
onChange={handleCheck}
|
||||||
|
disabled={blockInteration}
|
||||||
|
checked={blockInteration}
|
||||||
|
/>
|
||||||
|
</ListItemAvatar>
|
||||||
|
<ListItemText primary={task.description} />
|
||||||
|
</ListItem>
|
||||||
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
7
client/src/utils/formatDate.ts
Normal file
7
client/src/utils/formatDate.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const formatDate = (date: string) => {
|
||||||
|
return (
|
||||||
|
new Date(date).toLocaleDateString() +
|
||||||
|
" " +
|
||||||
|
new Date(date).toLocaleTimeString()
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user