Skip to content

Commit

Permalink
Improve readability of conditional renderings
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickackermann committed May 23, 2024
1 parent dc28c6e commit aeb9fa5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/client/src/commons/form/borehole/borehole/geometry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ const Geometry = ({ boreholeId, isEditable, measuredDepth }) => {
{ md: measuredDepth, x: 0, y: 0, z: measuredDepth },
];

const noDataLoaded = !data;
const anyDataPresent = data?.length > 0;

return (
<>
{!data ? (
{noDataLoaded ? (
<FullPageCentered>
<CircularProgress />
</FullPageCentered>
) : data?.length === 0 && !measuredDepth && !isEditable ? (
) : !anyDataPresent && !measuredDepth && !isEditable ? (
<FullPageCentered>
<Typography variant="fullPageMessage">{t("msgBoreholeGeometryEmpty")}</Typography>
</FullPageCentered>
Expand All @@ -49,7 +52,7 @@ const Geometry = ({ boreholeId, isEditable, measuredDepth }) => {
</Grid>
</>
)}
{isEditable && data.length > 0 && (
{isEditable && anyDataPresent && (
<Grid item xs={12}>
<Card>
<CardActions>
Expand All @@ -64,7 +67,7 @@ const Geometry = ({ boreholeId, isEditable, measuredDepth }) => {
</Card>
</Grid>
)}
{(data.length > 0 || !isEditable) &&
{(!isEditable || anyDataPresent) &&
[
<GeometryChartNE key="" data={data.length === 0 ? defaultData : data} />,
<GeometryChartZN key="" data={data.length === 0 ? defaultData : data} />,
Expand Down

0 comments on commit aeb9fa5

Please sign in to comment.