feat(web): highlight the offending field on a set_fields 422 (#28)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 15:39:49 +02:00
parent d6dc1c9b57
commit 0c9db7bcdb
7 changed files with 73 additions and 12 deletions
+4 -3
View File
@@ -3,7 +3,7 @@ import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { ObjectForm, type ObjectFormValues } from "./object-form";
import { useCreateObject, useSetFields } from "../api/queries";
import { useCreateObject, useSetFields, FieldRejection } from "../api/queries";
export function ObjectNewPage() {
const { t } = useTranslation();
@@ -32,8 +32,9 @@ export function ObjectNewPage() {
if (Object.keys(values.fields).length > 0) {
try {
await setFields.mutateAsync({ id, fields: values.fields });
} catch {
navigate(`/objects/${id}/edit`, { state: { fieldsError: true } });
} catch (e) {
const fieldErrorKey = e instanceof FieldRejection ? e.field : undefined;
navigate(`/objects/${id}/edit`, { state: { fieldsError: true, fieldErrorKey } });
return;
}
}