From 8f9f16179495af50ec8b0bdd90b5742c298a7253 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 30 Mar 2026 20:59:25 +0200 Subject: [PATCH] Clientes --- modules/customers/src/common/locales/en.json | 13 ++- modules/customers/src/common/locales/es.json | 17 ++- .../use-customer-grid-columns.tsx | 108 +++++++++--------- .../web/list/ui/components/address-cell.tsx | 35 ++++-- .../web/list/ui/components/contact-cell.tsx | 23 ++-- .../web/list/ui/pages/list-customers-page.tsx | 12 +- 6 files changed, 126 insertions(+), 82 deletions(-) diff --git a/modules/customers/src/common/locales/en.json b/modules/customers/src/common/locales/en.json index bf0e0bc5..9579c12c 100644 --- a/modules/customers/src/common/locales/en.json +++ b/modules/customers/src/common/locales/en.json @@ -21,13 +21,21 @@ "description": "Manage your customers", "list": { "title": "Customer list", - "description": "List all customers", + "description": "Manage your customers and their contact information", "grid_columns": { "customer": "Customer", "status": "Status", "contact": "Contact", "address": "Address", "actions": "Actions" + }, + "actions": { + "more": "More", + "view": "View", + "edit": "Edit customer", + "delete": "Delete customer", + "visit_website": "Visit website", + "copy_email": "Copy email" } }, "create": { @@ -192,6 +200,9 @@ "no_entities_found": "No results found for \"{{search}}\"", "select_or_create": "Select an item from the list or create a new one.", "create_label": "Create new item" + }, + "address_cell": { + "open_in_google_maps": "Open address in Google Maps" } } } \ No newline at end of file diff --git a/modules/customers/src/common/locales/es.json b/modules/customers/src/common/locales/es.json index d6c9ff25..8921b099 100644 --- a/modules/customers/src/common/locales/es.json +++ b/modules/customers/src/common/locales/es.json @@ -21,13 +21,21 @@ "description": "Gestiona tus clientes", "list": { "title": "Lista de clientes", - "description": "Lista todos los clientes", + "description": "Gestiona la información de tus clientes y sus datos de contacto", "grid_columns": { "customer": "Cliente", "status": "Estado", "contact": "Contacto", "address": "Dirección", "actions": "Acciones" + }, + "actions": { + "more": "Más", + "view": "Ver", + "edit": "Editar cliente", + "delete": "Eliminar cliente", + "visit_website": "Visitar sitio web", + "copy_email": "Copiar email" } }, "create": { @@ -53,8 +61,8 @@ "customer_type": { "label": "Este cliente es...", "description": "Seleccione el tipo de cliente", - "company": "una empresa", - "individual": "una persona" + "company": "Empresa", + "individual": "Particular" }, "name": { "label": "Nombre", @@ -194,6 +202,9 @@ "no_entities_found": "No se encontraron resultados para \"{{search}}\"", "select_or_create": "Seleccione un elemento de la lista o cree uno nuevo.", "create_label": "Crear nuevo elemento" + }, + "address_cell": { + "open_in_google_maps": "Abrir dirección en Google Maps" } } } \ No newline at end of file diff --git a/modules/customers/src/web/list/ui/blocks/customers-grid/use-customer-grid-columns.tsx b/modules/customers/src/web/list/ui/blocks/customers-grid/use-customer-grid-columns.tsx index 7d55508a..d9216d50 100644 --- a/modules/customers/src/web/list/ui/blocks/customers-grid/use-customer-grid-columns.tsx +++ b/modules/customers/src/web/list/ui/blocks/customers-grid/use-customer-grid-columns.tsx @@ -40,7 +40,7 @@ export function useCustomersGridColumns( ), accessorFn: (row) => row.name, @@ -51,45 +51,53 @@ export function useCustomersGridColumns( const customer = row.original; return ( -
- - - - - + ); }, }, @@ -99,11 +107,12 @@ export function useCustomersGridColumns( ), accessorFn: (row) => `${row.email_primary} ${row.phone_primary} ${row.mobile_primary} ${row.website}`, + enableSorting: false, size: 140, minSize: 120, cell: ({ row }) => , @@ -114,11 +123,12 @@ export function useCustomersGridColumns( ), accessorFn: (row) => `${row.street} ${row.street2} ${row.city} ${row.postal_code} ${row.province} ${row.country}`, + enableSorting: false, size: 140, minSize: 120, cell: ({ row }) => , @@ -129,7 +139,7 @@ export function useCustomersGridColumns( ), size: 64, @@ -144,7 +154,7 @@ export function useCustomersGridColumns(
- {t("pages.customers.list.actions.label")} + {t("pages.list.grid_columns.actions")} onViewClick?.(customer)}> - {t("pages.customers.list.actions.open")} + {t("pages.list.actions.view")} onEditClick?.(customer)}> - {t("pages.customers.list.actions.edit")} + {t("pages.list.actions.edit")} @@ -184,14 +190,14 @@ export function useCustomersGridColumns( window.open(safeHTTPUrl(website), "_blank", "noopener,noreferrer") } > - {t("pages.customers.list.actions.visitWebsite")} + {t("pages.list.actions.visit_website")} navigator.clipboard.writeText(email_primary)} > - {t("pages.customers.list.actions.copyEmail")} + {t("pages.list.actions.copy_email")} @@ -200,7 +206,7 @@ export function useCustomersGridColumns( className="text-destructive" onClick={() => onDeleteClick?.(customer)} > - {t("pages.customers.list.actions.delete")} + {t("pages.list.actions.delete")} diff --git a/modules/customers/src/web/list/ui/components/address-cell.tsx b/modules/customers/src/web/list/ui/components/address-cell.tsx index 7f2bfbd3..2408526f 100644 --- a/modules/customers/src/web/list/ui/components/address-cell.tsx +++ b/modules/customers/src/web/list/ui/components/address-cell.tsx @@ -1,19 +1,36 @@ -import type { CustomerListRow } from "@erp/customers/web/shared"; import { MapPinIcon } from "lucide-react"; +import { useTranslation } from "../../../i18n"; +import type { CustomerListRow } from "../../../shared"; + +const getGoogleMapsUrl = (customer: CustomerListRow) => { + const fullAddress = `${customer.street}, ${customer.postal_code} ${customer.city}, ${customer.province}, ${customer.country}`; + return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(fullAddress)}`; +}; + export const AddressCell = ({ customer }: { customer: CustomerListRow }) => { + const { t } = useTranslation(); const line1 = [customer.street, customer.street2].filter(Boolean).join(", "); const line2 = [customer.postal_code, customer.city].filter(Boolean).join(" "); const line3 = [customer.province, customer.country].filter(Boolean).join(", "); return ( -
- -
-

{line1}

-

- {line2} · {line3} -

-
+
+ + +
+

{line1}

+

+ {line2} · {line3} +

+
+
); }; diff --git a/modules/customers/src/web/list/ui/components/contact-cell.tsx b/modules/customers/src/web/list/ui/components/contact-cell.tsx index 7df96143..779ddc8b 100644 --- a/modules/customers/src/web/list/ui/components/contact-cell.tsx +++ b/modules/customers/src/web/list/ui/components/contact-cell.tsx @@ -3,13 +3,16 @@ import { MailIcon, PhoneIcon } from "lucide-react"; export const ContactCell = ({ customer }: { customer: CustomerListRow }) => (
- - - {customer.email_primary} - + {customer.email_primary && ( + + + {customer.email_primary} + + )} + {customer.email_secondary && ( ( {customer.email_secondary} )} - {customer.phone_primary ? ( + {customer.phone_primary && ( ( {customer.phone_primary} - ) : ( - - - - )}
); diff --git a/modules/customers/src/web/list/ui/pages/list-customers-page.tsx b/modules/customers/src/web/list/ui/pages/list-customers-page.tsx index 569d4196..4acba309 100644 --- a/modules/customers/src/web/list/ui/pages/list-customers-page.tsx +++ b/modules/customers/src/web/list/ui/pages/list-customers-page.tsx @@ -25,8 +25,8 @@ export const ListCustomersPage = () => { return ( @@ -37,17 +37,17 @@ export const ListCustomersPage = () => { <> navigate("/customers/create")} > - {t("pages.customers.create.title")} + {t("pages.create.title")} } - title={t("pages.customers.list.title")} + title={t("pages.list.title")} />