"use client"; import { Icon } from "@iconify/react"; import { Input } from "@nextui-org/react"; import React, { useState } from "react"; import { Control, FieldPath } from "react-hook-form"; import { z } from "zod"; import { FormControl, FormField, FormMessage } from "@/components/ui/form"; import { authFormSchema } from "@/types"; const formSchema = authFormSchema("sign-up"); type CustomInputProps = | { control: Control>; name: FieldPath>; label: string; type: "text" | "email"; placeholder: string; isRequired?: boolean; password?: false; } | { control: Control>; password: true; name?: never; label?: never; type?: never; placeholder?: never; isRequired?: never; }; export const CustomInput = ({ control, name, type, label, placeholder, password = false, isRequired = true, }: CustomInputProps) => { const [isVisible, setIsVisible] = useState(false); const toggleVisibility = () => setIsVisible(!isVisible); const inputName = password ? "password" : name!; const inputLabel = password ? "Password" : label; const inputType = password ? (isVisible ? "text" : "password") : type; const inputPlaceholder = password ? "Enter your password" : placeholder; const inputIsRequired = password ? true : isRequired; return ( >} render={({ field }) => ( <> ) : null } /> )} /> ); };