✨ review design
This commit is contained in:
parent
7d8653ae98
commit
749b05dc84
@ -8,8 +8,9 @@ import TableRow from "@mui/material/TableRow";
|
||||
|
||||
import Typography, { ETypo, ETypoColor } from "../../Typography";
|
||||
import classes from "./classes.module.scss";
|
||||
import { SxProps, Theme } from "@mui/material";
|
||||
|
||||
export type IRowProps = { key: string } & Record<string, React.ReactNode>;
|
||||
export type IRowProps = { key: string } & Record<string, React.ReactNode | { sx: SxProps<Theme>; content: React.ReactNode }>;
|
||||
|
||||
type IRow = {
|
||||
key?: string;
|
||||
@ -29,7 +30,7 @@ export type IHead = {
|
||||
|
||||
type CellContent = {
|
||||
key: string;
|
||||
value: React.ReactNode;
|
||||
value: React.ReactNode | { sx: SxProps<Theme>; content: React.ReactNode };
|
||||
};
|
||||
|
||||
export default function MuiTable(props: IProps) {
|
||||
@ -82,12 +83,14 @@ export default function MuiTable(props: IProps) {
|
||||
className={classes["cell"]}
|
||||
key={cell.key}
|
||||
align="left"
|
||||
sx={{ border: 0, padding: "4px 8px", height: "53px" }}>
|
||||
sx={{ ...getCellValueStyle(cell.value), border: 0, padding: "4px 8px", height: "53px" }}>
|
||||
<Typography
|
||||
className={classes["content"]}
|
||||
typo={ETypo.TEXT_MD_REGULAR}
|
||||
color={ETypoColor.COLOR_NEUTRAL_900}>
|
||||
{cell.value}
|
||||
{cell.value && typeof cell.value === "object" && "content" in cell.value
|
||||
? cell.value.content
|
||||
: cell.value}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
))}
|
||||
@ -99,4 +102,11 @@ export default function MuiTable(props: IProps) {
|
||||
</TableContainer>
|
||||
</InfiniteScroll>
|
||||
);
|
||||
|
||||
function getCellValueStyle(value: React.ReactNode | { sx: SxProps<Theme>; content: React.ReactNode }) {
|
||||
if (typeof value === "object" && value !== null && "sx" in value) {
|
||||
return value.sx;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
white-space: nowrap;
|
||||
|
||||
&.info {
|
||||
background-color: var(--tag-info-background);
|
||||
}
|
||||
|
@ -2,12 +2,11 @@
|
||||
|
||||
.root {
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
padding: var(--spacing-md, 16px);
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md, 16px);
|
||||
background: var(--primary-weak-higlight, #e5eefa);
|
||||
min-width: 300px;
|
||||
width: 300px;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
|
@ -16,5 +16,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm, 8px);
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
@ -131,16 +131,29 @@ export default function DocumentTables(props: IProps) {
|
||||
if (document.document_status !== EDocumentStatus.ASKED) return null;
|
||||
return {
|
||||
key: document.uid,
|
||||
document_type: document.document_type?.name ?? "_",
|
||||
document_status: (
|
||||
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||
document_status: {
|
||||
sx: { width: 107 },
|
||||
content: (
|
||||
<Tag
|
||||
color={ETagColor.INFO}
|
||||
variant={ETagVariant.SEMI_BOLD}
|
||||
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||
/>
|
||||
),
|
||||
date: document.created_at ? new Date(document.created_at).toLocaleDateString() : "_",
|
||||
actions: <IconButton icon={<TrashIcon onClick={() => openDeleteAskedDocumentModal(document.uid)} />} />,
|
||||
},
|
||||
date: {
|
||||
sx: { width: 107 },
|
||||
content: document.created_at ? new Date(document.created_at).toLocaleDateString() : "_",
|
||||
},
|
||||
actions: {
|
||||
sx: { width: 76 },
|
||||
content: (
|
||||
<div className={classes["actions"]}>
|
||||
<IconButton icon={<TrashIcon onClick={() => openDeleteAskedDocumentModal(document.uid)} />} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
};
|
||||
})
|
||||
.filter((document) => document !== null) as IRowProps[],
|
||||
@ -154,16 +167,25 @@ export default function DocumentTables(props: IProps) {
|
||||
if (document.document_status !== EDocumentStatus.DEPOSITED) return null;
|
||||
return {
|
||||
key: document.uid,
|
||||
document_type: document.document_type?.name ?? "_",
|
||||
document_status: (
|
||||
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||
document_status: {
|
||||
sx: { width: 107 },
|
||||
content: (
|
||||
<Tag
|
||||
color={ETagColor.WARNING}
|
||||
variant={ETagVariant.SEMI_BOLD}
|
||||
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||
/>
|
||||
),
|
||||
date: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
actions: (
|
||||
},
|
||||
date: {
|
||||
sx: { width: 107 },
|
||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
},
|
||||
actions: {
|
||||
sx: { width: 76 },
|
||||
content: (
|
||||
<div className={classes["actions"]}>
|
||||
<Link
|
||||
href={Module.getInstance()
|
||||
.get()
|
||||
@ -171,7 +193,9 @@ export default function DocumentTables(props: IProps) {
|
||||
.replace("[documentUid]", document.uid ?? "")}>
|
||||
<IconButton icon={<EyeIcon />} />
|
||||
</Link>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
};
|
||||
})
|
||||
.filter((document) => document !== null) as IRowProps[],
|
||||
@ -185,16 +209,24 @@ export default function DocumentTables(props: IProps) {
|
||||
if (document.document_status !== EDocumentStatus.VALIDATED) return null;
|
||||
return {
|
||||
key: document.uid,
|
||||
document_type: document.document_type?.name ?? "_",
|
||||
document_status: (
|
||||
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||
document_status: {
|
||||
sx: { width: 107 },
|
||||
content: (
|
||||
<Tag
|
||||
color={ETagColor.SUCCESS}
|
||||
variant={ETagVariant.SEMI_BOLD}
|
||||
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||
/>
|
||||
),
|
||||
date: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
actions: (
|
||||
},
|
||||
date: {
|
||||
sx: { width: 107 },
|
||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
},
|
||||
actions: {
|
||||
sx: { width: 76 },
|
||||
content: (
|
||||
<div className={classes["actions"]}>
|
||||
<Link
|
||||
href={Module.getInstance()
|
||||
@ -206,6 +238,7 @@ export default function DocumentTables(props: IProps) {
|
||||
<IconButton onClick={() => onDownload(document)} icon={<ArrowDownTrayIcon />} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
};
|
||||
})
|
||||
.filter((document) => document !== null) as IRowProps[],
|
||||
@ -219,15 +252,21 @@ export default function DocumentTables(props: IProps) {
|
||||
if (document.document_status !== EDocumentStatus.REFUSED) return null;
|
||||
return {
|
||||
key: document.uid,
|
||||
document_type: document.document_type?.name ?? "_",
|
||||
document_status: (
|
||||
document_type: { sx: { width: 400 }, content: document.document_type?.name ?? "_" },
|
||||
document_status: {
|
||||
sx: { width: 107 },
|
||||
content: (
|
||||
<Tag
|
||||
color={ETagColor.ERROR}
|
||||
variant={ETagVariant.SEMI_BOLD}
|
||||
label={tradDocumentStatus[document.document_status].toUpperCase()}
|
||||
/>
|
||||
),
|
||||
date: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
},
|
||||
date: {
|
||||
sx: { width: 107 },
|
||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
},
|
||||
actions: "",
|
||||
};
|
||||
})
|
||||
@ -241,15 +280,27 @@ export default function DocumentTables(props: IProps) {
|
||||
.map((document) => {
|
||||
return {
|
||||
key: document.uid,
|
||||
document_type: document.files?.[0]?.file_name?.split(".")?.[0] ?? "_",
|
||||
document_status: <Tag color={ETagColor.NEUTRAL} variant={ETagVariant.SEMI_BOLD} label={"ENVOYÉ"} />,
|
||||
date: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
actions: (
|
||||
document_type: {
|
||||
sx: { width: 400 },
|
||||
content: formatName(document.files?.[0]?.file_name?.split(".")?.[0] ?? "") || "_",
|
||||
},
|
||||
document_status: {
|
||||
sx: { width: 107 },
|
||||
content: <Tag color={ETagColor.NEUTRAL} variant={ETagVariant.SEMI_BOLD} label={"ENVOYÉ"} />,
|
||||
},
|
||||
date: {
|
||||
sx: { width: 107 },
|
||||
content: document.updated_at ? new Date(document.updated_at).toLocaleDateString() : "_",
|
||||
},
|
||||
actions: {
|
||||
sx: { width: 76 },
|
||||
content: (
|
||||
<div className={classes["actions"]}>
|
||||
<IconButton onClick={() => onDownloadFileNotary(document)} icon={<ArrowDownTrayIcon />} />
|
||||
<IconButton icon={<TrashIcon onClick={() => openDeleteSentDocumentModal(document.uid)} />} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
};
|
||||
})
|
||||
.filter((document) => document !== null) as IRowProps[],
|
||||
@ -333,3 +384,7 @@ function getHeader(dateColumnTitle: string, isMobile: boolean): IHead[] {
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function formatName(text: string): string {
|
||||
return text.replace(/[^a-zA-Z0-9 ]/g, "");
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ $mobile-breakpoint: 664px;
|
||||
.tabs {
|
||||
width: calc(100% - 210px);
|
||||
}
|
||||
border-bottom: 1px solid var(--color-neutral-500);
|
||||
}
|
||||
|
||||
.content {
|
||||
|
Loading…
x
Reference in New Issue
Block a user