Skip to content

Commit

Permalink
Remove JSON.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt committed Dec 20, 2024
1 parent c50be64 commit 4fa9518
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const HierarchicalDataEditProfile = ({
(accu[level] = accu[level] || []).push({
label: d[i18n.language],
id: d.id,
color: JSON.parse(d.conf ?? null)?.color,
color: (d.conf ?? null)?.color,
path: path,
});
return accu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const LithologyLayersList = props => {
const middle = (item?.fromDepth + item?.toDepth) / 2;
return x.fromDepth <= middle && middle <= x.toDepth;
});
setLithostratiColor(
JSON.parse(correspondingLithostrati?.lithostratigraphy?.conf ?? null)?.color ?? [255, 255, 255],
);
setLithostratiColor((correspondingLithostrati?.lithostratigraphy?.conf ?? null)?.color ?? [255, 255, 255]);
} else {
setLithostratiColor([255, 255, 255]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, LinearProgress } from "@mui/material";
import { useLayers } from "../../../../api/fetchApiV2.js";
import { theme } from "../../../../AppTheme.ts";

const handlePattern = layer => `url(/img/lit/${JSON.parse(layer?.lithology?.conf ?? null)?.image})`;
const handlePattern = layer => `url(/img/lit/${(layer?.lithology?.conf ?? null)?.image})`;

/**
* Displays the lithology layers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useEffect } from "react";
import { Box, LinearProgress } from "@mui/material";
import { useLithostratigraphies } from "../../../../../api/fetchApiV2.js";

const handleColor = layer =>
`rgb(${(JSON.parse(layer?.lithostratigraphy?.conf ?? null)?.color ?? [255, 255, 255]).join()})`;
const handleColor = layer => `rgb(${((layer?.lithostratigraphy?.conf ?? null)?.color ?? [255, 255, 255]).join()})`;

/**
* Displays the lithostratigraphy layers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const EditorSettingList = props => {
const isVisible = field => {
const layerKindConfigEntry = codes?.find(c => c.schema === "layer_kind");

const conf = layerKindConfigEntry?.conf ? JSON.parse(layerKindConfigEntry?.conf) : "";
const conf = layerKindConfigEntry?.conf ? layerKindConfigEntry?.conf : "";
return conf?.fields?.[field] ?? false;
};
return listName === "lithologyfields"
Expand Down

0 comments on commit 4fa9518

Please sign in to comment.