-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add status column to reporting operation table
- Loading branch information
1 parent
23dec24
commit 155dcc8
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
bciers/apps/reporting/src/app/components/operations/cells/ReportingOperationStatusCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use client"; | ||
|
||
import { ReportOperationStatus } from "@bciers/utils/src/enums"; | ||
import { Chip, ChipOwnProps } from "@mui/material"; | ||
import { GridRenderCellParams } from "@mui/x-data-grid"; | ||
|
||
export default function ReportingOperationStatusCell( | ||
params: GridRenderCellParams, | ||
) { | ||
const colorMap = new Map<string, ChipOwnProps["color"]>([ | ||
[ReportOperationStatus.NOT_STARTED, "primary"], | ||
[ReportOperationStatus.DRAFT, "primary"], | ||
[ReportOperationStatus.SUBMITTED, "success"], | ||
]); | ||
const status = params.value || ReportOperationStatus.NOT_STARTED; | ||
const statusColor = colorMap.get(status) || "primary"; | ||
const isMultiLineStatus = status === ReportOperationStatus.NOT_STARTED; | ||
|
||
// Adjust the font size for multi-line statuses so it will fit in the chip | ||
const fontSize = isMultiLineStatus ? "14px" : "16px"; | ||
return ( | ||
<Chip | ||
label={ | ||
// whiteSpace: "normal" is needed to wrap the text in the chip for multi-line statuses like "Not started" | ||
<div style={{ whiteSpace: "normal", color: statusColor, fontSize }}> | ||
{status} | ||
</div> | ||
} | ||
variant="outlined" | ||
color={statusColor} | ||
sx={{ | ||
width: 100, | ||
height: 40, | ||
borderRadius: "20px", | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters