"use client"; import { Building2, Calendar, Check, ChevronsUpDown, Coins, Facebook, FileText, Instagram, Link, Linkedin, MapPin, Tag, TrendingUp, Twitter, User, Users, } from "lucide-react"; import { useState } from "react"; import { Tags, TagsContent, TagsEmpty, TagsGroup, TagsInput, TagsItem, TagsList, TagsTrigger, TagsValue, } from "@/components/kibo-ui/tags"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { cn } from "@/lib/utils"; interface ComboboxOption { label: string; value: string; } interface FormComboboxProps { value: string; onChange: (value: string) => void; options: ComboboxOption[]; name?: string; placeholder?: string; searchPlaceholder?: string; emptyMessage?: string; required?: boolean; } interface FormTagsProps { value: string[]; onChange: (value: string[]) => void; options: ComboboxOption[]; name?: string; searchPlaceholder?: string; emptyMessage?: string; required?: boolean; } const FormCombobox = ({ value, onChange, options, name, placeholder = "یک مورد را انتخاب کنید...", searchPlaceholder = "جستجو بر اساس نام...", emptyMessage = "موردی یافت نشد.", required = false, }: FormComboboxProps) => { const [open, setOpen] = useState(false); const selectedOption = options.find((option) => option.value === value); const displayValue = selectedOption ? selectedOption.label : ""; return (
{}} onClick={() => setOpen(true)} className={cn( "cursor-pointer bg-background pe-6", !value && "text-muted-foreground", )} />
{emptyMessage} {options.map((option) => ( { onChange(currentValue === value ? "" : currentValue); setOpen(false); }} > {option.label} ))}
); }; const FormTags = ({ value = [], onChange, options, name, searchPlaceholder = "جستجوی دسته‌بندی...", emptyMessage = "دسته‌بندی‌ای یافت نشد.", required = false, }: FormTagsProps) => { const [open, setOpen] = useState(false); const handleSelect = (selectedValue: string) => { const newValue = value.includes(selectedValue) ? value.filter((v) => v !== selectedValue) : [...value, selectedValue]; onChange(newValue); }; const handleRemove = (tagToRemove: string) => { onChange(value.filter((v) => v !== tagToRemove)); }; return ( {value.length > 0 ? value.map((tagValue) => { const option = options.find((opt) => opt.value === tagValue); return ( handleRemove(tagValue)} > {option?.label || tagValue} ); }) : null} {emptyMessage} {options.map((option) => ( handleSelect(option.value)} > {option.label} ))} {required && value.length === 0 && ( )} {value.map((tagValue) => ( ))} ); }; interface CompaniesCreate3Props { title?: string; className?: string; } const CompaniesCreate3 = ({ title = "ثبت شرکت", className, }: CompaniesCreate3Props) => { const [formData, setFormData] = useState>( {}, ); const [open, setOpen] = useState(false); const companies = [ { id: 1, name: "شرکت آکمه", description: "شرکتی فعال در توسعه راهکارهای نرم‌افزاری و خدمات دیجیتال", location: "سانفرانسیسکو، آمریکا", }, { id: 2, name: "تک‌استارت", description: "فعال در حوزه فناوری، نوآوری و تحول دیجیتال", location: "نیویورک، آمریکا", }, ]; const FIELDS = [ { label: "نام رسمی شرکت", name: "name", placeholder: "مثال: شرکت فناوری نوآور", icon: Building2, required: true, }, { label: "معرفی شرکت", name: "description", placeholder: "معرفی کوتاهی از فعالیت‌ها، محصولات و خدمات شرکت بنویسید...", icon: FileText, }, { label: "تیم", name: "team", placeholder: "اعضای مسئول این شرکت را انتخاب کنید...", icon: User, type: "combobox", searchPlaceholder: "جستجوی اعضا...", emptyMessage: "عضو تیمی یافت نشد.", required: true, options: [ { label: "علی", value: "alex", }, { label: "محمد", value: "john", }, { label: "سارا", value: "jane", }, ], }, { label: "دسته‌بندی‌ها", name: "categories", placeholder: "یک یا چند حوزه فعالیت را انتخاب کنید...", icon: Tag, type: "tags", searchPlaceholder: "جستجوی دسته‌بندی...", emptyMessage: "دسته‌بندی یافت نشد.", options: [ { label: "SaaS", value: "saas", }, { label: "تجارت الکترونیک", value: "ecommerce", }, { label: "فین‌تک", value: "fintech", }, { label: "بهداشت و درمان", value: "healthcare", }, { label: "آموزش", value: "education", }, { label: "سازمانی", value: "enterprise", }, { label: "B2B", value: "b2b", }, { label: "B2C", value: "b2c", }, ], }, { label: "موقعیت جغرافیایی", name: "location", placeholder: "مثال: تهران، ایران", icon: MapPin, }, { label: "AngelList", name: "angellist", placeholder: "AngelList...", icon: Link, }, { label: "Facebook", name: "facebook", placeholder: "Facebook...", icon: Facebook, }, { label: "Instagram", name: "instagram", placeholder: "Instagram...", icon: Instagram, }, { label: "LinkedIn", name: "linkedin", placeholder: "LinkedIn...", icon: Linkedin, }, { label: "Twitter", name: "twitter", placeholder: "Twitter...", icon: Twitter, }, { label: "برآورد درآمد تکرارشونده سالانه (ARR)", name: "arr", placeholder: "مثال: ۱۲۰٬۰۰۰ ریال", icon: TrendingUp, }, { label: "سرمایه جذب‌شده", name: "funding", placeholder: "مثال: ۱۰ میلیون ریال", icon: Coins, }, { label: "تاریخ تأسیس", name: "founded_date", placeholder: "مثال: ۱۳۹۸/۰۶/۱۵", icon: Calendar, }, { label: "محدوده تعداد کارکنان", name: "employee_range", placeholder: "مثال: ۵۰ تا ۱۰۰ نفر", icon: Users, }, ]; const handleInputChange = (name: string, value: string | string[]) => { setFormData((prev) => ({ ...prev, [name]: value })); }; return (

شرکت‌ها

اطلاعات شرکت‌ها را ثبت، جستجو و مدیریت کنید.

نام شرکت معرفی شرکت موقعیت جغرافیایی {companies.map((company) => ( {company.name} {company.description} {company.location} ))}
{title} اطلاعات یک شرکت جدید را در سامانه ثبت کنید.
{ e.preventDefault(); setOpen(false); }} > {FIELDS.map((field, i) => { const isCombobox = field.type === "combobox"; const isTags = field.type === "tags"; return (
{isCombobox && field.options ? ( handleInputChange(field.name, value) } options={field.options} placeholder={field.placeholder} searchPlaceholder={field.searchPlaceholder} emptyMessage={field.emptyMessage} required={field.required} /> ) : isTags && field.options ? ( handleInputChange(field.name, value) } options={field.options} searchPlaceholder={field.searchPlaceholder} emptyMessage={field.emptyMessage} required={field.required} /> ) : ( handleInputChange(field.name, e.target.value) } required={field.required} className="bg-background" /> )}
); })}
); }; export { CompaniesCreate3 };