feat: attempt to fix the crud with auth

This commit is contained in:
Riccardo
2024-07-07 17:47:57 +02:00
parent ea73368cc9
commit 637520dbf2
27 changed files with 622 additions and 53 deletions

View File

@@ -0,0 +1,13 @@
import React from 'react';
import { FieldPath, FieldValues } from 'react-hook-form';
interface FormFieldContextValue<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> {
name: TName;
}
export const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
);

View File

@@ -0,0 +1,20 @@
import {
Controller,
ControllerProps,
FieldPath,
FieldValues
} from 'react-hook-form';
import { FormFieldContext } from './FormFieldContext';
export const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
return (
<FormFieldContext.Provider value={{ name: props.name }}>
<Controller {...props} />
</FormFieldContext.Provider>
);
};