Skip to content

Commit

Permalink
legt til error på radio,TODO må legge til handlersubmit på knapp fot…
Browse files Browse the repository at this point in the history
… å sjekke om radio ikke er valgt
  • Loading branch information
henriktheboss committed Feb 13, 2025
1 parent de6060f commit dd8aee4
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ interface Props {

const ForhaandsorienteringsMelding = (props: Props) => {
const { register, oppdaterer, avtaltText119, errors } = props;

const [error, setError] = useState("");
const [selectedType, setForhaandsorienteringType] = useState<string | null>(null);

const valgtforhandsorientering = (val: string) => {
setForhaandsorienteringType(val);
setError("");
};

const handleSubmit = () => {
if (!selectedType) {
setError("Du må velge en type forhåndsorientering før du kan gå videre.");
return;
}
};

return (
Expand All @@ -32,8 +40,9 @@ const ForhaandsorienteringsMelding = (props: Props) => {
legend="Velg type forhåndsorientering"
disabled={oppdaterer}
className="mt-4"
onChange={valgtforhandsorientering}
value={selectedType}
error={error}
onChange={valgtforhandsorientering}
>
<Radio value={ForhaandsorienteringType.SEND_STANDARD}>Forhåndsorientering (standard melding)</Radio>
<Radio value={ForhaandsorienteringType.SEND_PARAGRAF_11_9}>Forhåndsorientering for §11-9 (AAP)</Radio>
Expand All @@ -53,7 +62,6 @@ const ForhaandsorienteringsMelding = (props: Props) => {
value={avtaltText119}
{...register('avtaltText119')}
error={(errors as any).avtaltText119 && (errors as any).avtaltText119.message}

/>
<br />
<VarslingInfo />
Expand Down

0 comments on commit dd8aee4

Please sign in to comment.