"use client"; import { Plus } from "lucide-react"; import { useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { cn } from "@/lib/utils"; interface FileInputProps { onChange?: (file: File | null) => void; value?: File | null; alt?: string; className?: string; } const FileInput = ({ onChange, value, alt, className, ...props }: FileInputProps) => { const inputRef = useRef(null); return ( <> onChange?.(e.target.files?.[0] || null)} {...props} />
inputRef.current?.click()} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { inputRef.current?.click(); } }} className={cn( "flex size-26 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md border text-muted-foreground shadow-xs sm:size-34", className, )} > {!value ? ( ) : ( {alt} )}
); }; interface CompaniesCreate5Props { className?: string; title?: string; } const CompaniesCreate5 = ({ className, title = "ایجاد پروفایل شرکت", }: CompaniesCreate5Props) => { const [formData, setFormData] = useState>({}); const [logo, setLogo] = useState(null); const FIELDS = [ { label: "تلفن", name: "phone", type: "tel", placeholder: "۰۹۱۲ ۳۴۵ ۶۷۸۹", }, { label: "آدرس", name: "address", type: "text", placeholder: "تهران، خیابان ولیعصر، پلاک ۱۲", }, { label: "وب‌سایت", name: "website", type: "url", placeholder: "https://example.ir", }, ]; const handleInputChange = (name: string, value: string) => { setFormData((prev) => ({ ...prev, [name]: value })); }; return (
{title}
e.preventDefault()} className="mt-2" >
setLogo(file)} value={logo} alt="لوگوی شرکت" />
handleInputChange("name", e.target.value) } type="text" required={true} className="!bg-transparent" />
handleInputChange("email", e.target.value) } type="email" required={true} className="!bg-transparent" />
handleInputChange("description", e.target.value) } type="text" className="!bg-transparent" />
{FIELDS.map((field, i) => { return (
handleInputChange(field.name, e.target.value) } type={field.type} className="!bg-transparent" />
); })}
); }; export { CompaniesCreate5 };