import type { z } from "zod"; import { Paragraph } from "./Paragraph"; import { motion } from "framer-motion"; import { cn } from "~/utils/cn"; import { ErrorIcon } from "~/assets/icons/ErrorIcon"; export function FormError({ children, id, className, }: { children: React.ReactNode; id?: string; className?: string; }) { return ( <> {children && ( {children} )} ); } export function ZodFormErrors({ errors, path }: { errors: z.ZodIssue[]; path: string[] }) { if (errors.length === 0) { return null; } const relevantErrors = errors.filter((error) => { return error.path.join(".") === path.join("."); }); if (relevantErrors.length === 0) { return null; } return (
{relevantErrors.map((error, index) => ( {error.message} ))}
); }