Skip to content

Commit

Permalink
Merge pull request #220 from nitheesh-aot/req-readonly
Browse files Browse the repository at this point in the history
COMP-328: Requirement information display+Delete button style (front)
  • Loading branch information
dinesh-aot authored Feb 6, 2025
2 parents 456f82d + 1f67843 commit e5fbe7e
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 188 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Grid, Typography, Tooltip } from "@mui/material";
import { BCDesignTokens } from "epic.theme";
import { FC, ReactNode, memo } from "react";

const GridLabelValuePair: FC<{
label: string;
value: ReactNode;
gridProps?: { xs: number };
}> = memo(({ label, value, gridProps = { xs: 12 } }) => (
<Grid item {...gridProps}>
<Typography
variant="body2"
color={BCDesignTokens.typographyColorPlaceholder}
>
{label}
</Typography>
<Tooltip title={value}>
<Typography
variant="body1"
sx={{
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
}}
>
{value}
</Typography>
</Tooltip>
</Grid>
));

export default GridLabelValuePair;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isRequirementSourceCondition,
REGULATORY_CONSIDERATION_TYPE_ID,
} from "./RequirementUtils";
import GridLabelValuePair from "./GridLabelValuePair";

interface RequirementCardProps {
requirement: InspectionRequirement;
Expand All @@ -18,22 +19,6 @@ interface RequirementCardProps {
isActive: boolean;
}

const LabelValuePair: React.FC<{
label: string;
value: React.ReactNode;
gridProps?: { xs: number };
}> = React.memo(({ label, value, gridProps = { xs: 12 } }) => (
<Grid item {...gridProps}>
<Typography
variant="body2"
color={BCDesignTokens.typographyColorPlaceholder}
>
{label}
</Typography>
<Typography variant="body1">{value}</Typography>
</Grid>
));

const cardStyles = {
card: {
backgroundColor: BCDesignTokens.surfaceColorBackgroundWhite,
Expand Down Expand Up @@ -98,13 +83,13 @@ const RequirementCard: React.FC<RequirementCardProps> = memo(
const renderRegulatoryContent = useCallback(
() => (
<>
<LabelValuePair label="Summary" value={requirement.summary} />
<LabelValuePair
<GridLabelValuePair label="Summary" value={requirement.summary} />
<GridLabelValuePair
label="Topic"
value={requirement.topic.name}
gridProps={{ xs: 4 }}
/>
<LabelValuePair
<GridLabelValuePair
label="Agency"
value={requirement.agency?.name ?? ""}
gridProps={{ xs: 8 }}
Expand All @@ -117,16 +102,16 @@ const RequirementCard: React.FC<RequirementCardProps> = memo(
const renderRequirementContent = useCallback(
() => (
<>
<LabelValuePair label="Topic" value={requirement.topic.name} />
<LabelValuePair
<GridLabelValuePair label="Topic" value={requirement.topic.name} />
<GridLabelValuePair
label="Source"
value={
requirement.requirement_source_details?.[0]?.requirement_source
?.name
}
gridProps={{ xs: 4 }}
/>
<LabelValuePair
<GridLabelValuePair
label={isCondition ? "Condition #" : "Section #"}
value={
isCondition
Expand All @@ -135,12 +120,12 @@ const RequirementCard: React.FC<RequirementCardProps> = memo(
}
gridProps={{ xs: 8 }}
/>
<LabelValuePair
<GridLabelValuePair
label="Compliance Finding"
value={requirement.compliance_finding?.name}
gridProps={{ xs: 4 }}
/>
<LabelValuePair
<GridLabelValuePair
label="Enforcement Action"
value={requirement.enforcement_action_data
.map((action) => action.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const RequirementDrawer: React.FC<RequirementDrawerProps> = ({
setSelectedRequirementType(requirementType ?? undefined);
}}
isRegulatoryConsiderationExists={isRegulatoryConsiderationExists}
isEditMode={!!inspectionRequirementData}
/>
{isRequirement && (
<RequirementFormRight
Expand Down
Loading

0 comments on commit e5fbe7e

Please sign in to comment.