commit compras1 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 07:11:35 +02:00
parent d58b75c87a
commit eb32c74c56
202 changed files with 17463 additions and 1526 deletions
+24 -2
View File
@@ -4,6 +4,7 @@ import { useId, type ReactNode } from 'react';
import { Badge } from '@/components/ui/badge';
import { openJourneyHelp } from '@/components/journey-help';
import { recoveryHints } from '@/lib/journey-help';
import { focusFormError } from '@/lib/form-error-focus';
import { date, money, statusLabels } from '@/types/procurement';
import type { Requisition } from '@/types/procurement';
@@ -228,7 +229,13 @@ export function RequisitionTable({ rows }: { rows: Requisition[] }) {
</div>
);
}
export function FormErrors({ errors }: { errors: Record<string, string> }) {
export function FormErrors({
errors,
targets = {},
}: {
errors: Record<string, string>;
targets?: Record<string, string>;
}) {
if (!Object.keys(errors).length) return null;
const hints = recoveryHints(Object.keys(errors));
return (
@@ -239,7 +246,22 @@ export function FormErrors({ errors }: { errors: Record<string, string> }) {
<p className="mb-1 font-medium">Verifique os dados:</p>
<ul className="list-inside list-disc">
{Object.entries(errors).map(([key, value]) => (
<li key={key}>{value}</li>
<li key={key}>
{targets[key] ? (
<a
className="underline focus-visible:ring-2 focus-visible:ring-ring"
href={`#${targets[key]}`}
onClick={(event) => {
if (focusFormError(targets[key]))
event.preventDefault();
}}
>
{value}
</a>
) : (
value
)}
</li>
))}
</ul>
{hints.length > 0 && (