diff --git a/app/components/addUserModel/addUserModal.tsx b/app/components/addUserModel/addUserModal.tsx new file mode 100644 index 00000000..d6693a20 --- /dev/null +++ b/app/components/addUserModel/addUserModal.tsx @@ -0,0 +1,39 @@ +import clsx from "clsx"; +import { XIcon } from "lucide-react"; + +import { useModal } from "../../context/modalContext"; +import { InputForm } from "../ui/formComponents/formComponent"; +import { UploadPicture } from "../ui/formComponents/uploadPicture"; + +const AddUserModal = () => { + const { isOpen, handleClose } = useModal(); + return ( + <> + {isOpen && ( +
+
+ +

Add new user

+

Create New User

+ + +
+
+ )} + ; + + ); +}; + +export default AddUserModal; diff --git a/app/components/ui/form.tsx b/app/components/ui/form.tsx index 86972146..43abe65a 100644 --- a/app/components/ui/form.tsx +++ b/app/components/ui/form.tsx @@ -1,3 +1,4 @@ + "use client"; import * as LabelPrimitive from "@radix-ui/react-label"; @@ -5,6 +6,7 @@ import { Slot } from "@radix-ui/react-slot"; import { Label } from "app/components/ui/label"; import { cn } from "app/lib/utils/cn"; import * as React from "react"; + import { Controller, ControllerProps, @@ -12,46 +14,51 @@ import { FieldValues, FormProvider, useFormContext, -} from "react-hook-form"; -const Form = FormProvider; +} from "react-hook-form" + +import { cn } from "app/lib/utils/cn" +import { Label } from "app/components/ui/label" + +const Form = FormProvider type FormFieldContextValue< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TName extends FieldPath = FieldPath > = { - name: TName; -}; + name: TName +} const FormFieldContext = React.createContext( - {} as FormFieldContextValue, -); + {} as FormFieldContextValue +) const FormField = < TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TName extends FieldPath = FieldPath >({ - ...properties + ...props }: ControllerProps) => { return ( - - + + - ); -}; + ) +} const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext); - const itemContext = React.useContext(FormItemContext); - const { getFieldState, formState } = useFormContext(); + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState, formState } = useFormContext() - const fieldState = getFieldState(fieldContext.name, formState); + const fieldState = getFieldState(fieldContext.name, formState) if (!fieldContext) { - throw new Error("useFormField should be used within "); + throw new Error("useFormField should be used within ") } - const { id } = itemContext; + const { id } = itemContext + return { id, @@ -60,113 +67,124 @@ const useFormField = () => { formDescriptionId: `${id}-form-item-description`, formMessageId: `${id}-form-item-message`, ...fieldState, - }; -}; + + } +} type FormItemContextValue = { - id: string; -}; + id: string +} const FormItemContext = React.createContext( - {} as FormItemContextValue, -); + {} as FormItemContextValue +) + const FormItem = React.forwardRef< HTMLDivElement, React.HTMLAttributes ->(({ className, ...properties }, reference) => { - const id = React.useId(); + +>(({ className, ...props }, ref) => { + const id = React.useId() return ( -
+
- ); -}); -FormItem.displayName = "FormItem"; + ) +}) +FormItem.displayName = "FormItem" + const FormLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => { - const { error, formItemId } = useFormField(); + +>(({ className, ...props }, ref) => { + const { error, formItemId } = useFormField() return (