Skip to content

Commit

Permalink
Fix bug when creating new Standort with first Bohrung (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt authored Jul 20, 2022
2 parents 4d2f73a + 4620b04 commit 940d955
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 940d955

Please sign in to comment.