feat: attempt to fix the crud with auth
This commit is contained in:
28
components/FormMessage.tsx
Normal file
28
components/FormMessage.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useFormField } from '@hooks/useFormField';
|
||||
import { cn } from '@utils/cn';
|
||||
import * as React from 'react';
|
||||
|
||||
export const FormMessage = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, children, ...props }, ref) => {
|
||||
const { error, formMessageId } = useFormField();
|
||||
const body = error ? String(error?.message) : children;
|
||||
|
||||
return (
|
||||
<>
|
||||
{!body ? null : (
|
||||
<p
|
||||
ref={ref}
|
||||
id={formMessageId}
|
||||
className={cn('text-destructive text-sm font-medium', className)}
|
||||
{...props}
|
||||
>
|
||||
{body}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
FormMessage.displayName = 'FormMessage';
|
||||
Reference in New Issue
Block a user