diff --git a/src/clients/initial-access/CreateInitialAccessToken.tsx b/src/clients/initial-access/CreateInitialAccessToken.tsx index ced3ff282f..2983a7c1d6 100644 --- a/src/clients/initial-access/CreateInitialAccessToken.tsx +++ b/src/clients/initial-access/CreateInitialAccessToken.tsx @@ -24,7 +24,12 @@ import { toClients } from "../routes/Clients"; export default function CreateInitialAccessToken() { const { t } = useTranslation("clients"); - const { handleSubmit, control } = useForm(); + const { + handleSubmit, + control, + errors, + formState: { isValid }, + } = useForm({ mode: "onChange" }); const adminClient = useAdminClient(); const { realm } = useRealm(); @@ -76,16 +81,21 @@ export default function CreateInitialAccessToken() { fieldLabelId="clients:expiration" /> } + helperTextInvalid={t("expirationValueNotValid")} + validated={errors.expiration ? "error" : "default"} > ( )} /> @@ -113,15 +123,23 @@ export default function CreateInitialAccessToken() { value={value} onPlus={() => onChange(value + 1)} onMinus={() => onChange(value - 1)} - onChange={(event) => - onChange(Number((event.target as HTMLInputElement).value)) - } + onChange={(event) => { + const value = Number( + (event.target as HTMLInputElement).value + ); + onChange(value < 1 ? 1 : value); + }} /> )} /> -