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