import { PageHeader } from "@erp/core/components"; import { useUrlParamId } from "@erp/core/hooks"; import { AppContent, AppHeader, BackHistoryButton } from "@repo/rdx-ui/components"; import { Badge, Button, Card, CardContent, CardHeader, CardTitle, } from "@repo/shadcn-ui/components"; import { Banknote, EditIcon, FileText, Globe, Languages, Mail, MapPin, MoreVertical, Phone, Smartphone, } from "lucide-react"; import { useNavigate } from "react-router-dom"; import { CustomerEditorSkeleton, ErrorAlert } from "../../components"; import { useCustomerQuery } from "../../hooks"; import { useTranslation } from "../../i18n"; export const CustomerViewPage = () => { const customerId = useUrlParamId(); const { t } = useTranslation(); const navigate = useNavigate(); // 1) Estado de carga del cliente (query) const { data: customer, isLoading: isLoadingCustomer, isError: isLoadError, error: loadError, } = useCustomerQuery(customerId, { enabled: !!customerId }); if (isLoadingCustomer) { return ; } if (isLoadError) { return ( <>
); } return ( <> {customer?.name}{" "} {customer?.trade_name && ( ({customer.trade_name}) )} } description={
{customer?.tin} {customer?.is_company ? "Empresa" : "Persona"}
} rightSlot={
} />
{/* Main Content Grid */}
{/* Información Básica */} Información Básica
Nombre
{customer?.name}
Referencia
{customer?.reference}
Registro Legal
{customer?.legal_record}
Impuestos por Defecto
{customer?.default_taxes.map((tax) => ( {tax} ))}
{/* Dirección */} Dirección
Calle
{customer?.street} {customer?.street2 && ( <>
{customer?.street2} )}
Ciudad
{customer?.city}
Código Postal
{customer?.postal_code}
Provincia
{customer?.province}
País
{customer?.country}
{/* Información de Contacto */} Información de Contacto
{/* Contacto Principal */}

Contacto Principal

{customer?.email_primary && (
Email
{customer?.email_primary}
)} {customer?.mobile_primary && (
Móvil
{customer?.mobile_primary}
)} {customer?.phone_primary && (
Teléfono
{customer?.phone_primary}
)}
{/* Contacto Secundario */}

Contacto Secundario

{customer?.email_secondary && (
Email
{customer?.email_secondary}
)} {customer?.mobile_secondary && (
Móvil
{customer?.mobile_secondary}
)} {customer?.phone_secondary && (
Teléfono
{customer?.phone_secondary}
)}
{/* Otros Contactos */} {(customer?.website || customer?.fax) && (

Otros

{customer?.website && ( )} {customer?.fax && (
Fax
{customer?.fax}
)}
)}
{/* Preferencias */} Preferencias
Idioma Preferido
{customer?.language_code}
Moneda Preferida
{customer?.currency_code}
); };