Skip to content

Commit

Permalink
Fix error when creating new standort with first bohrung
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt committed Jul 19, 2022
1 parent 4d2f73a commit 4620b04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ClientApp/src/components/BohrungForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function BohrungForm(props) {
const [xCoordinate, setXCoordinate] = useState();
const [yCoordinate, setYCoordinate] = useState();

const currentBohrungIndex = currentStandort.bohrungen.indexOf(currentBohrung);
const numberOfBohrungen = currentStandort.bohrungen.length;
const currentBohrungIndex = currentStandort.bohrungen?.indexOf(currentBohrung) || 0;
const numberOfBohrungen = currentStandort.bohrungen?.length || 0;

// Get codes for dropdowns
useEffect(() => {
Expand Down Expand Up @@ -96,7 +96,7 @@ export default function BohrungForm(props) {

const validateDistance = () => {
let isValid = false;
if (currentStandort.bohrungen?.length === 0) {
if (numberOfBohrungen === 0) {
isValid = true;
} else if (xCoordinate && yCoordinate) {
const src = "EPSG:2056";
Expand Down

0 comments on commit 4620b04

Please sign in to comment.