feat(SW-1773): add proper validation to form and query

This commit is contained in:
Christian Andolf
2025-02-27 16:28:58 +01:00
parent 21255f8557
commit c98ac88ac0
12 changed files with 74 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
"use client"
import { Text, TextField } from "react-aria-components"
import { Controller, useFormContext } from "react-hook-form"
import { useIntl } from "react-intl"
import { CheckIcon, InfoCircleIcon } from "@/components/Icons"
import AriaInputWithLabel from "@/components/TempDesignSystem/Form/Input/AriaInputWithLabel"
@@ -25,6 +26,7 @@ export default function Input({
registerOptions = {},
type = "text",
}: InputProps) {
const intl = useIntl()
const { control } = useFormContext()
let numberAttributes: HTMLAttributes<HTMLInputElement> = {}
if (type === "number") {
@@ -73,7 +75,7 @@ export default function Input({
{fieldState.error ? (
<Caption className={styles.error} fontOnly>
<InfoCircleIcon color="red" />
{fieldState.error.message}
{intl.formatMessage({ id: fieldState.error.message })}
</Caption>
) : null}
</TextField>