add hours reminder document history

This commit is contained in:
Max S 2024-09-16 18:05:58 +02:00
parent 109a0f98dd
commit e9b67d48c1
3 changed files with 34 additions and 6 deletions

View File

@ -55,7 +55,13 @@ export default function MuiTable(props: IProps) {
className={classes["root"]} className={classes["root"]}
sx={{ maxHeight: "80vh", overflowY: "auto", overflowX: "hidden", backgroundColor: "var(--table-background-default)" }}> sx={{ maxHeight: "80vh", overflowY: "auto", overflowX: "hidden", backgroundColor: "var(--table-background-default)" }}>
<Table aria-label="simple table" sx={{ border: "0" }}> <Table aria-label="simple table" sx={{ border: "0" }}>
<TableHead sx={{ position: "sticky", top: "0", borderBottom: "1px solid var(--table-header-border)" }}> <TableHead
sx={{
position: "sticky",
top: "0",
borderBottom: "1px solid var(--table-header-border)",
backgroundColor: "var(--table-background-default)",
}}>
<TableRow> <TableRow>
{props.header.map((column) => ( {props.header.map((column) => (
<TableCell key={column.key} align={"left"} sx={{ border: 0, padding: "4px 8px" }}> <TableCell key={column.key} align={"left"} sx={{ border: 0, padding: "4px 8px" }}>

View File

@ -145,10 +145,13 @@ function buildRows(reminders: DocumentReminder[] | null): IRowProps[] {
if (!reminders) return []; if (!reminders) return [];
return reminders.map((reminder) => ({ return reminders.map((reminder) => ({
key: reminder.uid ?? "", key: reminder.uid ?? "",
remindedAt: new Date(reminder.reminder_date!).toLocaleDateString(), remindedAt: { sx: { width: 220 }, content: formatDateWithHours(reminder.reminder_date) },
customer: `${reminder.document?.depositor?.contact?.first_name} ${reminder.document?.depositor?.contact?.last_name}`, customer: {
sx: { width: 220 },
content: `${reminder.document?.depositor?.contact?.first_name} ${reminder.document?.depositor?.contact?.last_name}`,
},
document_type: reminder.document?.document_type?.name, document_type: reminder.document?.document_type?.name,
statut: getTag(reminder.document?.document_status as EDocumentStatus), statut: { sx: { width: 220 }, content: getTag(reminder.document?.document_status as EDocumentStatus) },
})); }));
} }
@ -166,3 +169,14 @@ function getTag(status: EDocumentStatus) {
return <Tag label={tradDocumentStatus[status]} color={ETagColor.INFO} variant={ETagVariant.SEMI_BOLD} />; return <Tag label={tradDocumentStatus[status]} color={ETagColor.INFO} variant={ETagVariant.SEMI_BOLD} />;
} }
} }
function formatDateWithHours(date: Date | null) {
if (!date) return "-";
return new Date(date).toLocaleDateString("fr-FR", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
});
}

View File

@ -95,8 +95,7 @@ export default function EmailReminder(props: IProps) {
</Link> </Link>
<div className={classes["info"]}> <div className={classes["info"]}>
<Typography typo={ETypo.TEXT_XS_REGULAR} color={ETypoColor.TEXT_SECONDARY}> <Typography typo={ETypo.TEXT_XS_REGULAR} color={ETypoColor.TEXT_SECONDARY}>
Dernière relance:{" "} Dernière relance: {reminders && remindersLength > 0 ? formatDateWithHours(reminders[0]!.reminder_date) : "-"}
{reminders && remindersLength > 0 ? new Date(reminders[0]!.reminder_date!).toLocaleDateString() : "-"}
</Typography> </Typography>
<Typography typo={ETypo.TEXT_XS_REGULAR} color={ETypoColor.TEXT_SECONDARY}> <Typography typo={ETypo.TEXT_XS_REGULAR} color={ETypoColor.TEXT_SECONDARY}>
Nombre de relance: {remindersLength} Nombre de relance: {remindersLength}
@ -107,3 +106,12 @@ export default function EmailReminder(props: IProps) {
</div> </div>
); );
} }
function formatDateWithHours(date: Date | null) {
if (!date) return "-";
return new Date(date).toLocaleDateString("fr-FR", {
year: "numeric",
month: "2-digit",
day: "2-digit",
});
}