Skip to content

Commit

Permalink
Merge pull request #336 from GeoWerkstatt/fix-react-warnings
Browse files Browse the repository at this point in the history
Fix react warnings
  • Loading branch information
danjov authored Feb 5, 2024
2 parents 3548abf + 5466b3f commit 79cb148
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 48 deletions.
29 changes: 15 additions & 14 deletions src/ClientApp/src/components/BohrprofilForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function BohrprofilForm(props) {
const [formationEndtiefeCodes, setFormationEndtiefeCodes] = useState([]);
const [openSchichtConfirmation, setOpenSchichtConfirmation] = useState(false);
const [openVorkommnisConfirmation, setOpenVorkommnisConfirmation] = useState(false);
const [selectedDate, setSelectedDate] = useState();
const [selectedDate, setSelectedDate] = useState(null);

const currentBohrprofilIndex =
currentBohrung.bohrprofile?.indexOf(currentBohrung.bohrprofile.find((b) => b.id === currentBohrprofil.id)) || 0;
Expand Down Expand Up @@ -253,7 +253,8 @@ export default function BohrprofilForm(props) {
sx: { marginRight: "6%", width: "47%" },
margin: "normal",
variant: "standard",
...register("datum"),
name: "datum",
ref: register("datum").ref,
},
}}
/>
Expand All @@ -265,7 +266,7 @@ export default function BohrprofilForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
InputLabelProps={{ shrink: field.value != null }}
margin="normal"
multiline
Expand All @@ -285,7 +286,7 @@ export default function BohrprofilForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
sx={{ marginRight: "6%", width: "47%" }}
margin="normal"
label="Terrainkote der Bohrung [m ü. M.]"
Expand All @@ -303,7 +304,7 @@ export default function BohrprofilForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
sx={{ width: "47%" }}
margin="normal"
label="Endtiefe der Bohrung [m u. T.]"
Expand All @@ -321,8 +322,8 @@ export default function BohrprofilForm(props) {
<Autocomplete
{...field}
options={formationFelsCodes.sort((a, b) => a.sortierung - b.sortierung).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => formationFelsCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => formationFelsCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
fullWidth
Expand All @@ -346,8 +347,8 @@ export default function BohrprofilForm(props) {
<Autocomplete
{...field}
options={formationEndtiefeCodes.sort((a, b) => a.sortierung - b.sortierung).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => formationEndtiefeCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => formationEndtiefeCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
fullWidth
Expand All @@ -373,8 +374,8 @@ export default function BohrprofilForm(props) {
{...field}
sx={{ marginRight: "6%", width: "47%" }}
options={tektonikCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => tektonikCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => tektonikCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
renderInput={(params) => (
Expand All @@ -399,8 +400,8 @@ export default function BohrprofilForm(props) {
{...field}
sx={{ width: "47%" }}
options={qualitaetCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
renderInput={(params) => (
Expand All @@ -423,7 +424,7 @@ export default function BohrprofilForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
InputLabelProps={{ shrink: field.value != null }}
margin="normal"
multiline
Expand Down
27 changes: 14 additions & 13 deletions src/ClientApp/src/components/BohrungForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function BohrungForm(props) {
const [ablenkungCodes, setAblenkungCodes] = useState([]);
const [qualitaetCodes, setQualitaetCodes] = useState([]);
const [openConfirmation, setOpenConfirmation] = useState(false);
const [selectedDate, setSelectedDate] = useState();
const [selectedDate, setSelectedDate] = useState(null);

const currentBohrungIndex =
currentStandort.bohrungen?.indexOf(currentStandort.bohrungen.find((b) => b.id === currentBohrung?.id)) || 0;
Expand Down Expand Up @@ -235,7 +235,7 @@ export default function BohrungForm(props) {
<TextField
{...field}
autoFocus
value={field.value}
value={field.value ?? ""}
margin="normal"
label="Bezeichnung der Bohrung"
type="text"
Expand All @@ -254,7 +254,7 @@ export default function BohrungForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
margin="normal"
InputLabelProps={{ shrink: field.value != null }}
multiline
Expand Down Expand Up @@ -283,7 +283,8 @@ export default function BohrungForm(props) {
sx: { marginRight: "6%", width: "47%" },
margin: "normal",
variant: "standard",
...register("datum"),
name: "datum",
ref: register("datum").ref,
},
}}
/>
Expand All @@ -295,7 +296,7 @@ export default function BohrungForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
InputLabelProps={{ shrink: field.value != null }}
sx={{ width: "47%" }}
margin="normal"
Expand All @@ -315,9 +316,9 @@ export default function BohrungForm(props) {
<Autocomplete
{...field}
options={ablenkungCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
value={field.value ?? null}
onChange={(_, data) => field.onChange(data)}
getOptionLabel={(option) => ablenkungCodes.find((c) => c.id === option)?.kurztext}
getOptionLabel={(option) => ablenkungCodes.find((c) => c.id === option)?.kurztext ?? ""}
autoHighlight
sx={{ marginRight: "6%", width: "47%" }}
renderInput={(params) => (
Expand All @@ -340,8 +341,8 @@ export default function BohrungForm(props) {
<Autocomplete
{...field}
options={qualitaetCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
sx={{ width: "47%" }}
Expand All @@ -365,7 +366,7 @@ export default function BohrungForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
InputLabelProps={{ shrink: field.value != null }}
fullWidth
margin="normal"
Expand All @@ -385,7 +386,7 @@ export default function BohrungForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
margin="normal"
label="Autor der geologischen Aufnahme"
type="text"
Expand Down Expand Up @@ -419,7 +420,7 @@ export default function BohrungForm(props) {
sx={{ marginRight: "6%", width: "47%" }}
margin="normal"
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
onChange={(value) => field.onChange(value)}
label="X-Koordinate der Bohrung"
type="number"
Expand Down Expand Up @@ -448,7 +449,7 @@ export default function BohrungForm(props) {
sx={{ width: "47%" }}
margin="normal"
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
onChange={(value) => field.onChange(value)}
label="Y-Koordinate der Bohrung"
type="number"
Expand Down
14 changes: 7 additions & 7 deletions src/ClientApp/src/components/SchichtForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function SchichtForm(props) {
render={({ field, fieldState: { error } }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
sx={{ width: "47%" }}
margin="normal"
label="Tiefe [m u. T.]"
Expand All @@ -133,8 +133,8 @@ export default function SchichtForm(props) {
{...field}
sx={{ width: "47%" }}
options={codeSchichten.map((c) => c.id).sort((a, b) => a - b)}
value={field.value}
getOptionLabel={(option) => codeSchichten.find((c) => c.id === option)?.text}
value={field.value ?? null}
getOptionLabel={(option) => codeSchichten.find((c) => c.id === option)?.text ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
renderInput={(params) => (
Expand All @@ -159,7 +159,7 @@ export default function SchichtForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
margin="normal"
multiline
label="Bemerkungen zur Schicht"
Expand All @@ -178,8 +178,8 @@ export default function SchichtForm(props) {
<Autocomplete
{...field}
options={qualitaetCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
sx={{ width: "47%" }}
autoHighlight
Expand All @@ -197,7 +197,7 @@ export default function SchichtForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
margin="normal"
multiline
label="Bemerkungen zur Qualitätsangabe"
Expand Down
14 changes: 7 additions & 7 deletions src/ClientApp/src/components/StandortForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function StandortForm(props) {
render={({ field, fieldState: { error } }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
autoFocus
margin="normal"
label="Bezeichnung des Standorts"
Expand All @@ -148,7 +148,7 @@ export default function StandortForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
margin="normal"
label="Bemerkung zum Standort"
type="text"
Expand All @@ -161,15 +161,15 @@ export default function StandortForm(props) {
/>
<React.Fragment>
<TextField
value={currentStandort?.gemeinde}
value={currentStandort?.gemeinde ?? ""}
fullWidth
type="text"
disabled
variant="standard"
label="Gemeinde"
/>
<TextField
value={currentStandort?.grundbuchNr}
value={currentStandort?.grundbuchNr ?? ""}
fullWidth
type="text"
inputProps={{
Expand All @@ -194,6 +194,7 @@ export default function StandortForm(props) {
defaultValue={currentStandort?.freigabeAfu ?? false}
render={({ field }) => (
<Checkbox
{...register("freigabeAfu")}
{...field}
checked={field.value}
onChange={(e) => {
Expand All @@ -202,15 +203,14 @@ export default function StandortForm(props) {
}}
/>
)}
{...register("freigabeAfu")}
/>
}
/>
</FormGroup>
)}
<React.Fragment>
<TextField
value={currentStandort?.afuUser}
value={currentStandort?.afuUser ?? ""}
InputLabelProps={{ shrink: afuFreigabe }}
sx={{ marginRight: "6%", width: "47%" }}
disabled
Expand All @@ -223,7 +223,7 @@ export default function StandortForm(props) {

<TextField
name="afuDatum"
value={currentStandort?.afuDatum ? new Date(currentStandort.afuDatum).toLocaleDateString() : null}
value={currentStandort?.afuDatum ? new Date(currentStandort.afuDatum).toLocaleDateString() : ""}
InputLabelProps={{ shrink: afuFreigabe }}
disabled
sx={{ width: "47%" }}
Expand Down
14 changes: 7 additions & 7 deletions src/ClientApp/src/components/VorkommnisForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function VorkommnisForm(props) {
render={({ field }) => (
<TextField
{...field}
value={field.value}
value={field.value ?? ""}
sx={{ width: "47%" }}
margin="normal"
label="Tiefe [m u. T.]"
Expand All @@ -132,8 +132,8 @@ export default function VorkommnisForm(props) {
{...field}
sx={{ width: "47%" }}
options={typCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => typCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => typCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
autoHighlight
renderInput={(params) => (
Expand All @@ -158,7 +158,7 @@ export default function VorkommnisForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
margin="normal"
multiline
label="Bemerkungen zum Vorkommnis"
Expand All @@ -177,8 +177,8 @@ export default function VorkommnisForm(props) {
<Autocomplete
{...field}
options={qualitaetCodes.sort((a, b) => a.kurztext.localeCompare(b.kurztext)).map((c) => c.id)}
value={field.value}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext}
value={field.value ?? null}
getOptionLabel={(option) => qualitaetCodes.find((c) => c.id === option)?.kurztext ?? ""}
onChange={(_, data) => field.onChange(data)}
sx={{ width: "47%" }}
autoHighlight
Expand All @@ -196,7 +196,7 @@ export default function VorkommnisForm(props) {
<TextField
{...field}
InputLabelProps={{ shrink: field.value != null }}
value={field.value}
value={field.value ?? ""}
margin="normal"
multiline
label="Bemerkungen zur Qualitätsangabe"
Expand Down

0 comments on commit 79cb148

Please sign in to comment.