From 58eede59af156758b34005e5a8ee9e846d85ec4f Mon Sep 17 00:00:00 2001 From: david Date: Wed, 1 Oct 2025 11:57:08 +0200 Subject: [PATCH] Facturas de cliente --- ...og.tsx => create-customer-form-dialog.tsx} | 0 .../customer-modal-selector/customer-card.tsx | 128 ++++++++++++++---- .../customer-empty-card.tsx | 34 +++-- .../customer-modal-selector.tsx | 26 ++-- .../customer-search-dialog.tsx | 9 +- packages/shadcn-ui/src/styles/globals.css | 8 +- 6 files changed, 141 insertions(+), 64 deletions(-) rename modules/customers/src/web/components/customer-modal-selector/{customer-form-dialog.tsx => create-customer-form-dialog.tsx} (100%) diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-form-dialog.tsx b/modules/customers/src/web/components/customer-modal-selector/create-customer-form-dialog.tsx similarity index 100% rename from modules/customers/src/web/components/customer-modal-selector/customer-form-dialog.tsx rename to modules/customers/src/web/components/customer-modal-selector/create-customer-form-dialog.tsx diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-card.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-card.tsx index 54d21f58..10db8a9c 100644 --- a/modules/customers/src/web/components/customer-modal-selector/customer-card.tsx +++ b/modules/customers/src/web/components/customer-modal-selector/customer-card.tsx @@ -1,46 +1,114 @@ -import { Building2Icon, FileTextIcon, Mail, Phone, User } from "lucide-react"; +import { Button, Separator } from "@repo/shadcn-ui/components"; +import { + CreditCard, + EyeIcon, + MapPinHouseIcon, + RefreshCwIcon, + UserIcon, + UserPlusIcon, +} from "lucide-react"; import { CustomerSummary } from "../../schemas"; interface CustomerCardProps { customer: CustomerSummary; + + onViewCustomer?: () => void; + onChangeCustomer?: () => void; + onAddNewCustomer?: () => void; } -export const CustomerCard = ({ customer }: CustomerCardProps) => { +export const CustomerCard = ({ + customer, + onViewCustomer, + onChangeCustomer, + onAddNewCustomer, +}: CustomerCardProps) => { + const hasAddress = + customer.street || + customer.street2 || + customer.city || + customer.postal_code || + customer.province || + customer.country; + return ( -
-
- -
-
-

{customer.name}

-
- {customer.email_primary && ( -
- - {customer.email_primary} +
+
+ {/* Avatar mejorado con gradiente sutil */} +
+ +
+ +
+ {/* Nombre del cliente */} +

+ {customer.name} +

+ + {/* NIF/CIF con icono */} + {customer.tin && ( +
+ + {customer.tin}
)} - {customer.mobile_primary && ( -
- - {customer.mobile_primary} -
- )} - {customer.trade_name && ( -
- - {customer.trade_name} -
- )} - {customer.tin && ( -
- - {customer.tin} + {/* Separador si hay dirección */} + {hasAddress && } + + {/* Dirección con mejor estructura */} + {hasAddress && ( +
+
+ +
+ {customer.street &&
{customer.street}
} + {customer.street2 &&
{customer.street2}
} +
+ {customer.postal_code && {customer.postal_code}} + {customer.city && {customer.city}} +
+
+ {customer.province && {customer.province}} + {customer.country && {customer.country}} +
+
+
)}
-
+ + +
+ + + +
+
); }; diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-empty-card.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-empty-card.tsx index 44824592..33929706 100644 --- a/modules/customers/src/web/components/customer-modal-selector/customer-empty-card.tsx +++ b/modules/customers/src/web/components/customer-modal-selector/customer-empty-card.tsx @@ -1,19 +1,27 @@ import { UserSearchIcon } from "lucide-react"; -export const CustomerEmptyCard = () => { +export const CustomerEmptyCard = (props: React.ComponentProps<"button">) => { return ( -
-
- +
+ ); }; diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector.tsx index e28b859f..1b0b4ef1 100644 --- a/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector.tsx +++ b/modules/customers/src/web/components/customer-modal-selector/customer-modal-selector.tsx @@ -1,9 +1,9 @@ import { useEffect, useMemo, useState } from "react"; import { useCustomersSearchQuery } from "../../hooks"; import { CustomerSummary, defaultCustomerFormData } from "../../schemas"; +import { CreateCustomerFormDialog } from "./create-customer-form-dialog"; import { CustomerCard } from "./customer-card"; import { CustomerEmptyCard } from "./customer-empty-card"; -import { CreateCustomerFormDialog } from "./customer-form-dialog"; import { CustomerSearchDialog } from "./customer-search-dialog"; // Debounce pequeño y tipado @@ -75,16 +75,16 @@ export const CustomerModalSelector = ({ value, onValueChange }: CustomerModalSel return ( <> - +
+ {selected ? ( + setShowSearch(true)} /> + ) : ( + setShowSearch(true)} + onKeyDown={(e) => (e.key === "Enter" || e.key === " ") && setShowSearch(true)} + /> + )} +
{ - /*setNewClient({ name: name ?? "", email: "" }); - setShowForm(true);*/ + setNewClient({ name: name ?? "", email: "" }); + setShowForm(true); }} isLoading={isLoading} isError={isError} diff --git a/modules/customers/src/web/components/customer-modal-selector/customer-search-dialog.tsx b/modules/customers/src/web/components/customer-modal-selector/customer-search-dialog.tsx index 251bad6c..b3c1f176 100644 --- a/modules/customers/src/web/components/customer-modal-selector/customer-search-dialog.tsx +++ b/modules/customers/src/web/components/customer-modal-selector/customer-search-dialog.tsx @@ -16,8 +16,8 @@ import { } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { - AsteriskIcon, Check, + CreditCardIcon, MailIcon, SmartphoneIcon, User, @@ -122,9 +122,10 @@ export const CustomerSearchDialog = ({
{customer.tin && ( - - {customer.tin} - +
+ + {customer.tin} +
)} {customer.email_primary && ( diff --git a/packages/shadcn-ui/src/styles/globals.css b/packages/shadcn-ui/src/styles/globals.css index 5a5d80e4..62005f3b 100644 --- a/packages/shadcn-ui/src/styles/globals.css +++ b/packages/shadcn-ui/src/styles/globals.css @@ -56,8 +56,8 @@ --secondary-foreground: oklch(0.2069 0.0098 285.5081); --muted: oklch(0.9674 0.0013 286.3752); --muted-foreground: oklch(0.5466 0.0216 285.664); - --accent: oklch(0.9674 0.0013 286.3752); - --accent-foreground: oklch(0.2069 0.0098 285.5081); + --accent: oklch(0.9299 0.0334 272.7879); + --accent-foreground: oklch(0.3729 0.0306 259.7328); --destructive: oklch(0.583 0.2387 28.4765); --destructive-foreground: oklch(1.0 0 0); --border: oklch(0.9173 0.0067 286.2663); @@ -102,8 +102,8 @@ --secondary-foreground: oklch(0.9851 0 0); --muted: oklch(0.2686 0 0); --muted-foreground: oklch(0.709 0 0); - --accent: oklch(0.2686 0 0); - --accent-foreground: oklch(0.9851 0 0); + --accent: oklch(0.3729 0.0306 259.7328); + --accent-foreground: oklch(0.8717 0.0093 258.3382); --destructive: oklch(0.7022 0.1892 22.2279); --destructive-foreground: oklch(0.2558 0.0412 235.1561); --border: oklch(1.0 0 0);