"use client"; import { generateUUIDv4 } from "@repo/rdx-utils"; import { Badge, Button, Card, CardContent, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, Separator, } from "@repo/shadcn-ui/components"; import { Building, Calendar, Edit, Mail, MapPin, Phone, Plus, Search, Trash2, User, } from "lucide-react"; import { useState } from "react"; const mockCustomers = [ { id: "a1d2e3f4-5678-90ab-cdef-1234567890ab", name: "Juan Pérez", email: "juan@email.com", phone: "+34 600 123 456", company: "Tech Corp", address: "Calle Mayor 123, Madrid", createdAt: "2024-01-15", status: "Activo", }, { id: "b1d2e3f4-5678-90ab-cdef-1234567890ab", name: "María García", email: "maria@email.com", phone: "+34 600 789 012", company: "Design Studio", address: "Av. Diagonal 456, Barcelona", createdAt: "2024-02-20", status: "Activo", }, { id: "c1d2e3f4-5678-90ab-cdef-1234567890ab", name: "Carlos López", email: "carlos@email.com", phone: "+34 600 345 678", company: "Marketing Plus", address: "Gran Vía 789, Valencia", createdAt: "2024-01-30", status: "Inactivo", }, { id: "d1d2e3f4-5678-90ab-cdef-1234567890ab", name: "Ana Martínez", email: "ana@email.com", phone: "+34 600 901 234", company: "Consulting Group", address: "Calle Sierpes 321, Sevilla", createdAt: "2024-03-10", status: "Activo", }, ]; export const ClientSelector = () => { const [open, setOpen] = useState(false); const [selectedCustomer, setSelectedCustomer] = useState(null); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [isDetailsModalOpen, setIsDetailsModalOpen] = useState(false); const [searchValue, setSearchValue] = useState(""); const [newCustomer, setNewCustomer] = useState({ name: "", email: "", phone: "", company: "", address: "", }); const handleCreateCustomer = (e) => { e.preventDefault(); const createdCustomer = { id: generateUUIDv4(), ...newCustomer, createdAt: new Date().toISOString().split("T")[0], status: "Activo", }; console.log("Cliente creado:", createdCustomer); setSelectedCustomer(createdCustomer); setIsCreateModalOpen(false); setNewCustomer({ name: "", email: "", phone: "", company: "", address: "" }); }; const handleEditCustomer = () => { console.log("Editar cliente:", selectedCustomer); setIsDetailsModalOpen(false); }; const handleDeleteCustomer = () => { console.log("Eliminar cliente:", selectedCustomer); setSelectedCustomer(null); setIsDetailsModalOpen(false); }; const handleSelectCustomer = (customer) => { console.log("Seleccionar cliente:", customer); setSelectedCustomer(customer); setOpen(false); }; return (

No se encontró ningún cliente con "{searchValue}"

{mockCustomers.map((customer) => ( handleSelectCustomer(customer)} className='flex items-center space-x-3 p-3' >

{customer.name}

{customer.status}
{customer.company} {customer.email}
))}
{ setIsCreateModalOpen(true); setOpen(false); }} className='flex items-center space-x-3 p-3 text-primary' > Crear nuevo cliente
{selectedCustomer && (

{selectedCustomer.name}

{selectedCustomer.status}

{selectedCustomer.company}

)} Crear Nuevo Cliente Completa la información del nuevo cliente
setNewCustomer({ ...newCustomer, name: e.target.value })} placeholder='Nombre completo' />
setNewCustomer({ ...newCustomer, company: e.target.value })} placeholder='Nombre de la empresa' />
setNewCustomer({ ...newCustomer, email: e.target.value })} placeholder='correo@ejemplo.com' />
setNewCustomer({ ...newCustomer, phone: e.target.value })} placeholder='+34 600 000 000' />
setNewCustomer({ ...newCustomer, address: e.target.value })} placeholder='Dirección completa' />
Detalles del Cliente {selectedCustomer && (

{selectedCustomer.name}

{selectedCustomer.company}

{selectedCustomer.status}

{selectedCustomer.email}

{selectedCustomer.phone}

{selectedCustomer.address}

{new Date(selectedCustomer.createdAt).toLocaleDateString("es-ES")}

)}
); };