generated from bcgov/EPIC.scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from nitheesh-aot/requirements
Requirements
- Loading branch information
Showing
6 changed files
with
216 additions
and
22 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
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
177 changes: 177 additions & 0 deletions
177
compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.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,177 @@ | ||
import { FC, memo, useState } from "react"; | ||
import { | ||
Box, | ||
Typography, | ||
Button, | ||
Stack, | ||
Accordion, | ||
AccordionSummary, | ||
AccordionDetails, | ||
IconButton, | ||
Tooltip, | ||
} from "@mui/material"; | ||
import { | ||
AddRounded, | ||
DeleteOutlineRounded, | ||
EditOutlined, | ||
ExpandLessRounded, | ||
ExpandMoreRounded, | ||
PostAddOutlined, | ||
} from "@mui/icons-material"; | ||
import { RequirementSourceFormData } from "@/models/InspectionRequirement"; | ||
import { BCDesignTokens } from "epic.theme"; | ||
import ParagraphWithReadMore from "@/components/Shared/ParagraphWithReadMore"; | ||
import { RequirementSourceEnum } from "@/utils/constants"; | ||
|
||
type RequirementSourceCardProps = { | ||
data: RequirementSourceFormData; | ||
index: number; | ||
}; | ||
|
||
const RequirementSourceCard: FC<RequirementSourceCardProps> = memo( | ||
({ data, index }) => { | ||
const [isExpanded, setIsExpanded] = useState(index === 0); | ||
|
||
const isCondition = [ | ||
RequirementSourceEnum.SCHEDULE_B, | ||
RequirementSourceEnum.EAC, | ||
RequirementSourceEnum.EACA, | ||
].includes(data.requirementSource?.id as RequirementSourceEnum); | ||
|
||
return ( | ||
<Accordion | ||
expanded={isExpanded} | ||
onChange={(_, expanded) => { | ||
setIsExpanded(expanded); | ||
}} | ||
sx={{ | ||
marginTop: "1rem", | ||
border: `1px solid ${BCDesignTokens.surfaceColorBorderDefault}`, | ||
borderRadius: BCDesignTokens.layoutBorderRadiusMedium, | ||
"&.Mui-expanded:first-of-type": { | ||
marginTop: "1rem", | ||
}, | ||
}} | ||
> | ||
<AccordionSummary | ||
aria-controls={`panel${index}-content`} | ||
id={`requirement-source-panel${index}-header`} | ||
sx={{ | ||
"&.Mui-expanded": { | ||
minHeight: "48px", | ||
padding: "0.875rem 1rem", | ||
borderBottom: `1px solid ${BCDesignTokens.surfaceColorBorderDefault}`, | ||
backgroundColor: BCDesignTokens.surfaceColorBackgroundLightGray, | ||
"& .MuiAccordionSummary-content": { | ||
margin: "0", | ||
}, | ||
}, | ||
"& .MuiAccordionSummary-content": { | ||
display: "flex", | ||
justifyContent: "space-between", | ||
gap: "1rem", | ||
}, | ||
}} | ||
> | ||
<Box display={"flex"} alignItems={"flex-start"} gap={0.5}> | ||
{isExpanded ? <ExpandLessRounded /> : <ExpandMoreRounded />} | ||
<Typography variant="body2" fontWeight={700}> | ||
{data.requirementSource?.name} | ||
{data.requirementSource?.id === RequirementSourceEnum.EACA && | ||
` #${data.sourceAmendmentNumber}`} | ||
</Typography> | ||
</Box> | ||
<Button | ||
variant="text" | ||
color="secondary" | ||
size="small" | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
}} | ||
startIcon={<AddRounded />} | ||
sx={{ | ||
backgroundColor: "transparent", | ||
paddingY: 0, | ||
height: "auto", | ||
"& .MuiButton-startIcon": { | ||
mr: 0, | ||
}, | ||
}} | ||
> | ||
{isCondition ? "Condition" : "Section"} | ||
</Button> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Stack> | ||
<Box display={"flex"} justifyContent={"flex-end"} gap={".25rem"}> | ||
<Tooltip title="Add Related Document" arrow> | ||
<IconButton size="small" color="secondary"> | ||
<PostAddOutlined /> | ||
</IconButton> | ||
</Tooltip> | ||
<Tooltip title="Edit" arrow> | ||
<IconButton size="small" color="secondary"> | ||
<EditOutlined /> | ||
</IconButton> | ||
</Tooltip> | ||
<Tooltip title="Delete" arrow> | ||
<IconButton size="small" color="secondary"> | ||
<DeleteOutlineRounded /> | ||
</IconButton> | ||
</Tooltip> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
gap: "1rem", | ||
marginBottom: ".5rem", | ||
}} | ||
> | ||
<Box> | ||
<Typography | ||
variant="subtitle2" | ||
color={BCDesignTokens.typographyColorPlaceholder} | ||
> | ||
{isCondition ? "Condition #:" : "Section #:"} | ||
</Typography> | ||
<Typography variant="body2" fontWeight={700}> | ||
{data.sourceNumber} | ||
</Typography> | ||
</Box> | ||
<Box> | ||
<Typography | ||
variant="subtitle2" | ||
color={BCDesignTokens.typographyColorPlaceholder} | ||
> | ||
Title: | ||
</Typography> | ||
<Typography variant="body2" fontWeight={700}> | ||
{data.sourceTitle} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
<Box> | ||
<Typography | ||
variant="subtitle2" | ||
color={BCDesignTokens.typographyColorPlaceholder} | ||
> | ||
Description: | ||
</Typography> | ||
<ParagraphWithReadMore | ||
maxHeight={84} | ||
renderTypography={ | ||
<Typography variant="body2" display={"flex"} flex={1}> | ||
{data.description?.text} | ||
</Typography> | ||
} | ||
/> | ||
</Box> | ||
</Stack> | ||
</AccordionDetails> | ||
</Accordion> | ||
); | ||
} | ||
); | ||
|
||
export default RequirementSourceCard; |
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