expanding the name and collor function to use the custom grain (still need to return the color for custom)

This commit is contained in:
csawatzky 2025-12-16 14:31:09 -06:00
parent ce1ee67fdc
commit e2ad43975d

View file

@ -100,13 +100,26 @@ export default function UnitMeasurementSummary(props: Props) {
); );
}; };
const grainName = () => {
if(component.settings.grainType === pond.Grain.GRAIN_CUSTOM && component.settings.customGrain?.name){
return component.settings.customGrain.name
}
return GrainDescriber(component.settings.grainType).name
}
const grainColor = () => {
if(component.settings.grainType === pond.Grain.GRAIN_CUSTOM && component.settings.customGrain?.name){
return
}
return GrainDescriber(component.settings.grainType).colour
}
const getSummaryComponent = (summaries: Summary[]): any => { const getSummaryComponent = (summaries: Summary[]): any => {
if (summaries.length < 1) { if (summaries.length < 1) {
return noSummary(); return noSummary();
} }
let overlays: JSX.Element[] = []; let overlays: JSX.Element[] = [];
let grain = GrainDescriber(component.settings.grainType);
return ( return (
<Grid container> <Grid container>
<Grid size={{ xs: 12 }}> <Grid size={{ xs: 12 }}>
@ -170,7 +183,7 @@ export default function UnitMeasurementSummary(props: Props) {
component.settings.grainType !== pond.Grain.GRAIN_INVALID && ( component.settings.grainType !== pond.Grain.GRAIN_INVALID && (
<Typography variant={largeText ? "body1" : "caption"} color="textPrimary"> <Typography variant={largeText ? "body1" : "caption"} color="textPrimary">
<span key={"grainType"}> <span key={"grainType"}>
Grain Type: <span style={{ color: grain.colour }}>{grain.name}</span> Grain Type: <span style={{ color: grainColor() }}>{grainName()}</span>
</span> </span>
</Typography> </Typography>
)} )}