From 5ea58539529f94b20f3ece2d0420524f39481b2f Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Wed, 11 Nov 2026 15:45:19 -0600 Subject: [PATCH 01/17] =?UTF-8?q?Redise=C3=B1a=20la=20navegaci=C3=B3n=20co?= =?UTF-8?q?n=20el=20sidebar=20inset=20de=20shadcn=20y=20agrupa=20Ventas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reemplaza el sidebar propio por el de shadcn (variant inset, collapsible icon) con logo, menú colapsable Ventas (Clientes, Sucursales, Contactos) y menú de usuario con cierre de sesión. Unifica el encabezado de las páginas en PageHeader, agrega la sección al breadcrumb, cambia el dashboard por accesos rápidos y hace que las pestañas del detalle de cliente se desplacen en móvil. --- apps/web/public/suni-logo.png | Bin 0 -> 27837 bytes apps/web/src/components/app-sidebar.tsx | 50 +- .../web/src/components/dynamic-breadcrumb.tsx | 64 +- apps/web/src/components/nav-bar.tsx | 170 +++- apps/web/src/components/nav-items.ts | 43 ++ apps/web/src/components/nav-user.tsx | 115 +++ apps/web/src/components/page-header.tsx | 33 + apps/web/src/routes/_auth/branches/index.tsx | 25 +- apps/web/src/routes/_auth/contacts/index.tsx | 25 +- .../$customerId/branches/$branchId/index.tsx | 4 +- .../_auth/customers/$customerId/edit.tsx | 25 +- .../_auth/customers/$customerId/index.tsx | 23 +- apps/web/src/routes/_auth/customers/index.tsx | 25 +- apps/web/src/routes/_auth/customers/new.tsx | 21 +- apps/web/src/routes/_auth/dashboard.tsx | 68 +- apps/web/src/routes/_auth/route.tsx | 35 +- .../src/routes/_auth/users/$userId/edit.tsx | 25 +- apps/web/src/routes/_auth/users/index.tsx | 25 +- apps/web/src/routes/_auth/users/new.tsx | 21 +- packages/ui/src/components/avatar.tsx | 108 +++ packages/ui/src/components/collapsible.tsx | 19 + packages/ui/src/components/separator.tsx | 22 + packages/ui/src/components/sheet.tsx | 136 ++++ packages/ui/src/components/sidebar.tsx | 730 ++++++++++++++---- packages/ui/src/hooks/use-mobile.ts | 19 + packages/ui/src/styles/globals.css | 12 +- 26 files changed, 1487 insertions(+), 356 deletions(-) create mode 100644 apps/web/public/suni-logo.png create mode 100644 apps/web/src/components/nav-items.ts create mode 100644 apps/web/src/components/nav-user.tsx create mode 100644 apps/web/src/components/page-header.tsx create mode 100644 packages/ui/src/components/avatar.tsx create mode 100644 packages/ui/src/components/collapsible.tsx create mode 100644 packages/ui/src/components/separator.tsx create mode 100644 packages/ui/src/components/sheet.tsx create mode 100644 packages/ui/src/hooks/use-mobile.ts diff --git a/apps/web/public/suni-logo.png b/apps/web/public/suni-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..3c5c27d06994bc99a579a5577aa3dcfe3c15b2eb GIT binary patch literal 27837 zcmV)dK&QWnP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR92BA^2R1ONa40RR91O8@`>0C@@mi2wjV07*naRCodGy$fI-Rhj=kGw&@) zlQwCZwzO$!OWFd3(kr#~)~d*YBCc*Li{iqnMM1i{y6bPfC0%z{*Bb&NS`|UTOS4{4 zSXi~uRiMxtU`wx1dZTU9ByHLz?``Jy`JS11Gw++E4Fz`p|DQR@yfbqy&pGEg=RD_m zp7WeDw)Ou5=XsuOU35`}mCtAG&6_h}k-Zr+lGgd>=dCSU%8&QND%^B-gk?L`j+d{< z*?G@$oR|}j@6Fk;~^F`~*n5ltV$IrZJMJ+E&J+p>#2OI~{e`$-%GdI1cQnn9st!ulwnfigXPwx(7hN!6cV5i zmbH4dV}0#wwg`~j+?+o;arz23=YGj^@>h=B_sso;cta0E73i7|?)H z|BrG!dX}GhubkqPafu-5DvTGN&&Y-B))^&!xf69vp86Uu=iHEYvu|dY4+9M@_i)6! z4BbrL_izYPUGyeGbC7En@B4V)=h^wTm}hr-ww(imJ+9?-6JBP=>``_;UlofvlihrN z;*s{u+OoTvA0{2?4c5cF^xDUrj`)NL3PcDGr3qUz5^jjl;X|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Ak{|XVThB_2me7FWns?Kn5_sXf)n&58mVr}+=O#0pCIb}Haa zEM$peQh^(1A$|CSgjmri@56N3>YOI-kryfb6GVHP6~7@m(nCW--_5zW%UcathG9Oy zSn*oJ&M=nwytLFVfDRa4G-g|fL{TGz!AYwMz7=y-zsCLBpPs% zPHKB9k^0lDKt!eDN8dN#X?P~?MCXrh*zk+H5f}M7f%lN@>L9LO`Tn`~o4uX;_dkDG z8=AG35E!lW57E$UN+&g3o|{5_cp`0I?^XRljh9`;S0g`oqZsU!% zOz8v7`^0@kG=y?NqF46*#*NKqkDpzU$)>i0{9o0?s}hn)rQw1#worE~9-J7^*Hg^9 z2(ekF_Ycx*eW!Eu{UeD@o3e>FSxsA@hFLFeH7W-P0)t>#H*mdf-EUewFZW4(G54eG z7F{H;lcd#o!b4oieQwpNn-kONwX8Qk3rqY3CY0}D>}$@n5&;K< zkP_fylZcuX4MLy*&;)?Pgo`F<>39KC8`B#&?rHM8ovo*joq-+k61#UV(J>*e;0V$} z;xDX_amuc*Uiso0Q*}&ZV_gu{LqS0NE9Cu?Z7uttKEFU7 z$2p{0E}fZG4h@soyJcpYO9>B^cW&yvt+7{Iy1AaXIUG^$r9G<|;jcr=?g@_VdXSZv zwFu`?7m_~52^KP36U_=#y1-%Z^2+>>5GDd47aZ=<(t{a;#$18torPn6nL|!~*M9Q& zyXH?fu<&A8h|0V9f_6jwlNx9kkJ9RGzPbHFuf$j zVLwf;YSmD*e)!5O&AKRCK8o;W!f0V(l;$=Jy4xe zCtg*zsy-t!>JS#$&!wpsZs1Q%DrhBhh0~aQT_6H}W~Z>Rc<1F?%kmR%9(s%+)fct; zLB_14m=Hen87E5ElFVY9r?KSyJI3W@4F5##J+KU5n))C_l&OtXxcFH9wx zTU*cPCnrZU>C9R07*qoM6N<$f|IJlQ2+n{ literal 0 HcmV?d00001 diff --git a/apps/web/src/components/app-sidebar.tsx b/apps/web/src/components/app-sidebar.tsx index 1026c98..7339844 100644 --- a/apps/web/src/components/app-sidebar.tsx +++ b/apps/web/src/components/app-sidebar.tsx @@ -3,25 +3,63 @@ import { SidebarContent, SidebarFooter, SidebarHeader, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + SidebarRail, + useSidebar, } from "@suni/ui/components/sidebar"; +import { Link, useRouter } from "@tanstack/react-router"; +import { useEffect } from "react"; import type { ComponentProps } from "react"; import { NavMain } from "@/components/nav-bar"; +import { NavUser } from "@/components/nav-user"; export function AppSidebar(props: ComponentProps) { + const router = useRouter(); + const { setOpenMobile } = useSidebar(); + + // On mobile the menu is a sheet over the page; close it once a link navigates. + useEffect( + () => router.subscribe("onBeforeNavigate", () => setOpenMobile(false)), + [router, setOpenMobile] + ); + return ( - + -
Suni
+ + + } + > + + + } + tooltip="Suni" + > + S + + +
-
- -
+
-
Footer
+
+
); } diff --git a/apps/web/src/components/dynamic-breadcrumb.tsx b/apps/web/src/components/dynamic-breadcrumb.tsx index 5f0cd82..c95cbe3 100644 --- a/apps/web/src/components/dynamic-breadcrumb.tsx +++ b/apps/web/src/components/dynamic-breadcrumb.tsx @@ -10,6 +10,8 @@ import type { LinkProps } from "@tanstack/react-router"; import { Link, useRouterState } from "@tanstack/react-router"; import { Fragment } from "react"; +import { NAV_ENTRIES, isSection } from "@/components/nav-items"; + const SEGMENT_LABELS = { dashboard: "Inicio", users: "Usuarios", @@ -17,16 +19,31 @@ const SEGMENT_LABELS = { edit: "Editar", customers: "Clientes", branches: "Sucursales", + contacts: "Contactos", } satisfies Record; type KnownSegment = keyof typeof SEGMENT_LABELS; +// Only these segments name a page when nested; others (like a customer's branches) have no route of their own. +const NESTED_SEGMENTS = new Set(["new", "edit"]); + +const SECTION_BY_PATH = new Map(); + +for (const entry of NAV_ENTRIES) { + if (isSection(entry)) { + for (const item of entry.items) { + SECTION_BY_PATH.set(item.to, entry.label); + } + } +} + function isKnownSegment(segment: string): segment is KnownSegment { return Object.hasOwn(SEGMENT_LABELS, segment); } interface Crumb { - path: LinkProps["to"]; + // A section like "Ventas" groups pages in the sidebar but has no page itself. + path?: LinkProps["to"]; label: string; } @@ -37,12 +54,17 @@ function getCrumbs(pathname: string): Crumb[] { { path: "/dashboard", label: SEGMENT_LABELS.dashboard }, ]; + const section = SECTION_BY_PATH.get(`/${segments[0]}`); + + if (section) { + crumbs.push({ label: section }); + } + for (const [index, segment] of segments.entries()) { - if (segment === "dashboard" && index === 0) { - continue; - } + const named = + index === 0 ? segment !== "dashboard" : NESTED_SEGMENTS.has(segment); - if (isKnownSegment(segment)) { + if (named && isKnownSegment(segment)) { crumbs.push({ // SAFETY: solo los segmentos listados en SEGMENT_LABELS llegan aquí path: `/${segments.slice(0, index + 1).join("/")}` as LinkProps["to"], @@ -54,6 +76,28 @@ function getCrumbs(pathname: string): Crumb[] { return crumbs; } +function CrumbLabel({ + crumb, + isCurrent, +}: { + crumb: Crumb; + isCurrent: boolean; +}) { + if (isCurrent) { + return {crumb.label}; + } + + if (!crumb.path) { + return {crumb.label}; + } + + return ( + }> + {crumb.label} + + ); +} + export function DynamicBreadcrumb() { const pathname = useRouterState({ select: (s) => s.location.pathname }); const crumbs = getCrumbs(pathname); @@ -62,16 +106,10 @@ export function DynamicBreadcrumb() { {crumbs.map((crumb, index) => ( - + {index > 0 && } - {index === crumbs.length - 1 ? ( - {crumb.label} - ) : ( - }> - {crumb.label} - - )} + ))} diff --git a/apps/web/src/components/nav-bar.tsx b/apps/web/src/components/nav-bar.tsx index cb1f414..4f87507 100644 --- a/apps/web/src/components/nav-bar.tsx +++ b/apps/web/src/components/nav-bar.tsx @@ -1,53 +1,145 @@ -import { SidebarMenu, SidebarMenuItem } from "@suni/ui/components/sidebar"; -import { cn } from "@suni/ui/lib/utils"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@suni/ui/components/collapsible"; +import { + SidebarGroup, + SidebarGroupLabel, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + SidebarMenuSub, + SidebarMenuSubButton, + SidebarMenuSubItem, + useSidebar, +} from "@suni/ui/components/sidebar"; import { Link, useRouterState } from "@tanstack/react-router"; -import type { LinkProps } from "@tanstack/react-router"; -import type { LucideIcon } from "lucide-react"; -import { Building2, Contact, ContactRound, Home, Users } from "lucide-react"; +import { ChevronRight } from "lucide-react"; +import { useState } from "react"; +import { NAV_ENTRIES, isSection } from "@/components/nav-items"; +import type { NavLink, NavSection } from "@/components/nav-items"; import { useIsAdmin } from "@/hooks/use-is-admin"; -interface NavItem { - to: NonNullable; - label: string; - icon: LucideIcon; - adminOnly?: true; +function isActive(pathname: string, to: string) { + return pathname === to || pathname.startsWith(`${to}/`); } -const NAV_ITEMS = [ - { to: "/dashboard", label: "Inicio", icon: Home }, - { to: "/users", label: "Usuarios", icon: Users, adminOnly: true }, - { to: "/customers", label: "Clientes", icon: ContactRound }, - { to: "/branches", label: "Sucursales", icon: Building2 }, - { to: "/contacts", label: "Contactos", icon: Contact }, -] satisfies NavItem[]; +interface NavSectionItemProps { + section: NavSection; + items: NavLink[]; + pathname: string; +} + +function NavSectionItem({ section, items, pathname }: NavSectionItemProps) { + const { isMobile, state, setOpen: setSidebarOpen } = useSidebar(); + const active = items.some((item) => isActive(pathname, item.to)); + const [open, setOpen] = useState(active); + const [wasActive, setWasActive] = useState(active); + + // Entering one of its pages opens the section; leaving keeps whatever the user chose. + if (active !== wasActive) { + setWasActive(active); + + if (active) { + setOpen(true); + } + } + + function handleOpenChange(next: boolean) { + // Sub-items are hidden while collapsed to icons, so expand the sidebar and the section together. + if (!isMobile && state === "collapsed") { + setSidebarOpen(true); + setOpen(true); + + return; + } + + setOpen(next); + } + + const { label, icon: Icon } = section; + + return ( + } + > + } + > + + {label} + + + + + {items.map((item) => ( + + } + > + {item.label} + + + ))} + + + + ); +} export function NavMain() { const pathname = useRouterState({ select: (s) => s.location.pathname }); const isAdmin = useIsAdmin(); - const items = NAV_ITEMS.filter((item) => isAdmin || !("adminOnly" in item)); + const canSee = (link: NavLink) => isAdmin || !link.adminOnly; return ( - - {items.map(({ to, label, icon: Icon }) => { - const active = pathname.startsWith(to); - - return ( - - - - {label} - - - ); - })} - + + Módulos + + {NAV_ENTRIES.map((entry) => { + if (!isSection(entry)) { + if (!canSee(entry)) { + return null; + } + + const { to, label, icon: Icon } = entry; + + return ( + + } + tooltip={label} + > + + {label} + + + ); + } + + const items = entry.items.filter(canSee); + + if (items.length === 0) { + return null; + } + + return ( + + ); + })} + + ); } diff --git a/apps/web/src/components/nav-items.ts b/apps/web/src/components/nav-items.ts new file mode 100644 index 0000000..f0c90e5 --- /dev/null +++ b/apps/web/src/components/nav-items.ts @@ -0,0 +1,43 @@ +import type { LinkProps } from "@tanstack/react-router"; +import type { LucideIcon } from "lucide-react"; +import { + Building2, + Contact, + ContactRound, + DollarSign, + Home, + Users, +} from "lucide-react"; + +export interface NavLink { + to: NonNullable; + label: string; + icon: LucideIcon; + adminOnly?: true; +} + +export interface NavSection { + label: string; + icon: LucideIcon; + items: NavLink[]; +} + +type NavEntry = NavLink | NavSection; + +export const NAV_ENTRIES: NavEntry[] = [ + { to: "/dashboard", label: "Inicio", icon: Home }, + { to: "/users", label: "Usuarios", icon: Users, adminOnly: true }, + { + label: "Ventas", + icon: DollarSign, + items: [ + { to: "/customers", label: "Clientes", icon: ContactRound }, + { to: "/branches", label: "Sucursales", icon: Building2 }, + { to: "/contacts", label: "Contactos", icon: Contact }, + ], + }, +]; + +export function isSection(entry: NavEntry): entry is NavSection { + return "items" in entry; +} diff --git a/apps/web/src/components/nav-user.tsx b/apps/web/src/components/nav-user.tsx new file mode 100644 index 0000000..cb6955e --- /dev/null +++ b/apps/web/src/components/nav-user.tsx @@ -0,0 +1,115 @@ +import { + Avatar, + AvatarFallback, + AvatarImage, +} from "@suni/ui/components/avatar"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@suni/ui/components/dropdown-menu"; +import { + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + useSidebar, +} from "@suni/ui/components/sidebar"; +import { useQueryClient } from "@tanstack/react-query"; +import { useNavigate, useRouteContext } from "@tanstack/react-router"; +import { ChevronsUpDown, LogOut } from "lucide-react"; +import { toast } from "sonner"; + +import { authClient } from "@/lib/auth-client"; + +function initials(name: string) { + return name + .split(/\s+/u) + .filter(Boolean) + .slice(0, 2) + .map((word) => word[0]?.toUpperCase()) + .join(""); +} + +function UserIdentity({ + name, + email, + image, +}: { + name: string; + email: string; + image?: string | null; +}) { + return ( + <> + + {image ? : null} + {initials(name)} + +
+ {name} + {email} +
+ + ); +} + +export function NavUser() { + const user = useRouteContext({ + from: "/_auth", + select: (ctx) => ctx.session.user, + }); + + const { isMobile } = useSidebar(); + const navigate = useNavigate(); + const queryClient = useQueryClient(); + + async function signOut() { + const { error } = await authClient.signOut(); + + if (error) { + toast.error("No se pudo cerrar la sesión."); + + return; + } + + // Leave the page first so its queries don't refetch without a session. + await navigate({ to: "/" }); + queryClient.clear(); + } + + return ( + + + + }> + + + + + + +
+ +
+
+
+ + + + Cerrar sesión + +
+
+
+
+ ); +} diff --git a/apps/web/src/components/page-header.tsx b/apps/web/src/components/page-header.tsx new file mode 100644 index 0000000..7cd73bd --- /dev/null +++ b/apps/web/src/components/page-header.tsx @@ -0,0 +1,33 @@ +import type { LucideIcon } from "lucide-react"; +import type { ReactNode } from "react"; + +interface PageHeaderProps { + icon: LucideIcon; + title: string; + description: string; + actions?: ReactNode; +} + +export function PageHeader({ + icon: Icon, + title, + description, + actions, +}: PageHeaderProps) { + return ( +
+
+
+
+ +
+

{title}

+
+

{description}

+
+ {actions ? ( +
{actions}
+ ) : null} +
+ ); +} diff --git a/apps/web/src/routes/_auth/branches/index.tsx b/apps/web/src/routes/_auth/branches/index.tsx index 3a234be..f23c89d 100644 --- a/apps/web/src/routes/_auth/branches/index.tsx +++ b/apps/web/src/routes/_auth/branches/index.tsx @@ -5,6 +5,7 @@ import { z } from "zod"; import { BranchesList } from "@/components/customers/branches/grid"; import { NewEntityButton } from "@/components/customers/new-entity-button"; +import { PageHeader } from "@/components/page-header"; /* oxlint-disable promise/prefer-await-to-then, github/no-then -- zod `.catch()` is not Promise.catch */ const searchSchema = z.object({ @@ -25,23 +26,15 @@ function RouteComponent() { const navigate = Route.useNavigate(); return ( -
-
-
-
-
- -
-

Sucursales

-
-

- Gestiona las sucursales de los clientes -

-
-
+
+ -
-
+ } + /> -
-
-
-
- -
-

Contactos

-
-

- Gestiona los contactos de las sucursales -

-
-
+
+ -
-
+ } + /> ( -

- No se pudo cargar la sucursal. -

+

No se pudo cargar la sucursal.

), }); diff --git a/apps/web/src/routes/_auth/customers/$customerId/edit.tsx b/apps/web/src/routes/_auth/customers/$customerId/edit.tsx index afeacde..44246ee 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/edit.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/edit.tsx @@ -3,6 +3,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { SquareChartGantt } from "lucide-react"; import { CustomerForm } from "@/components/customers/customer-form"; +import { PageHeader } from "@/components/page-header"; import { orpc } from "@/utils/orpc"; export const Route = createFileRoute("/_auth/customers/$customerId/edit")({ @@ -12,9 +13,7 @@ export const Route = createFileRoute("/_auth/customers/$customerId/edit")({ ), component: RouteComponent, errorComponent: () => ( -

- No se pudo cargar el cliente. -

+

No se pudo cargar el cliente.

), }); @@ -27,20 +26,12 @@ function RouteComponent() { ); return ( -
-
-
-
-
- -
-

Editar Cliente

-
-

- Modifica la información del cliente -

-
-
+
+
diff --git a/apps/web/src/routes/_auth/customers/$customerId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/index.tsx index 421968b..92319b3 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/index.tsx @@ -35,9 +35,7 @@ export const Route = createFileRoute("/_auth/customers/$customerId/")({ ), component: RouteComponent, errorComponent: () => ( -

- No se pudo cargar el cliente. -

+

No se pudo cargar el cliente.

), }); @@ -147,14 +145,17 @@ function RouteComponent() { - - {TABS.map(({ value, label, icon: Icon }) => ( - - - {label} - - ))} - + {/* Six tabs don't fit a phone; scroll them instead of widening the page. */} +
+ + {TABS.map(({ value, label, icon: Icon }) => ( + + + {label} + + ))} + +
-
-
-
-
- -
-

Clientes

-
-

- Gestiona los clientes del sistema -

-
-
+
+ Nuevo Cliente -
-
+ } + /> diff --git a/apps/web/src/routes/_auth/customers/new.tsx b/apps/web/src/routes/_auth/customers/new.tsx index bcfe83d..55375bd 100644 --- a/apps/web/src/routes/_auth/customers/new.tsx +++ b/apps/web/src/routes/_auth/customers/new.tsx @@ -2,6 +2,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { ContactRound } from "lucide-react"; import { CustomerForm } from "@/components/customers/customer-form"; +import { PageHeader } from "@/components/page-header"; export const Route = createFileRoute("/_auth/customers/new")({ component: RouteComponent, @@ -9,20 +10,12 @@ export const Route = createFileRoute("/_auth/customers/new")({ function RouteComponent() { return ( -
-
-
-
-
- -
-

Nuevo Cliente

-
-

- Crea un nuevo cliente para el sistema -

-
-
+
+
); diff --git a/apps/web/src/routes/_auth/dashboard.tsx b/apps/web/src/routes/_auth/dashboard.tsx index b0a2f15..b84a332 100644 --- a/apps/web/src/routes/_auth/dashboard.tsx +++ b/apps/web/src/routes/_auth/dashboard.tsx @@ -1,22 +1,72 @@ -import { useQuery } from "@tanstack/react-query"; -import { createFileRoute } from "@tanstack/react-router"; +import { Link, createFileRoute } from "@tanstack/react-router"; +import { ChevronRight, Home } from "lucide-react"; -import { orpc } from "@/utils/orpc"; +import { NAV_ENTRIES, isSection } from "@/components/nav-items"; +import type { NavLink } from "@/components/nav-items"; +import { PageHeader } from "@/components/page-header"; +import { useIsAdmin } from "@/hooks/use-is-admin"; export const Route = createFileRoute("/_auth/dashboard")({ component: RouteComponent, }); function RouteComponent() { - const { session } = Route.useRouteContext(); + const firstName = Route.useRouteContext({ + select: (ctx) => ctx.session.user.name.split(" ")[0], + }); - const privateData = useQuery(orpc.privateData.queryOptions()); + const isAdmin = useIsAdmin(); + + const shortcuts: (NavLink & { section?: string })[] = []; + + for (const entry of NAV_ENTRIES) { + const links = isSection(entry) + ? entry.items.map((item) => ({ ...item, section: entry.label })) + : [entry]; + + for (const link of links) { + if (link.to !== "/dashboard" && (isAdmin || !link.adminOnly)) { + shortcuts.push(link); + } + } + } return ( -
-

Dashboard

-

Welcome {session.user.name}

-

API: {privateData.data?.message}

+
+ + +
); } diff --git a/apps/web/src/routes/_auth/route.tsx b/apps/web/src/routes/_auth/route.tsx index 4ed1b32..f274a89 100644 --- a/apps/web/src/routes/_auth/route.tsx +++ b/apps/web/src/routes/_auth/route.tsx @@ -1,8 +1,10 @@ +import { Separator } from "@suni/ui/components/separator"; import { SidebarInset, SidebarProvider, SidebarTrigger, } from "@suni/ui/components/sidebar"; +import { TooltipProvider } from "@suni/ui/components/tooltip"; import { Outlet, createFileRoute, redirect } from "@tanstack/react-router"; import { AppSidebar } from "@/components/app-sidebar"; @@ -26,17 +28,26 @@ export const Route = createFileRoute("/_auth")({ function AuthLayout() { return ( - - - -
- - -
-
- -
-
-
+ + {/* The sidebar saves its collapsed state in this cookie; read it back so a reload keeps it. */} + + + +
+ + + +
+
+ +
+
+
+
); } diff --git a/apps/web/src/routes/_auth/users/$userId/edit.tsx b/apps/web/src/routes/_auth/users/$userId/edit.tsx index 5ecb1cc..9e36251 100644 --- a/apps/web/src/routes/_auth/users/$userId/edit.tsx +++ b/apps/web/src/routes/_auth/users/$userId/edit.tsx @@ -1,6 +1,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { UserPen } from "lucide-react"; +import { PageHeader } from "@/components/page-header"; import { UserForm } from "@/components/users/user-form"; export const Route = createFileRoute("/_auth/users/$userId/edit")({ @@ -8,9 +9,7 @@ export const Route = createFileRoute("/_auth/users/$userId/edit")({ queryClient.query(orpc.users.get.queryOptions({ input: { id: userId } })), component: RouteComponent, errorComponent: () => ( -

- No se pudo cargar el usuario. -

+

No se pudo cargar el usuario.

), }); @@ -18,20 +17,12 @@ function RouteComponent() { const user = Route.useLoaderData(); return ( -
-
-
-
-
- -
-

Editar Usuario

-
-

- Modifica la información del usuario -

-
-
+
+
diff --git a/apps/web/src/routes/_auth/users/index.tsx b/apps/web/src/routes/_auth/users/index.tsx index 51111d8..7cb2790 100644 --- a/apps/web/src/routes/_auth/users/index.tsx +++ b/apps/web/src/routes/_auth/users/index.tsx @@ -2,6 +2,7 @@ import { Button } from "@suni/ui/components/button"; import { Link, createFileRoute } from "@tanstack/react-router"; import { Plus, Users } from "lucide-react"; +import { PageHeader } from "@/components/page-header"; import { UsersDataTable } from "@/components/users/users-table"; export const Route = createFileRoute("/_auth/users/")({ @@ -12,20 +13,12 @@ function RouteComponent() { const { session } = Route.useRouteContext(); return ( -
-
-
-
-
- -
-

Usuarios

-
-

- Administra los usuarios del sistema -

-
-
+
+ Nuevo Usuario -
-
+ } + />
); diff --git a/apps/web/src/routes/_auth/users/new.tsx b/apps/web/src/routes/_auth/users/new.tsx index f9f1f70..656eb1b 100644 --- a/apps/web/src/routes/_auth/users/new.tsx +++ b/apps/web/src/routes/_auth/users/new.tsx @@ -1,6 +1,7 @@ import { createFileRoute } from "@tanstack/react-router"; import { User } from "lucide-react"; +import { PageHeader } from "@/components/page-header"; import { UserForm } from "@/components/users/user-form"; export const Route = createFileRoute("/_auth/users/new")({ @@ -9,20 +10,12 @@ export const Route = createFileRoute("/_auth/users/new")({ function RouteComponent() { return ( -
-
-
-
-
- -
-

Nuevo Usuario

-
-

- Crea un nuevo usuario para el sistema -

-
-
+
+
); diff --git a/packages/ui/src/components/avatar.tsx b/packages/ui/src/components/avatar.tsx new file mode 100644 index 0000000..3afe8a9 --- /dev/null +++ b/packages/ui/src/components/avatar.tsx @@ -0,0 +1,108 @@ +"use client" + +import * as React from "react" +import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar" +import { cn } from "cn" + +function Avatar({ + className, + size = "default", + ...props +}: AvatarPrimitive.Root.Props & { + size?: "default" | "sm" | "lg" +}) { + return ( + + ) +} + +function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) { + return ( + + ) +} + +function AvatarFallback({ + className, + ...props +}: AvatarPrimitive.Fallback.Props) { + return ( + + ) +} + +function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) { + return ( + svg]:hidden", + "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", + "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", + className + )} + {...props} + /> + ) +} + +function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AvatarGroupCount({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", + className + )} + {...props} + /> + ) +} + +export { + Avatar, + AvatarImage, + AvatarFallback, + AvatarGroup, + AvatarGroupCount, + AvatarBadge, +} diff --git a/packages/ui/src/components/collapsible.tsx b/packages/ui/src/components/collapsible.tsx new file mode 100644 index 0000000..4b242f7 --- /dev/null +++ b/packages/ui/src/components/collapsible.tsx @@ -0,0 +1,19 @@ +import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible" + +function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) { + return +} + +function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) { + return ( + + ) +} + +function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) { + return ( + + ) +} + +export { Collapsible, CollapsibleTrigger, CollapsibleContent } diff --git a/packages/ui/src/components/separator.tsx b/packages/ui/src/components/separator.tsx new file mode 100644 index 0000000..7d8337e --- /dev/null +++ b/packages/ui/src/components/separator.tsx @@ -0,0 +1,22 @@ +import { Separator as SeparatorPrimitive } from "@base-ui/react/separator" +import { cn } from "cn" + +function Separator({ + className, + orientation = "horizontal", + ...props +}: SeparatorPrimitive.Props) { + return ( + + ) +} + +export { Separator } diff --git a/packages/ui/src/components/sheet.tsx b/packages/ui/src/components/sheet.tsx new file mode 100644 index 0000000..c9c3357 --- /dev/null +++ b/packages/ui/src/components/sheet.tsx @@ -0,0 +1,136 @@ +import * as React from "react" +import { Dialog as SheetPrimitive } from "@base-ui/react/dialog" +import { cn } from "cn" + +import { Button } from "@suni/ui/components/button" +import { XIcon } from "lucide-react" + +function Sheet({ ...props }: SheetPrimitive.Root.Props) { + return +} + +function SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) { + return +} + +function SheetClose({ ...props }: SheetPrimitive.Close.Props) { + return +} + +function SheetPortal({ ...props }: SheetPrimitive.Portal.Props) { + return +} + +function SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) { + return ( + + ) +} + +function SheetContent({ + className, + children, + side = "right", + showCloseButton = true, + ...props +}: SheetPrimitive.Popup.Props & { + side?: "top" | "right" | "bottom" | "left" + showCloseButton?: boolean +}) { + return ( + + + + {children} + {showCloseButton && ( + + } + > + + Close + + )} + + + ) +} + +function SheetHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function SheetFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) { + return ( + + ) +} + +function SheetDescription({ + className, + ...props +}: SheetPrimitive.Description.Props) { + return ( + + ) +} + +export { + Sheet, + SheetTrigger, + SheetClose, + SheetContent, + SheetHeader, + SheetFooter, + SheetTitle, + SheetDescription, +} diff --git a/packages/ui/src/components/sidebar.tsx b/packages/ui/src/components/sidebar.tsx index 82861d7..c628bfb 100644 --- a/packages/ui/src/components/sidebar.tsx +++ b/packages/ui/src/components/sidebar.tsx @@ -1,155 +1,254 @@ -import { PanelLeft } from 'lucide-react'; -import * as React from 'react'; +"use client" + +import * as React from "react" +import { mergeProps } from "@base-ui/react/merge-props" +import { useRender } from "@base-ui/react/use-render" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "cn" + +import { useIsMobile } from "@suni/ui/hooks/use-mobile" import { Button } from "@suni/ui/components/button" -import { cn } from 'cn'; +import { Input } from "@suni/ui/components/input" +import { Separator } from "@suni/ui/components/separator" +import { + Sheet, + SheetContent, + SheetDescription, + SheetHeader, + SheetTitle, +} from "@suni/ui/components/sheet" +import { Skeleton } from "@suni/ui/components/skeleton" +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@suni/ui/components/tooltip" +import { PanelLeftIcon } from "lucide-react" -const SIDEBAR_WIDTH = '16rem'; -const SIDEBAR_KEYBOARD_SHORTCUT = 'b'; +const SIDEBAR_COOKIE_NAME = "sidebar_state" +const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7 +const SIDEBAR_WIDTH = "16rem" +const SIDEBAR_WIDTH_MOBILE = "18rem" +const SIDEBAR_WIDTH_ICON = "3rem" +const SIDEBAR_KEYBOARD_SHORTCUT = "b" type SidebarContextProps = { - state: 'expanded' | 'collapsed'; - open: boolean; - setOpen: React.Dispatch>; - openMobile: boolean; - setOpenMobile: React.Dispatch>; - toggleSidebar: () => void; -}; + state: "expanded" | "collapsed" + open: boolean + setOpen: (open: boolean) => void + openMobile: boolean + setOpenMobile: (open: boolean) => void + isMobile: boolean + toggleSidebar: () => void +} -const SidebarContext = React.createContext(null); +const SidebarContext = React.createContext(null) function useSidebar() { - const context = React.useContext(SidebarContext); + const context = React.useContext(SidebarContext) if (!context) { - throw new Error('useSidebar must be used within a SidebarProvider.'); + throw new Error("useSidebar must be used within a SidebarProvider.") } - return context; -} - -/* ---------------------------------- Provider --------------------------------- */ -type SidebarProviderProps = React.ComponentProps<'div'> & { - /** Estado inicial en escritorio. En móvil siempre inicia cerrada. */ - defaultOpen?: boolean; -}; + return context +} function SidebarProvider({ defaultOpen = true, + open: openProp, + onOpenChange: setOpenProp, className, style, children, ...props -}: SidebarProviderProps) { - const [open, setOpen] = React.useState(defaultOpen); - const [openMobile, setOpenMobile] = React.useState(false); +}: React.ComponentProps<"div"> & { + defaultOpen?: boolean + open?: boolean + onOpenChange?: (open: boolean) => void +}) { + const isMobile = useIsMobile() + const [openMobile, setOpenMobile] = React.useState(false) + + // This is the internal state of the sidebar. + // We use openProp and setOpenProp for control from outside the component. + const [_open, _setOpen] = React.useState(defaultOpen) + const open = openProp ?? _open + const setOpen = React.useCallback( + (value: boolean | ((value: boolean) => boolean)) => { + const openState = typeof value === "function" ? value(open) : value + if (setOpenProp) { + setOpenProp(openState) + } else { + _setOpen(openState) + } - // Alterna ambos estados: el CSS (breakpoint md) decide cuál se ve. + // This sets the cookie to keep the sidebar state. + document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}` + }, + [setOpenProp, open] + ) + + // Helper to toggle the sidebar. const toggleSidebar = React.useCallback(() => { - setOpen((value) => !value); - setOpenMobile((value) => !value); - }, []); + return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open) + }, [isMobile, setOpen, setOpenMobile]) + // Adds a keyboard shortcut to toggle the sidebar. React.useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { - // Ctrl/Cmd + B if ( event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey) ) { - event.preventDefault(); - toggleSidebar(); - } - // Escape cierra el panel en móvil - if (event.key === 'Escape') { - setOpenMobile(false); + event.preventDefault() + toggleSidebar() } - }; - window.addEventListener('keydown', handleKeyDown); - return () => window.removeEventListener('keydown', handleKeyDown); - }, [toggleSidebar]); + } - const value = React.useMemo( + window.addEventListener("keydown", handleKeyDown) + return () => window.removeEventListener("keydown", handleKeyDown) + }, [toggleSidebar]) + + // We add a state so that we can do data-state="expanded" or "collapsed". + // This makes it easier to style the sidebar with Tailwind classes. + const state = open ? "expanded" : "collapsed" + + const contextValue = React.useMemo( () => ({ - state: open ? 'expanded' : 'collapsed', + state, open, setOpen, + isMobile, openMobile, setOpenMobile, toggleSidebar, }), - [open, openMobile, toggleSidebar] - ); + [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar] + ) return ( - +
{children}
- ); + ) } -/* ---------------------------------- Sidebar ---------------------------------- */ - -/** - * Mobile first: - * - Base (móvil): panel fuera de pantalla que se desliza sobre el contenido con un fondo oscuro. - * - md y superior: panel fijo al costado que ocupa espacio y se puede colapsar. - */ function Sidebar({ + side = "left", + variant = "sidebar", + collapsible = "offcanvas", className, children, + dir, ...props -}: React.ComponentProps<'aside'>) { - const { state, openMobile, setOpenMobile } = useSidebar(); +}: React.ComponentProps<"div"> & { + side?: "left" | "right" + variant?: "sidebar" | "floating" | "inset" + collapsible?: "offcanvas" | "icon" | "none" +}) { + const { isMobile, state, openMobile, setOpenMobile } = useSidebar() + + if (collapsible === "none") { + return ( +
+ {children} +
+ ) + } + + if (isMobile) { + return ( + + + + Menú + Navegación principal de Suni. + +
{children}
+
+
+ ) + } return (
- {/* Fondo oscuro (solo móvil) */} + {/* This is what handles the sidebar gap on desktop */} - ); + ) } function SidebarTrigger({ @@ -157,99 +256,468 @@ function SidebarTrigger({ onClick, ...props }: React.ComponentProps) { - const { toggleSidebar } = useSidebar(); + const { toggleSidebar } = useSidebar() return ( - - ); + + ) } -function SidebarInset({ +function SidebarRail({ className, ...props }: React.ComponentProps<"button">) { + const { toggleSidebar } = useSidebar() + + return ( + @@ -214,7 +214,6 @@ export function BranchForm({ className="w-full sm:w-auto" disabled={submitting} type="submit" - variant="green" > {submitting ? : null} {branch ? "Guardar" : "Crear"} diff --git a/apps/web/src/components/customers/branches/branch-header.tsx b/apps/web/src/components/customers/branches/branch-header.tsx index 794085e..830680d 100644 --- a/apps/web/src/components/customers/branches/branch-header.tsx +++ b/apps/web/src/components/customers/branches/branch-header.tsx @@ -37,13 +37,13 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) {
@@ -51,7 +51,7 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) {

{branch.name} @@ -80,7 +80,7 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) { {onEdit && !isCustomerArchived ? (
{isArchived ? null : ( - diff --git a/apps/web/src/components/customers/branches/branch-info.tsx b/apps/web/src/components/customers/branches/branch-info.tsx index 29af8ad..dbde801 100644 --- a/apps/web/src/components/customers/branches/branch-info.tsx +++ b/apps/web/src/components/customers/branches/branch-info.tsx @@ -27,7 +27,9 @@ export function BranchInfoContent({ return (
-

Dirección

+

+ Dirección +

@@ -47,7 +49,7 @@ export function BranchInfoContent({
-

+

Imagen de fachada

diff --git a/apps/web/src/components/customers/branches/card.tsx b/apps/web/src/components/customers/branches/card.tsx index a0e559d..3b954d2 100644 --- a/apps/web/src/components/customers/branches/card.tsx +++ b/apps/web/src/components/customers/branches/card.tsx @@ -78,7 +78,7 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { "group bg-card relative flex h-full flex-col overflow-hidden rounded-xl border transition-colors duration-200", isArchived ? "border-border/60 bg-archived-pattern shadow-sm" - : "border-border hover:border-success/30 hover:shadow-md" + : "border-border hover:border-primary/30 hover:shadow-md" )} > {branch.name} @@ -117,7 +117,7 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { "line-clamp-1 text-sm font-medium hover:underline", isCustomerArchived ? "text-muted-foreground" - : "text-success" + : "text-primary" )} params={{ customerId: customer.id }} title={customer.name} @@ -189,7 +189,7 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { Ver detalles - +
diff --git a/apps/web/src/components/customers/branches/grid.tsx b/apps/web/src/components/customers/branches/grid.tsx index d9d1852..b6fc398 100644 --- a/apps/web/src/components/customers/branches/grid.tsx +++ b/apps/web/src/components/customers/branches/grid.tsx @@ -95,7 +95,7 @@ export function BranchesGrid({ customerId, canCreate }: BranchesGridProps) { return (
-

Sucursales

+

Sucursales

{canCreate ? ( ) : null} diff --git a/apps/web/src/components/customers/contacts/contact-card.tsx b/apps/web/src/components/customers/contacts/contact-card.tsx index 8f2162a..813489e 100644 --- a/apps/web/src/components/customers/contacts/contact-card.tsx +++ b/apps/web/src/components/customers/contacts/contact-card.tsx @@ -92,7 +92,7 @@ interface ContactParentsProps { const PARENT_LINK = "line-clamp-1 text-sm font-medium hover:underline"; function nameColor(isArchived: boolean) { - return isArchived ? "text-muted-foreground" : "text-success"; + return isArchived ? "text-muted-foreground" : "text-primary"; } function ContactParents({ @@ -175,7 +175,7 @@ export default function ContactCard({ contact, customer }: ContactCardProps) { "group bg-card relative flex h-full flex-col overflow-hidden rounded-xl border transition-colors duration-200", isArchived ? "border-border/60 bg-archived-pattern shadow-sm" - : "border-border hover:border-success/30 hover:shadow-md" + : "border-border hover:border-primary/30 hover:shadow-md" )} >
@@ -223,10 +223,10 @@ export default function ContactCard({ contact, customer }: ContactCardProps) {
- + {contact.email} diff --git a/apps/web/src/components/customers/contacts/contact-form.tsx b/apps/web/src/components/customers/contacts/contact-form.tsx index 398ea9f..7d54aba 100644 --- a/apps/web/src/components/customers/contacts/contact-form.tsx +++ b/apps/web/src/components/customers/contacts/contact-form.tsx @@ -90,7 +90,7 @@ export function ContactForm({ }} >
- + Datos generales
@@ -118,7 +118,7 @@ export function ContactForm({
- + Contacto
@@ -162,7 +162,7 @@ export function ContactForm({ disabled={submitting} onClick={onCancel} type="button" - variant="outline-destructive" + variant="outline" > Cancelar @@ -170,7 +170,6 @@ export function ContactForm({ className="w-full sm:w-auto" disabled={submitting} type="submit" - variant="green" > {submitting ? : null} {contact ? "Guardar" : "Crear"} diff --git a/apps/web/src/components/customers/contacts/contact-grid.tsx b/apps/web/src/components/customers/contacts/contact-grid.tsx index 66f60fd..2eb6f23 100644 --- a/apps/web/src/components/customers/contacts/contact-grid.tsx +++ b/apps/web/src/components/customers/contacts/contact-grid.tsx @@ -91,7 +91,7 @@ export function ContactsGrid({ return (
-

Contactos

+

Contactos

{canCreate ? (
@@ -52,7 +52,7 @@ export default function CustomerCard({ customer }: CustomerCardProps) {

{customer.name} @@ -152,7 +152,7 @@ export default function CustomerCard({ customer }: CustomerCardProps) { Ver detalles - +

diff --git a/apps/web/src/components/customers/customer-form.tsx b/apps/web/src/components/customers/customer-form.tsx index a1121b8..8c60df6 100644 --- a/apps/web/src/components/customers/customer-form.tsx +++ b/apps/web/src/components/customers/customer-form.tsx @@ -119,7 +119,7 @@ export function CustomerForm({ customer }: CustomerFormProps) { }} >
- + Datos generales
@@ -181,7 +181,7 @@ export function CustomerForm({ customer }: CustomerFormProps) {
- + Dirección
@@ -278,16 +278,11 @@ export function CustomerForm({ customer }: CustomerFormProps) { ) } - variant="outline-destructive" + variant="outline" > Cancelar - diff --git a/apps/web/src/components/customers/data.tsx b/apps/web/src/components/customers/data.tsx index 396f50c..a8c1e93 100644 --- a/apps/web/src/components/customers/data.tsx +++ b/apps/web/src/components/customers/data.tsx @@ -21,7 +21,7 @@ export function CustomerData({ customer }: CustomerDataProps) {
Vendedor:
diff --git a/apps/web/src/components/customers/new-entity-button.tsx b/apps/web/src/components/customers/new-entity-button.tsx index 02225c1..906cfaf 100644 --- a/apps/web/src/components/customers/new-entity-button.tsx +++ b/apps/web/src/components/customers/new-entity-button.tsx @@ -188,7 +188,6 @@ export function NewEntityButton({ - diff --git a/apps/web/src/components/page-header.tsx b/apps/web/src/components/page-header.tsx index 7cd73bd..ca0e840 100644 --- a/apps/web/src/components/page-header.tsx +++ b/apps/web/src/components/page-header.tsx @@ -18,10 +18,10 @@ export function PageHeader({
-
- +
+
-

{title}

+

{title}

{description}

diff --git a/apps/web/src/components/users/change-user-status-dialog.tsx b/apps/web/src/components/users/change-user-status-dialog.tsx index 96d222b..0596afd 100644 --- a/apps/web/src/components/users/change-user-status-dialog.tsx +++ b/apps/web/src/components/users/change-user-status-dialog.tsx @@ -31,7 +31,7 @@ const ACTIONS = { activate: { label: "Activar", Icon: CircleCheckBig, - triggerVariant: "outline-green", + triggerVariant: "outline", confirmVariant: "default", emailClassName: "text-success", description: "Esto reactivará", diff --git a/apps/web/src/components/users/user-form.tsx b/apps/web/src/components/users/user-form.tsx index ed547d3..d8e7087 100644 --- a/apps/web/src/components/users/user-form.tsx +++ b/apps/web/src/components/users/user-form.tsx @@ -94,16 +94,11 @@ export function UserForm({ user }: UserFormProps) { disabled={submitting} nativeButton={false} render={} - variant="outline-destructive" + variant="outline" > Cancelar - diff --git a/apps/web/src/components/users/users-table.tsx b/apps/web/src/components/users/users-table.tsx index e276f62..2e516c8 100644 --- a/apps/web/src/components/users/users-table.tsx +++ b/apps/web/src/components/users/users-table.tsx @@ -33,7 +33,7 @@ const columnHelper = createColumnHelper(); function RoleBadge({ role }: { role: string | null }) { if (role === "admin") { return ( - + Admin ); @@ -70,9 +70,7 @@ function createColumns(currentUserId: string) { {info.getValue()} {info.row.original.id === currentUserId && ( - - Tú - + Tú )} ), diff --git a/apps/web/src/routes/_auth/customers/$customerId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/index.tsx index 92319b3..c61d22a 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/index.tsx @@ -74,13 +74,13 @@ function RouteComponent() {
@@ -88,7 +88,7 @@ function RouteComponent() {

{customer.name} @@ -108,7 +108,7 @@ function RouteComponent() { "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium", customer.type === "Asesor" ? "bg-muted text-foreground" - : "bg-brand/10 text-brand" + : "bg-primary/10 text-primary" )} > {customer.type} @@ -118,7 +118,7 @@ function RouteComponent() {
{isArchived ? null : ( diff --git a/apps/web/src/routes/_auth/customers/index.tsx b/apps/web/src/routes/_auth/customers/index.tsx index deccbb5..bb22540 100644 --- a/apps/web/src/routes/_auth/customers/index.tsx +++ b/apps/web/src/routes/_auth/customers/index.tsx @@ -77,7 +77,6 @@ function RouteComponent() { className="w-full sm:w-auto" nativeButton={false} render={} - variant="green" > Nuevo Cliente diff --git a/apps/web/src/routes/_auth/dashboard.tsx b/apps/web/src/routes/_auth/dashboard.tsx index b84a332..e1ca53e 100644 --- a/apps/web/src/routes/_auth/dashboard.tsx +++ b/apps/web/src/routes/_auth/dashboard.tsx @@ -44,11 +44,11 @@ function RouteComponent() { {shortcuts.map(({ to, label, icon: Icon, section }) => (
  • -
    - +
    +
    {label} @@ -60,7 +60,7 @@ function RouteComponent() {
  • diff --git a/apps/web/src/routes/_auth/users/index.tsx b/apps/web/src/routes/_auth/users/index.tsx index 7cb2790..319ed8c 100644 --- a/apps/web/src/routes/_auth/users/index.tsx +++ b/apps/web/src/routes/_auth/users/index.tsx @@ -23,7 +23,6 @@ function RouteComponent() { className="w-full sm:w-auto" nativeButton={false} render={} - variant="green" > Nuevo Usuario diff --git a/packages/ui/src/components/badge.tsx b/packages/ui/src/components/badge.tsx index bbc701b..1d4ed5f 100644 --- a/packages/ui/src/components/badge.tsx +++ b/packages/ui/src/components/badge.tsx @@ -9,16 +9,13 @@ const badgeVariants = cva( variants: { variant: { default: - "border-success/30 bg-success/10 text-success hover:bg-success/20", + "border-primary/30 bg-primary/10 text-primary", secondary: - "border-secondary-foreground/20 bg-secondary text-secondary-foreground hover:bg-secondary/80", + "border-secondary-foreground/20 bg-secondary text-secondary-foreground", destructive: - "border-destructive/30 bg-destructive/10 text-destructive hover:bg-destructive/20", + "border-destructive/30 bg-destructive/10 text-destructive", success: - "border-green-500/30 bg-green-500/10 text-green-700 hover:bg-green-500/20 dark:text-green-400 gap-1", - blue: "border-brand/30 bg-brand/10 text-brand hover:bg-brand/20", - warning: - "border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/20 dark:text-amber-400", + "border-success/30 bg-success/10 text-success", outline: "text-foreground", }, }, diff --git a/packages/ui/src/components/breadcrumb.tsx b/packages/ui/src/components/breadcrumb.tsx index f75efed..9cb34ca 100644 --- a/packages/ui/src/components/breadcrumb.tsx +++ b/packages/ui/src/components/breadcrumb.tsx @@ -39,7 +39,7 @@ function BreadcrumbLink({ return useRender({ defaultTagName: 'a', props: mergeProps<'a'>( - { className: cn('transition-colors hover:text-foreground text-brand', className) }, + { className: cn('transition-colors hover:text-foreground text-primary', className) }, props ), render, @@ -55,7 +55,7 @@ function BreadcrumbPage({ - {children ?? } + {children ?? } ); } diff --git a/packages/ui/src/components/button.tsx b/packages/ui/src/components/button.tsx index 39318b1..73c921b 100644 --- a/packages/ui/src/components/button.tsx +++ b/packages/ui/src/components/button.tsx @@ -3,27 +3,22 @@ import { cva, type VariantProps } from "class-variance-authority" import { cn } from "cn" const buttonVariants = cva( - "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", + "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", { variants: { variant: { default: - "bg-primary text-primary-foreground shadow hover:bg-primary/90", + "bg-primary text-primary-foreground shadow hover:bg-primary-hover", destructive: - "bg-destructive text-white shadow-sm hover:bg-destructive/90", + "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive-pressed", outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground", link: "text-primary underline-offset-4 hover:underline", - green: - "bg-success text-white shadow transition-colors duration-400 hover:bg-success/80 active:bg-success-pressed", - "outline-green": - "border border-success text-success hover:bg-success/10 duration-500 active:bg-success-pressed active:text-white", "outline-destructive": - "border border-danger text-danger hover:bg-danger/10 duration-500 active:bg-danger-dark active:text-white", - blue: "bg-brand text-white shadow transition-colors duration-400 hover:bg-brand/80 active:bg-brand-dark", + "border border-destructive text-destructive hover:bg-destructive/10 duration-500 active:bg-destructive-pressed active:text-destructive-foreground", }, size: { default: "h-9 px-4 py-2", diff --git a/packages/ui/src/components/sidebar.tsx b/packages/ui/src/components/sidebar.tsx index c628bfb..eefbbda 100644 --- a/packages/ui/src/components/sidebar.tsx +++ b/packages/ui/src/components/sidebar.tsx @@ -475,7 +475,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) { } const sidebarMenuButtonVariants = cva( - "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", + "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-primary data-active:font-medium data-active:text-sidebar-primary-foreground data-active:hover:bg-sidebar-primary data-active:hover:text-sidebar-primary-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", { variants: { variant: { @@ -679,7 +679,7 @@ function SidebarMenuSubButton({ props: mergeProps<"a">( { className: cn( - "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", + "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent/50 focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", className ), }, diff --git a/packages/ui/src/components/tabs.tsx b/packages/ui/src/components/tabs.tsx index c5c6943..155efd4 100644 --- a/packages/ui/src/components/tabs.tsx +++ b/packages/ui/src/components/tabs.tsx @@ -29,7 +29,7 @@ function TabsTrigger({ return ( Date: Wed, 11 Nov 2026 16:20:02 -0600 Subject: [PATCH 03/17] =?UTF-8?q?Redise=C3=B1a=20los=20badges=20y=20las=20?= =?UTF-8?q?acciones=20de=20suspender=20y=20activar=20usuarios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Los badges pasan a píldoras sin borde con peso medio; el estado usa un punto en lugar del ícono de monitor y "Tú" se distingue del rol. Suspender y Activar son íconos ghost como Editar y solo muestran su color al pasar el mouse, con las variantes ghost-destructive y ghost-success en lugar de outline-destructive. --- .../users/change-user-status-dialog.tsx | 4 ++-- apps/web/src/components/users/users-table.tsx | 18 ++++++++++++------ packages/ui/src/components/badge.tsx | 12 ++++++------ packages/ui/src/components/button.tsx | 7 +++++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/apps/web/src/components/users/change-user-status-dialog.tsx b/apps/web/src/components/users/change-user-status-dialog.tsx index 0596afd..fef443b 100644 --- a/apps/web/src/components/users/change-user-status-dialog.tsx +++ b/apps/web/src/components/users/change-user-status-dialog.tsx @@ -23,7 +23,7 @@ const ACTIONS = { suspend: { label: "Suspender", Icon: Ban, - triggerVariant: "outline-destructive", + triggerVariant: "ghost-destructive", confirmVariant: "destructive", emailClassName: "text-destructive", description: "Esto suspenderá", @@ -31,7 +31,7 @@ const ACTIONS = { activate: { label: "Activar", Icon: CircleCheckBig, - triggerVariant: "outline", + triggerVariant: "ghost-success", confirmVariant: "default", emailClassName: "text-success", description: "Esto reactivará", diff --git a/apps/web/src/components/users/users-table.tsx b/apps/web/src/components/users/users-table.tsx index 2e516c8..6944f86 100644 --- a/apps/web/src/components/users/users-table.tsx +++ b/apps/web/src/components/users/users-table.tsx @@ -18,7 +18,7 @@ import { useReactTable, } from "@tanstack/react-table"; import type { PaginationState } from "@tanstack/react-table"; -import { MonitorCheck, MonitorX, Pencil, Shield, User } from "lucide-react"; +import { Pencil, Shield, User } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; import { ChangeUserStatusDialog } from "@/components/users/change-user-status-dialog"; @@ -34,30 +34,34 @@ function RoleBadge({ role }: { role: string | null }) { if (role === "admin") { return ( - Admin + Admin ); } return ( - Usuario + Usuario ); } +function StatusDot() { + return ; +} + function StatusBadge({ banned }: { banned: boolean }) { if (banned) { return ( - Suspendido + Suspendido ); } return ( - Activo + Activo ); } @@ -70,7 +74,9 @@ function createColumns(currentUserId: string) { {info.getValue()} {info.row.original.id === currentUserId && ( - Tú + + Tú + )} ), diff --git a/packages/ui/src/components/badge.tsx b/packages/ui/src/components/badge.tsx index 1d4ed5f..eaefaac 100644 --- a/packages/ui/src/components/badge.tsx +++ b/packages/ui/src/components/badge.tsx @@ -4,19 +4,19 @@ import * as React from "react"; import { cn } from "cn"; const badgeVariants = cva( - "inline-flex items-center rounded-md border px-2.5 py-0.5 font-semibold text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 gap-1", + "inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 font-medium text-xs [&_svg]:size-3 [&_svg]:shrink-0", { variants: { variant: { default: - "border-primary/30 bg-primary/10 text-primary", + "bg-primary/10 text-primary", secondary: - "border-secondary-foreground/20 bg-secondary text-secondary-foreground", + "bg-muted text-muted-foreground", destructive: - "border-destructive/30 bg-destructive/10 text-destructive", + "bg-destructive/10 text-destructive", success: - "border-success/30 bg-success/10 text-success", - outline: "text-foreground", + "bg-success/10 text-success", + outline: "text-muted-foreground ring-1 ring-border ring-inset", }, }, defaultVariants: { diff --git a/packages/ui/src/components/button.tsx b/packages/ui/src/components/button.tsx index 73c921b..53b7866 100644 --- a/packages/ui/src/components/button.tsx +++ b/packages/ui/src/components/button.tsx @@ -16,9 +16,12 @@ const buttonVariants = cva( secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground", + // Quiet row actions whose hover color previews the outcome. + "ghost-destructive": + "text-muted-foreground hover:bg-destructive/10 hover:text-destructive", + "ghost-success": + "text-muted-foreground hover:bg-success/10 hover:text-success", link: "text-primary underline-offset-4 hover:underline", - "outline-destructive": - "border border-destructive text-destructive hover:bg-destructive/10 duration-500 active:bg-destructive-pressed active:text-destructive-foreground", }, size: { default: "h-9 px-4 py-2", From b15c6f57b807a886ff405e0f694d962de188a9d9 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Wed, 11 Nov 2026 16:28:37 -0600 Subject: [PATCH 04/17] =?UTF-8?q?Iguala=20el=20espaciado=20de=20Usuarios?= =?UTF-8?q?=20con=20Clientes=20y=20mueve=20el=20total=20junto=20a=20la=20p?= =?UTF-8?q?aginaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/components/users/users-table.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/users/users-table.tsx b/apps/web/src/components/users/users-table.tsx index 6944f86..2d7680f 100644 --- a/apps/web/src/components/users/users-table.tsx +++ b/apps/web/src/components/users/users-table.tsx @@ -191,14 +191,8 @@ export function UsersDataTable({ currentUserId }: UsersDataTableProps) { } return ( -
    +
    -

    Usuarios

    - - {total} - -
    -
    { @@ -261,9 +255,10 @@ export function UsersDataTable({ currentUserId }: UsersDataTableProps) {
    -
    +
    - Página {pagination.pageIndex + 1} de {pageCount} + Página {pagination.pageIndex + 1} de {pageCount} ·{" "} + {total === 1 ? "1 usuario" : `${total} usuarios`}
    - -
    +
    + +
    ); diff --git a/apps/web/src/routes/_auth/users/$userId/edit.tsx b/apps/web/src/routes/_auth/users/$userId/edit.tsx index 9e36251..dd01936 100644 --- a/apps/web/src/routes/_auth/users/$userId/edit.tsx +++ b/apps/web/src/routes/_auth/users/$userId/edit.tsx @@ -1,4 +1,4 @@ -import { createFileRoute } from "@tanstack/react-router"; +import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { UserPen } from "lucide-react"; import { PageHeader } from "@/components/page-header"; @@ -15,6 +15,8 @@ export const Route = createFileRoute("/_auth/users/$userId/edit")({ function RouteComponent() { const user = Route.useLoaderData(); + const navigate = useNavigate(); + const goToUsers = () => navigate({ to: "/users" }); return (
    @@ -24,7 +26,7 @@ function RouteComponent() { title="Editar Usuario" /> - +
    ); } diff --git a/apps/web/src/routes/_auth/users/index.tsx b/apps/web/src/routes/_auth/users/index.tsx index 319ed8c..c9a6708 100644 --- a/apps/web/src/routes/_auth/users/index.tsx +++ b/apps/web/src/routes/_auth/users/index.tsx @@ -1,8 +1,8 @@ -import { Button } from "@suni/ui/components/button"; -import { Link, createFileRoute } from "@tanstack/react-router"; -import { Plus, Users } from "lucide-react"; +import { createFileRoute } from "@tanstack/react-router"; +import { Users } from "lucide-react"; import { PageHeader } from "@/components/page-header"; +import { CreateUserDialog } from "@/components/users/create-user-dialog"; import { UsersDataTable } from "@/components/users/users-table"; export const Route = createFileRoute("/_auth/users/")({ @@ -18,16 +18,7 @@ function RouteComponent() { description="Administra los usuarios del sistema" icon={Users} title="Usuarios" - actions={ - - } + actions={} />
    diff --git a/apps/web/src/routes/_auth/users/new.tsx b/apps/web/src/routes/_auth/users/new.tsx deleted file mode 100644 index 656eb1b..0000000 --- a/apps/web/src/routes/_auth/users/new.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createFileRoute } from "@tanstack/react-router"; -import { User } from "lucide-react"; - -import { PageHeader } from "@/components/page-header"; -import { UserForm } from "@/components/users/user-form"; - -export const Route = createFileRoute("/_auth/users/new")({ - component: RouteComponent, -}); - -function RouteComponent() { - return ( -
    - - -
    - ); -} From bb8de3f9273a45782d7517375a964ee848265762 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Wed, 11 Nov 2026 16:48:30 -0600 Subject: [PATCH 06/17] =?UTF-8?q?Usa=20el=20s=C3=ADmbolo=20del=20logo=20co?= =?UTF-8?q?mo=20=C3=ADcono=20del=20sidebar=20colapsado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/public/suni-mark.png | Bin 0 -> 12672 bytes apps/web/src/components/app-sidebar.tsx | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 apps/web/public/suni-mark.png diff --git a/apps/web/public/suni-mark.png b/apps/web/public/suni-mark.png new file mode 100644 index 0000000000000000000000000000000000000000..95608fd49a838c76f5853c014a339c27fa961e13 GIT binary patch literal 12672 zcma*Obx@mM&_DVFcL)}&#oZ~c0fI|$cPV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jee{>XEOU8U4 z0)%a}vEv0zQ8I#CdYkrboR3{E&T{w7vOnJL&# zK_U9(^8LT%;N0G}5uJ((f3Dx&)b1s@+Ee_fbCT2j&3vDt7cscJD*WV z$$Z-17DB=-f*mu9G{lYmaHPXVfT`IVCE)ZopX_pRkViIB7aop^y)Zx|%`qSM#%O4B zdIumbzYWIf8m~a2MxI~15Pt|9RujU757H+0%YlI=CExby`n<^m(%*sB761RM}pDGrCUI-2}8sJlRQja0mLL&-nevPdcV$I@)s zmtSmf)_G_obap*pPgQ(x@D+XpmZl>S43#J=+qEOQRbF*{>R`$G9$E@}OyvzL7cYC^ z#7Qog8jcm0Z)d`f%ueh_AX%1im!4aG{jX0~pRwLnL8^Gn(OOkFPvk!s4hA1uzfuZ1?N3^bWVX^) zUA-e zd1P_XNpcJN^^*#je-iS^^dFTWL`wnugdH<3*TrlMRZ}jV$(?#?)>Q7 z+=uV0sd57Yg!Wy;HuS9Vz&xm$kOsW)2IHO8qBb2F!#`dbTx8+umP4YfOI@>${q5!s zf*Gb9rk9Mrs>vN441sBfcf3Lr*5;)s6I7U!=#0%-dfdtea^l%1jQeSuUgWXVjCJG7l7}$HTGIZv1b=`RaadKA@r*Ecm?l_{wNzDD>VOit zrW)0>Dn(nPE7GSoCWHs=p@L-<(Iq%s7JYcww>d07#jCv=SpsS1_$A*C$MCa1VrSYy>sGP=?K9BuUVrx4M) { /> } tooltip="Suni" > - S + From efdca8f0fc0918c3af39e534177370941db443a1 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Wed, 11 Nov 2026 17:48:07 -0600 Subject: [PATCH 07/17] Unifica filtros, controles y detalle de cliente, y aligera el sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Une los filtros de clientes, sucursales y contactos en un FilterBar compartido y fija una sola altura de 36px para inputs, grupos y selects. Rediseña el detalle de cliente con PageHeader, una tarjeta de datos y pestañas subrayadas que deshabilitan las secciones sin contenido. Marca las tarjetas archivadas con una franja que explica el motivo, separa Inicio de los módulos y cambia los bloques sólidos del sidebar por un tinte claro. --- .../customers/branches/branch-header.tsx | 9 +- .../components/customers/branches/card.tsx | 22 +- .../components/customers/branches/filters.tsx | 146 +++++-------- .../components/customers/branches/grid.tsx | 16 +- .../customers/contacts/contact-card.tsx | 26 +-- .../customers/contacts/contact-filters.tsx | 89 +++----- .../customers/contacts/contact-grid.tsx | 24 ++- .../components/customers/customer-card.tsx | 19 +- .../components/customers/customer-filters.tsx | 63 ++---- apps/web/src/components/customers/data.tsx | 93 +++++---- .../customers/shared/archive-state.ts | 26 +++ .../customers/shared/archived-banner.tsx | 18 ++ .../customers/shared/filter-badge.tsx | 20 -- .../customers/shared/filter-bar.tsx | 69 +++++++ apps/web/src/components/nav-bar.tsx | 97 +++++---- apps/web/src/components/nav-items.ts | 8 +- apps/web/src/components/page-header.tsx | 4 +- .../$customerId/branches/$branchId/index.tsx | 39 ++-- .../_auth/customers/$customerId/index.tsx | 194 ++++++++---------- apps/web/src/routes/_auth/dashboard.tsx | 2 +- packages/ui/src/components/input-group.tsx | 2 +- packages/ui/src/components/input.tsx | 2 +- packages/ui/src/components/react-select.tsx | 2 +- packages/ui/src/components/sidebar.tsx | 6 +- packages/ui/src/components/tabs.tsx | 6 +- packages/ui/src/styles/globals.css | 10 - 26 files changed, 501 insertions(+), 511 deletions(-) create mode 100644 apps/web/src/components/customers/shared/archived-banner.tsx delete mode 100644 apps/web/src/components/customers/shared/filter-badge.tsx create mode 100644 apps/web/src/components/customers/shared/filter-bar.tsx diff --git a/apps/web/src/components/customers/branches/branch-header.tsx b/apps/web/src/components/customers/branches/branch-header.tsx index 830680d..4e3df8c 100644 --- a/apps/web/src/components/customers/branches/branch-header.tsx +++ b/apps/web/src/components/customers/branches/branch-header.tsx @@ -6,7 +6,7 @@ import { Link } from "@tanstack/react-router"; import { Archive, ArchiveRestore, Building2, Pencil } from "lucide-react"; import { useState } from "react"; -import { archiveState } from "../shared/archive-state"; +import { archiveState, archivedLabel } from "../shared/archive-state"; import { ChangeBranchStatusDialog } from "./change-branch-status-dialog"; type Branch = AppRouterOutputs["branches"]["get"]; @@ -17,8 +17,9 @@ interface BranchHeaderProps { } export function BranchHeader({ branch, onEdit }: BranchHeaderProps) { - const { isOwnArchived, isCustomerArchived, isArchived } = - archiveState(branch); + const archive = archiveState(branch); + + const { isOwnArchived, isCustomerArchived, isArchived } = archive; const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); @@ -59,7 +60,7 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) { {isArchived ? ( - {isCustomerArchived ? "Cliente archivado" : "Archivada"} + {archivedLabel(archive, "Archivada")} ) : null}
    diff --git a/apps/web/src/components/customers/branches/card.tsx b/apps/web/src/components/customers/branches/card.tsx index 3b954d2..b5fcb3b 100644 --- a/apps/web/src/components/customers/branches/card.tsx +++ b/apps/web/src/components/customers/branches/card.tsx @@ -1,4 +1,3 @@ -import { Badge } from "@suni/ui/components/badge"; import { Button } from "@suni/ui/components/button"; import { DropdownMenu, @@ -21,8 +20,10 @@ import { } from "lucide-react"; import { useState } from "react"; +import { ArchivedBanner } from "@/components/customers/shared/archived-banner"; + import { ArchiveMenuItem } from "../shared/archive-menu-item"; -import { archiveState } from "../shared/archive-state"; +import { archiveState, archivedLabel } from "../shared/archive-state"; import { BranchFormDialog } from "./branch-form-dialog"; import { ChangeBranchStatusDialog } from "./change-branch-status-dialog"; import { branchImageSrc, formatAddress } from "./util/branch-address"; @@ -53,19 +54,14 @@ function BranchImage({ name, src, isArchived }: BranchImageProps) { src={src} />
    - {isArchived && ( - - - Archivada - - )}
    ); } export default function BranchCard({ branch, customer }: BranchCardProps) { - const { isOwnArchived, isCustomerArchived, isArchived, parentHint } = - archiveState(branch); + const archive = archiveState(branch); + const { isOwnArchived, isCustomerArchived, isArchived, parentHint } = archive; + const archivedText = archivedLabel(archive, "Archivada"); const [isUpdateFormOpen, setIsUpdateFormOpen] = useState(false); const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); @@ -77,10 +73,11 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { className={cn( "group bg-card relative flex h-full flex-col overflow-hidden rounded-xl border transition-colors duration-200", isArchived - ? "border-border/60 bg-archived-pattern shadow-sm" + ? "border-border bg-muted/30" : "border-border hover:border-primary/30 hover:shadow-md" )} > + {archivedText ? : null} {branch.name} + {archivedText ? ( + , {archivedText} + ) : null}

    diff --git a/apps/web/src/components/customers/branches/filters.tsx b/apps/web/src/components/customers/branches/filters.tsx index 86c81b1..d53400f 100644 --- a/apps/web/src/components/customers/branches/filters.tsx +++ b/apps/web/src/components/customers/branches/filters.tsx @@ -1,9 +1,7 @@ -import { Button } from "@suni/ui/components/button"; -import { Input } from "@suni/ui/components/input"; import { ReactSelect } from "@suni/ui/components/react-select"; -import { X } from "lucide-react"; +import type { ReactNode } from "react"; -import { FilterBadge } from "@/components/customers/shared/filter-badge"; +import { FilterBar } from "@/components/customers/shared/filter-bar"; import { DEFAULT_BRANCH_FILTERS } from "@/components/customers/shared/filters"; import type { BranchFilters, @@ -16,14 +14,13 @@ interface Option { } const STATUS_OPTIONS: Option[] = [ - { value: "all", label: "Todas" }, - { value: "active", label: "Activas" }, - { value: "archived", label: "Archivadas" }, + { value: "all", label: "Todas las sucursales" }, + { value: "active", label: "Sucursales activas" }, + { value: "archived", label: "Sucursales archivadas" }, ]; -const MAX_CUSTOMER_BADGE_LENGTH = 20; - interface BranchesFiltersProps { + action?: ReactNode; filters: BranchFilters; hasFilters: boolean; onFiltersChange: (filters: BranchFilters) => void; @@ -35,102 +32,57 @@ export function BranchesFilters({ hasFilters, onFiltersChange, customers, + action, }: BranchesFiltersProps) { - const showCustomerFilter = !!customers; - - const customerOptions: Option[] = [ - { value: "all", label: "Todos los clientes" }, - ...(customers ?? []).map((c) => ({ value: c.id, label: c.name })), - ]; - - const selectedCustomerName = - filters.customerId === "all" - ? null - : (customers?.find((c) => c.id === filters.customerId)?.name ?? null); + const customerOptions: Option[] = (customers ?? []).map((c) => ({ + value: c.id, + label: c.name, + })); const update = (patch: Partial) => onFiltersChange({ ...filters, ...patch }); return ( -
    -
    - update({ name: event.target.value })} - placeholder="Buscar por nombre de sucursal..." - type="text" - value={filters.name} - /> + onFiltersChange(DEFAULT_BRANCH_FILTERS)} + onSearchChange={(name) => update({ name })} + search={filters.name} + searchLabel="Buscar sucursal" + > + {customers ? ( | null) => - update({ status: option?.value ?? "all" }) + aria-label="Filtrar por cliente" + className="w-full lg:w-64" + isClearable + onChange={(option: Option | null) => + update({ customerId: option?.value ?? "all" }) + } + options={customerOptions} + // "all" is the empty state, so it shows as the placeholder and offers nothing to clear. + placeholder="Todos los clientes" + value={ + filters.customerId === "all" + ? null + : (customerOptions.find( + (opt) => opt.value === filters.customerId + ) ?? { + value: filters.customerId, + label: "Cliente seleccionado", + }) } - options={STATUS_OPTIONS} - placeholder="Estatus" - value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} /> -
    - - {showCustomerFilter && ( -
    - - update({ customerId: option?.value ?? "all" }) - } - options={customerOptions} - placeholder="Cliente" - value={customerOptions.find( - (opt) => opt.value === filters.customerId - )} - /> -
    - )} - - {hasFilters && ( -
    - - Filtros activos: - - - {filters.name.trim() && ( - update({ name: "" })}> - Nombre: “{filters.name.trim()}” - - )} - - {filters.status !== "all" && ( - update({ status: "all" })}> - Estatus:{" "} - { - STATUS_OPTIONS.find((opt) => opt.value === filters.status) - ?.label - } - - )} - - {showCustomerFilter && selectedCustomerName && ( - update({ customerId: "all" })}> - Cliente:{" "} - {selectedCustomerName.length > MAX_CUSTOMER_BADGE_LENGTH - ? `${selectedCustomerName.slice(0, MAX_CUSTOMER_BADGE_LENGTH)}...` - : selectedCustomerName} - - )} - - -
    - )} -
    + ) : null} + | null) => + update({ status: option?.value ?? "all" }) + } + options={STATUS_OPTIONS} + value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} + /> + ); } diff --git a/apps/web/src/components/customers/branches/grid.tsx b/apps/web/src/components/customers/branches/grid.tsx index b6fc398..c2f2cd1 100644 --- a/apps/web/src/components/customers/branches/grid.tsx +++ b/apps/web/src/components/customers/branches/grid.tsx @@ -1,5 +1,6 @@ import { skipToken } from "@tanstack/react-query"; import { Building2 } from "lucide-react"; +import type { ReactNode } from "react"; import { useMemo, useState } from "react"; import { NewEntityButton } from "@/components/customers/new-entity-button"; @@ -16,6 +17,7 @@ import BranchCard from "./card"; import { BranchesFilters } from "./filters"; interface BranchesListProps { + action?: ReactNode; filters: BranchFilters; onFiltersChange: (filters: BranchFilters) => void; /** Scopes the list to one customer and hides the customer filter. */ @@ -25,6 +27,7 @@ interface BranchesListProps { export function BranchesList({ filters, onFiltersChange, + action, customerId, }: BranchesListProps) { const pickedCustomerId = @@ -53,6 +56,7 @@ export function BranchesList({ return ( <> -
    -

    Sucursales

    - {canCreate ? ( - - ) : null} -
    - + ) : null + } customerId={customerId} filters={filters} onFiltersChange={setFilters} diff --git a/apps/web/src/components/customers/contacts/contact-card.tsx b/apps/web/src/components/customers/contacts/contact-card.tsx index 813489e..23ca2df 100644 --- a/apps/web/src/components/customers/contacts/contact-card.tsx +++ b/apps/web/src/components/customers/contacts/contact-card.tsx @@ -1,5 +1,4 @@ import type { AppRouterOutputs } from "@suni/api/routers/index"; -import { Badge } from "@suni/ui/components/badge"; import { Button } from "@suni/ui/components/button"; import { DropdownMenu, @@ -22,8 +21,10 @@ import { } from "lucide-react"; import { useState } from "react"; +import { ArchivedBanner } from "@/components/customers/shared/archived-banner"; + import { ArchiveMenuItem } from "../shared/archive-menu-item"; -import { archiveState } from "../shared/archive-state"; +import { archiveState, archivedLabel } from "../shared/archive-state"; import { ChangeContactStatusDialog } from "./change-contact-status-dialog"; import { ContactFormDialog } from "./contact-form-dialog"; @@ -157,13 +158,17 @@ function ContactPhone({ contact }: { contact: Contact }) { } export default function ContactCard({ contact, customer }: ContactCardProps) { + const archive = archiveState(contact); + const { isOwnArchived, isCustomerArchived, isBranchArchived, parentHint, isArchived, - } = archiveState(contact); + } = archive; + + const archivedText = archivedLabel(archive, "Archivado"); const [isUpdateFormOpen, setIsUpdateFormOpen] = useState(false); const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); @@ -174,10 +179,11 @@ export default function ContactCard({ contact, customer }: ContactCardProps) { className={cn( "group bg-card relative flex h-full flex-col overflow-hidden rounded-xl border transition-colors duration-200", isArchived - ? "border-border/60 bg-archived-pattern shadow-sm" + ? "border-border bg-muted/30" : "border-border hover:border-primary/30 hover:shadow-md" )} > + {archivedText ? : null}
    @@ -188,6 +194,9 @@ export default function ContactCard({ contact, customer }: ContactCardProps) { )} > {contact.name} + {archivedText ? ( + , {archivedText} + ) : null}

    {contact.position && ( @@ -232,15 +241,6 @@ export default function ContactCard({ contact, customer }: ContactCardProps) {
    - - {isArchived && ( -
    - - - Archivado - -
    - )}
    { } const STATUS_OPTIONS: Option[] = [ - { value: "all", label: "Todos" }, - { value: "active", label: "Activos" }, - { value: "archived", label: "Archivados" }, + { value: "all", label: "Todos los contactos" }, + { value: "active", label: "Contactos activos" }, + { value: "archived", label: "Contactos archivados" }, ]; interface ContactsFiltersProps { + action?: ReactNode; filters: ContactFilters; hasFilters: boolean; onFiltersChange: (filters: ContactFilters) => void; @@ -31,67 +30,29 @@ export function ContactsFilters({ filters, hasFilters, onFiltersChange, + action, }: ContactsFiltersProps) { - const hasName = filters.name.trim() !== ""; - const hasStatus = filters.status !== "all"; - - const statusLabel = STATUS_OPTIONS.find( - (option) => option.value === filters.status - )?.label; - const update = (patch: Partial) => onFiltersChange({ ...filters, ...patch }); return ( -
    -
    - update({ name: event.target.value })} - placeholder="Buscar por nombre..." - type="text" - value={filters.name} - /> - | null) => - update({ status: option?.value ?? "all" }) - } - options={STATUS_OPTIONS} - placeholder="Estatus" - value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} - /> -
    - - {hasFilters && ( -
    - - Filtros activos: - - - {hasName && ( - update({ name: "" })}> - Nombre: “{filters.name.trim()}” - - )} - - {hasStatus && ( - update({ status: "all" })}> - Estatus: {statusLabel} - - )} - - -
    - )} -
    + onFiltersChange(DEFAULT_CONTACT_FILTERS)} + onSearchChange={(name) => update({ name })} + search={filters.name} + searchLabel="Buscar contacto" + > + | null) => + update({ status: option?.value ?? "all" }) + } + options={STATUS_OPTIONS} + value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} + /> + ); } diff --git a/apps/web/src/components/customers/contacts/contact-grid.tsx b/apps/web/src/components/customers/contacts/contact-grid.tsx index 2eb6f23..2acb9e6 100644 --- a/apps/web/src/components/customers/contacts/contact-grid.tsx +++ b/apps/web/src/components/customers/contacts/contact-grid.tsx @@ -1,4 +1,5 @@ import { Users } from "lucide-react"; +import type { ReactNode } from "react"; import { useMemo, useState } from "react"; import { NewEntityButton } from "@/components/customers/new-entity-button"; @@ -14,6 +15,7 @@ import ContactCard from "./contact-card"; import { ContactsFilters } from "./contact-filters"; interface ContactsListProps { + action?: ReactNode; filters: ContactFilters; onFiltersChange: (filters: ContactFilters) => void; /** Scopes the list to one customer and hides the customer on each card. */ @@ -24,6 +26,7 @@ interface ContactsListProps { export function ContactsList({ filters, onFiltersChange, + action, customerId, branchId, }: ContactsListProps) { @@ -45,6 +48,7 @@ export function ContactsList({ return ( <> -
    -

    Contactos

    - {canCreate ? ( - - ) : null} -
    - + ) : null + } branchId={branchId} customerId={customerId} filters={filters} diff --git a/apps/web/src/components/customers/customer-card.tsx b/apps/web/src/components/customers/customer-card.tsx index 67bedab..24109ba 100644 --- a/apps/web/src/components/customers/customer-card.tsx +++ b/apps/web/src/components/customers/customer-card.tsx @@ -1,5 +1,4 @@ import type { AppRouterOutputs } from "@suni/api/routers/index"; -import { Badge } from "@suni/ui/components/badge"; import { Button } from "@suni/ui/components/button"; import { DropdownMenu, @@ -22,6 +21,8 @@ import { } from "lucide-react"; import { useState } from "react"; +import { ArchivedBanner } from "@/components/customers/shared/archived-banner"; + import { ChangeCustomerStatusDialog } from "./change-customer-status-dialog"; interface CustomerCardProps { @@ -38,10 +39,11 @@ export default function CustomerCard({ customer }: CustomerCardProps) { className={cn( "group bg-card relative flex h-full flex-col overflow-hidden rounded-xl border transition-colors duration-200", isArchived - ? "border-border/60 bg-archived-pattern shadow-sm" + ? "border-border bg-muted/30" : "border-border hover:border-primary/30 hover:shadow-md" )} > + {isArchived ? : null}
    {customer.name} + {isArchived ? ( + , Archivado + ) : null} @@ -134,16 +139,6 @@ export default function CustomerCard({ customer }: CustomerCardProps) {
    - - {/* Archived badge */} - {isArchived && ( -
    - - - Archivado - -
    - )}
    {/* View details footer */} diff --git a/apps/web/src/components/customers/customer-filters.tsx b/apps/web/src/components/customers/customer-filters.tsx index 6bd40fc..c61d3bd 100644 --- a/apps/web/src/components/customers/customer-filters.tsx +++ b/apps/web/src/components/customers/customer-filters.tsx @@ -1,12 +1,11 @@ import type { AppRouterOutputs } from "@suni/api/routers/index"; import { CUSTOMER_TYPES } from "@suni/db/schema/customer-enums"; -import { Button } from "@suni/ui/components/button"; -import { Input } from "@suni/ui/components/input"; import { ReactSelect } from "@suni/ui/components/react-select"; import { getRouteApi } from "@tanstack/react-router"; -import { X } from "lucide-react"; import { useMemo } from "react"; +import { FilterBar } from "@/components/customers/shared/filter-bar"; + const routeApi = getRouteApi("/_auth/customers/"); type Search = ReturnType; @@ -32,59 +31,41 @@ export default function CustomerFilters({ const setFilters = (filters: Partial) => navigate({ search: (prev) => ({ ...prev, ...filters }), replace: true }); - const typeOptions = useMemo(() => { - const count = (value: string) => - customers.filter((customer) => customer.type === value).length; - - return [ - { - value: "all" as const, - label: `Todos los tipos (${customers.length})`, - }, - ...CUSTOMER_TYPES.map((value) => ({ + const typeOptions = useMemo( + () => + CUSTOMER_TYPES.map((value) => ({ value, - label: `${value} (${count(value)})`, + label: `${value} (${customers.filter((c) => c.type === value).length})`, })), - ]; - }, [customers]); + [customers] + ); return ( -
    -
    - setFilters({ name: event.target.value })} - placeholder="Buscar por nombre..." - type="search" - value={name} - /> -
    + navigate({ search: {}, replace: true })} + onSearchChange={(value) => setFilters({ name: value })} + search={name} + searchLabel="Buscar por nombre" + > setFilters({ type: option?.value ?? "all" })} options={typeOptions} - placeholder="Filtrar por tipo..." - value={typeOptions.find((option) => option.value === type)} + // "all" is the empty state, so it shows as the placeholder and offers nothing to clear. + placeholder={`Todos los tipos (${customers.length})`} + value={typeOptions.find((option) => option.value === type) ?? null} /> setFilters({ status: option?.value ?? "active" })} options={statusOptions} value={statusOptions.find((option) => option.value === status)} /> - {hasFilters && ( - // Empty search falls back to the schema defaults. - - )} -
    + ); } diff --git a/apps/web/src/components/customers/data.tsx b/apps/web/src/components/customers/data.tsx index a8c1e93..c000ff8 100644 --- a/apps/web/src/components/customers/data.tsx +++ b/apps/web/src/components/customers/data.tsx @@ -1,62 +1,67 @@ import type { AppRouterOutputs } from "@suni/api/routers/index"; +import { cn } from "@suni/ui/lib/utils"; import { Link } from "@tanstack/react-router"; - -import { formatDate } from "@/lib/date-utils"; +import type { ReactNode } from "react"; interface CustomerDataProps { customer: AppRouterOutputs["customers"]["get"]; } -export function CustomerData({ customer }: CustomerDataProps) { +function Field({ + label, + className, + children, +}: { + label: string; + className?: string; + children: ReactNode; +}) { return ( -
    -
    -
    -
    Medio de adquisición:
    -
    {customer.acquisition}
    -
    - - {customer.seller && ( -
    -
    Vendedor:
    -
    - - {customer.seller.name} - -
    -
    - )} -
    +
    +
    {label}
    +
    {children}
    +
    + ); +} -
    -

    Dirección Fiscal

    -
    - +export function CustomerData({ customer }: CustomerDataProps) { + return ( +
    +
    + +
    {customer.street}, No. Ext. {customer.extNumber} {customer.intNumber && `, No. Int. ${customer.intNumber}`}, Colonia{" "} {customer.suburb} - - +
    {`${customer.city}, ${customer.state}, CP ${customer.postalCode}`} +
    +
    + + + + {customer.phone} + {customer.phoneExtension && ` ext. ${customer.phoneExtension}`} -
    -
    + -
    -
    Teléfono:
    -
    - {customer.phone} - {customer.phoneExtension && ` ext. ${customer.phoneExtension}`} -
    -
    + {customer.acquisition} - - Última actualización: {formatDate(customer.updatedAt)} - -
    + {customer.seller ? ( + + + {customer.seller.name} + + + ) : null} + + ); } diff --git a/apps/web/src/components/customers/shared/archive-state.ts b/apps/web/src/components/customers/shared/archive-state.ts index e0cc6aa..cd25112 100644 --- a/apps/web/src/components/customers/shared/archive-state.ts +++ b/apps/web/src/components/customers/shared/archive-state.ts @@ -4,6 +4,12 @@ interface Archivable { branch?: { archived: unknown } | null; } +const INHERITED_FROM = { + customer: " con el cliente", + branch: " con la sucursal", + self: "", +} as const; + // Mirrors the API rule: an archived customer or branch archives everything under it. export function archiveState(entity: Archivable) { const isOwnArchived = !!entity.archived; @@ -18,7 +24,19 @@ export function archiveState(entity: Archivable) { parentHint = "Desarchiva primero la sucursal"; } + // Parent first, like parentHint: the parent is what has to be unarchived first. + let archivedBy: keyof typeof INHERITED_FROM | null = null; + + if (isCustomerArchived) { + archivedBy = "customer"; + } else if (isBranchArchived) { + archivedBy = "branch"; + } else if (isOwnArchived) { + archivedBy = "self"; + } + return { + archivedBy, isOwnArchived, isCustomerArchived, isBranchArchived, @@ -26,3 +44,11 @@ export function archiveState(entity: Archivable) { parentHint, }; } + +/** "Archivado", "Archivada con el cliente"…, shared by cards and detail headers. */ +export function archivedLabel( + { archivedBy }: ReturnType, + base: "Archivado" | "Archivada" +) { + return archivedBy ? `${base}${INHERITED_FROM[archivedBy]}` : null; +} diff --git a/apps/web/src/components/customers/shared/archived-banner.tsx b/apps/web/src/components/customers/shared/archived-banner.tsx new file mode 100644 index 0000000..ef49c68 --- /dev/null +++ b/apps/web/src/components/customers/shared/archived-banner.tsx @@ -0,0 +1,18 @@ +import { Archive } from "lucide-react"; + +interface ArchivedBannerProps { + label: string; +} + +/** Opens an archived card so the state is seen first; the card title carries it for screen readers. */ +export function ArchivedBanner({ label }: ArchivedBannerProps) { + return ( +
    + + {label} +
    + ); +} diff --git a/apps/web/src/components/customers/shared/filter-badge.tsx b/apps/web/src/components/customers/shared/filter-badge.tsx deleted file mode 100644 index f06b74e..0000000 --- a/apps/web/src/components/customers/shared/filter-badge.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { X } from "lucide-react"; -import type { ReactNode } from "react"; - -interface FilterBadgeProps { - children: ReactNode; - onClear: () => void; -} - -export function FilterBadge({ children, onClear }: FilterBadgeProps) { - return ( - - ); -} diff --git a/apps/web/src/components/customers/shared/filter-bar.tsx b/apps/web/src/components/customers/shared/filter-bar.tsx new file mode 100644 index 0000000..7509401 --- /dev/null +++ b/apps/web/src/components/customers/shared/filter-bar.tsx @@ -0,0 +1,69 @@ +import { Button } from "@suni/ui/components/button"; +import { + InputGroup, + InputGroupAddon, + InputGroupInput, +} from "@suni/ui/components/input-group"; +import { Search, X } from "lucide-react"; +import { useRef } from "react"; +import type { ReactNode } from "react"; + +interface FilterBarProps { + search: string; + searchLabel: string; + onSearchChange: (search: string) => void; + hasFilters: boolean; + onClear: () => void; + /** The selects, each sized by its caller. */ + children?: ReactNode; + action?: ReactNode; +} + +export function FilterBar({ + search, + searchLabel, + onSearchChange, + hasFilters, + onClear, + children, + action, +}: FilterBarProps) { + const searchRef = useRef(null); + + // The clear button unmounts once nothing is filtered, so focus moves to the search instead of the page. + const clear = () => { + onClear(); + searchRef.current?.focus(); + }; + + return ( + // Selects keep their width; the row wraps before the search gets squeezed next to the sidebar. +
    + + + + + onSearchChange(event.target.value)} + ref={searchRef} + placeholder={`${searchLabel}...`} + type="search" + value={search} + /> + + {children} + {hasFilters || action ? ( +
    + {hasFilters ? ( + + ) : null} + {action} +
    + ) : null} +
    + ); +} diff --git a/apps/web/src/components/nav-bar.tsx b/apps/web/src/components/nav-bar.tsx index 4f87507..837b0b1 100644 --- a/apps/web/src/components/nav-bar.tsx +++ b/apps/web/src/components/nav-bar.tsx @@ -5,20 +5,20 @@ import { } from "@suni/ui/components/collapsible"; import { SidebarGroup, - SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, + SidebarSeparator, useSidebar, } from "@suni/ui/components/sidebar"; import { Link, useRouterState } from "@tanstack/react-router"; import { ChevronRight } from "lucide-react"; import { useState } from "react"; -import { NAV_ENTRIES, isSection } from "@/components/nav-items"; +import { HOME_LINK, NAV_ENTRIES, isSection } from "@/components/nav-items"; import type { NavLink, NavSection } from "@/components/nav-items"; import { useIsAdmin } from "@/hooks/use-is-admin"; @@ -69,7 +69,13 @@ function NavSectionItem({ section, items, pathname }: NavSectionItemProps) { render={} > } + // The section stands in for its active page only while that page is hidden: section closed, or icons only. + render={ + + } > {label} @@ -93,53 +99,58 @@ function NavSectionItem({ section, items, pathname }: NavSectionItemProps) { ); } +function NavLinkItem({ link, pathname }: { link: NavLink; pathname: string }) { + const { to, label, icon: Icon } = link; + + return ( + + } + tooltip={label} + > + + {label} + + + ); +} + export function NavMain() { const pathname = useRouterState({ select: (s) => s.location.pathname }); const isAdmin = useIsAdmin(); const canSee = (link: NavLink) => isAdmin || !link.adminOnly; return ( - - Módulos - - {NAV_ENTRIES.map((entry) => { - if (!isSection(entry)) { - if (!canSee(entry)) { - return null; + <> + + + + + + + + + {NAV_ENTRIES.map((entry) => { + if (!isSection(entry)) { + return canSee(entry) ? ( + + ) : null; } - const { to, label, icon: Icon } = entry; - - return ( - - } - tooltip={label} - > - - {label} - - - ); - } - - const items = entry.items.filter(canSee); - - if (items.length === 0) { - return null; - } - - return ( - - ); - })} - - + const items = entry.items.filter(canSee); + + return items.length > 0 ? ( + + ) : null; + })} + + + ); } diff --git a/apps/web/src/components/nav-items.ts b/apps/web/src/components/nav-items.ts index f0c90e5..810f2ff 100644 --- a/apps/web/src/components/nav-items.ts +++ b/apps/web/src/components/nav-items.ts @@ -24,8 +24,14 @@ export interface NavSection { type NavEntry = NavLink | NavSection; +export const HOME_LINK: NavLink = { + to: "/dashboard", + label: "Inicio", + icon: Home, +}; + +/** The modules, listed below Inicio in the sidebar. */ export const NAV_ENTRIES: NavEntry[] = [ - { to: "/dashboard", label: "Inicio", icon: Home }, { to: "/users", label: "Usuarios", icon: Users, adminOnly: true }, { label: "Ventas", diff --git a/apps/web/src/components/page-header.tsx b/apps/web/src/components/page-header.tsx index ca0e840..49f6ccf 100644 --- a/apps/web/src/components/page-header.tsx +++ b/apps/web/src/components/page-header.tsx @@ -4,7 +4,7 @@ import type { ReactNode } from "react"; interface PageHeaderProps { icon: LucideIcon; title: string; - description: string; + description: ReactNode; actions?: ReactNode; } @@ -23,7 +23,7 @@ export function PageHeader({

    {title}

    -

    {description}

    +
    {description}
    {actions ? (
    {actions}
    diff --git a/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx index 6be6d30..d7b01b2 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx @@ -1,3 +1,4 @@ +import { Badge } from "@suni/ui/components/badge"; import { Tabs, TabsContent, @@ -6,7 +7,6 @@ import { } from "@suni/ui/components/tabs"; import { useSuspenseQuery } from "@tanstack/react-query"; import { createFileRoute, redirect } from "@tanstack/react-router"; -import { FileText, FolderOpen, HardHat, Info, Users } from "lucide-react"; import type { ReactNode } from "react"; import { useState } from "react"; @@ -45,14 +45,13 @@ export const Route = createFileRoute( }); const TABS = [ - { value: "info", label: "Información general", icon: Info }, - { value: "quotations", label: "Cotizaciones", icon: FileText }, - { value: "files", label: "Archivos", icon: FolderOpen }, - { value: "contacts", label: "Contactos", icon: Users }, + { value: "info", label: "Información general" }, + { value: "quotations", label: "Cotizaciones" }, + { value: "files", label: "Archivos" }, + { value: "contacts", label: "Contactos" }, { value: "technical-requirements", label: "Requerimientos Técnicos", - icon: HardHat, }, ] as const; @@ -95,14 +94,26 @@ function RouteComponent() { setIsUpdateFormOpen(true)} /> - - {TABS.map(({ value, label, icon: Icon }) => ( - - - {label} - - ))} - +
    + + {TABS.map(({ value, label }) => ( + // Tabs without content yet stay visible but disabled, so the roadmap shows without dead ends. + + {label} + {content[value] === null ? ( + Pronto + ) : null} + + ))} + +
    {TABS.map(({ value }) => ( diff --git a/apps/web/src/routes/_auth/customers/$customerId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/index.tsx index c61d22a..ef2f503 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/index.tsx @@ -1,31 +1,23 @@ import { Badge } from "@suni/ui/components/badge"; -import { Button, buttonVariants } from "@suni/ui/components/button"; +import { Button } from "@suni/ui/components/button"; import { Tabs, TabsList, TabsTrigger, TabsContent, } from "@suni/ui/components/tabs"; -import { cn } from "@suni/ui/lib/utils"; import { useSuspenseQuery } from "@tanstack/react-query"; import { createFileRoute, Link } from "@tanstack/react-router"; -import { - Archive, - ArchiveRestore, - ContactRound, - FileText, - FolderOpen, - KeyRound, - MapPin, - ShoppingCart, - Users, -} from "lucide-react"; +import { Archive, ArchiveRestore, ContactRound, Pencil } from "lucide-react"; import { useState } from "react"; +import type { ReactNode } from "react"; import { BranchesGrid } from "@/components/customers/branches/grid"; import { ChangeCustomerStatusDialog } from "@/components/customers/change-customer-status-dialog"; import { ContactsGrid } from "@/components/customers/contacts/contact-grid"; import { CustomerData } from "@/components/customers/data"; +import { PageHeader } from "@/components/page-header"; +import { formatDate } from "@/lib/date-utils"; import { orpc } from "@/utils/orpc"; export const Route = createFileRoute("/_auth/customers/$customerId/")({ @@ -40,12 +32,12 @@ export const Route = createFileRoute("/_auth/customers/$customerId/")({ }); const TABS = [ - { value: "branches", label: "Sucursales", icon: MapPin }, - { value: "contacts", label: "Contactos", icon: Users }, - { value: "quotes", label: "Cotizaciones", icon: FileText }, - { value: "files", label: "Documentos Fiscales", icon: FolderOpen }, - { value: "orders", label: "Órdenes de Compra", icon: ShoppingCart }, - { value: "billing-portal", label: "Portal de facturación", icon: KeyRound }, + { value: "branches", label: "Sucursales" }, + { value: "contacts", label: "Contactos" }, + { value: "quotes", label: "Cotizaciones" }, + { value: "files", label: "Documentos Fiscales" }, + { value: "orders", label: "Órdenes de Compra" }, + { value: "billing-portal", label: "Portal de facturación" }, ] as const; function RouteComponent() { @@ -59,82 +51,59 @@ function RouteComponent() { const isArchived = !!customer.archived; const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); + const content: Record<(typeof TABS)[number]["value"], ReactNode> = { + branches: , + contacts: , + quotes: null, + files: null, + orders: null, + "billing-portal": null, + }; + return ( -
    -
    -
    -
    -
    - -
    -
    -

    + + {isArchived ? null : ( +

    + + Editar + + )} +
    -
    -
    -

    {customer.rfc}

    - + ) : ( + )} - > + {isArchived ? "Desarchivar" : "Archivar"} + + + } + description={ +
    + {customer.rfc} + {customer.type} - + + Actualizado {formatDate(customer.updatedAt)}
    -
    -
    - {isArchived ? null : ( - - Editar - - )} - -
    -
    + } + icon={ContactRound} + title={customer.name} + /> + {isArchived ? ( +

    + + Este cliente está archivado. Desarchívalo para editarlo o agregarle + sucursales y contactos. +

    + ) : null} + - + {/* Six tabs don't fit a phone; scroll them instead of widening the page. */} -
    - - {TABS.map(({ value, label, icon: Icon }) => ( - - +
    + + {TABS.map(({ value, label }) => ( + // Tabs without content yet stay visible but disabled, so the roadmap shows without dead ends. + {label} + {content[value] === null ? ( + Pronto + ) : null} ))}
    - - - - - - + {TABS.map(({ value }) => ( + + {content[value]} + + ))}
    ); diff --git a/apps/web/src/routes/_auth/dashboard.tsx b/apps/web/src/routes/_auth/dashboard.tsx index e1ca53e..361c580 100644 --- a/apps/web/src/routes/_auth/dashboard.tsx +++ b/apps/web/src/routes/_auth/dashboard.tsx @@ -25,7 +25,7 @@ function RouteComponent() { : [entry]; for (const link of links) { - if (link.to !== "/dashboard" && (isAdmin || !link.adminOnly)) { + if (isAdmin || !link.adminOnly) { shortcuts.push(link); } } diff --git a/packages/ui/src/components/input-group.tsx b/packages/ui/src/components/input-group.tsx index f8faf77..dfad241 100644 --- a/packages/ui/src/components/input-group.tsx +++ b/packages/ui/src/components/input-group.tsx @@ -12,7 +12,7 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) { data-slot="input-group" role="group" className={cn( - "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", + "group/input-group relative flex h-9 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className )} {...props} diff --git a/packages/ui/src/components/input.tsx b/packages/ui/src/components/input.tsx index 32d1520..6ed6e4d 100644 --- a/packages/ui/src/components/input.tsx +++ b/packages/ui/src/components/input.tsx @@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) { type={type} data-slot="input" className={cn( - "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 read-only:cursor-default read-only:bg-muted/60 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", + "h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 read-only:cursor-default read-only:bg-muted/60 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className )} {...props} diff --git a/packages/ui/src/components/react-select.tsx b/packages/ui/src/components/react-select.tsx index 61cf740..b69c2e9 100644 --- a/packages/ui/src/components/react-select.tsx +++ b/packages/ui/src/components/react-select.tsx @@ -13,7 +13,7 @@ export const selectClassNames = { control: (state) => cn( // Mirrors Input so selects line up with text fields; min-h needs ! to beat react-select's base minHeight of 38px. - "min-h-8! rounded-lg border border-input bg-transparent px-2.5 text-base transition-colors md:text-sm dark:bg-input/30", + "min-h-9! rounded-lg border border-input bg-transparent px-2.5 text-base transition-colors md:text-sm dark:bg-input/30", state.isFocused && "border-ring ring-3 ring-ring/50", // aria-invalid sits on the inner input, so Input's aria-invalid: variants can't reach this box. isInvalid(state.selectProps["aria-invalid"]) && diff --git a/packages/ui/src/components/sidebar.tsx b/packages/ui/src/components/sidebar.tsx index eefbbda..d0dc0c9 100644 --- a/packages/ui/src/components/sidebar.tsx +++ b/packages/ui/src/components/sidebar.tsx @@ -475,11 +475,11 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) { } const sidebarMenuButtonVariants = cva( - "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-primary data-active:font-medium data-active:text-sidebar-primary-foreground data-active:hover:bg-sidebar-primary data-active:hover:text-sidebar-primary-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", + "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-border/40 focus-visible:ring-2 active:bg-sidebar-border disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", { variants: { variant: { - default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", + default: "", outline: "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]", }, @@ -679,7 +679,7 @@ function SidebarMenuSubButton({ props: mergeProps<"a">( { className: cn( - "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent/50 focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", + "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-border/40 focus-visible:ring-2 active:bg-sidebar-border disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", className ), }, diff --git a/packages/ui/src/components/tabs.tsx b/packages/ui/src/components/tabs.tsx index 155efd4..7a77615 100644 --- a/packages/ui/src/components/tabs.tsx +++ b/packages/ui/src/components/tabs.tsx @@ -14,7 +14,7 @@ function TabsList({ return ( Date: Wed, 11 Nov 2026 18:44:12 -0600 Subject: [PATCH 08/17] Mueve el estado de archivado al pie de las tarjetas, junto a Desarchivar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reemplaza la franja superior por un pie que explica el motivo del archivado y, cuando la tarjeta es la archivada, ofrece Desarchivar ahí mismo. En clientes y sucursales ocupa el lugar de "Ver detalles" y el título archivado queda subrayado. Al cerrar el diálogo de estado el foco vuelve a la tarjeta. --- .../components/customers/branches/card.tsx | 46 +++++++++++++------ .../branches/change-branch-status-dialog.tsx | 4 ++ .../change-customer-status-dialog.tsx | 4 ++ .../contacts/change-contact-status-dialog.tsx | 4 ++ .../customers/contacts/contact-card.tsx | 20 ++++++-- .../components/customers/customer-card.tsx | 40 ++++++++++------ .../customers/shared/archived-banner.tsx | 18 -------- .../customers/shared/archived-footer.tsx | 35 ++++++++++++++ .../customers/shared/change-status-dialog.tsx | 6 ++- 9 files changed, 127 insertions(+), 50 deletions(-) delete mode 100644 apps/web/src/components/customers/shared/archived-banner.tsx create mode 100644 apps/web/src/components/customers/shared/archived-footer.tsx diff --git a/apps/web/src/components/customers/branches/card.tsx b/apps/web/src/components/customers/branches/card.tsx index b5fcb3b..47b0ea7 100644 --- a/apps/web/src/components/customers/branches/card.tsx +++ b/apps/web/src/components/customers/branches/card.tsx @@ -18,9 +18,9 @@ import { Pencil, Phone, } from "lucide-react"; -import { useState } from "react"; +import { useRef, useState } from "react"; -import { ArchivedBanner } from "@/components/customers/shared/archived-banner"; +import { ArchivedFooter } from "@/components/customers/shared/archived-footer"; import { ArchiveMenuItem } from "../shared/archive-menu-item"; import { archiveState, archivedLabel } from "../shared/archive-state"; @@ -65,11 +65,13 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { const [isUpdateFormOpen, setIsUpdateFormOpen] = useState(false); const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); + const cardRef = useRef(null); const address = formatAddress(branch); return ( <>
    - {archivedText ? : null} {branch.name} @@ -181,17 +184,29 @@ export default function BranchCard({ branch, customer }: BranchCardProps) { )}
    - -
    - - Ver detalles - - -
    - + {archivedText ? ( + setIsStatusDialogOpen(true) + : undefined + } + /> + ) : ( + +
    + + Ver detalles + + +
    + + )}
    ; open: boolean; onOpenChange: (open: boolean) => void; + finalFocus?: RefObject; } export function ChangeBranchStatusDialog({ branch, open, onOpenChange, + finalFocus, }: ChangeBranchStatusDialogProps) { const mutation = useArchiveBranch(); return ( ; open: boolean; onOpenChange: (open: boolean) => void; + finalFocus?: RefObject; } export function ChangeCustomerStatusDialog({ customer, open, onOpenChange, + finalFocus, }: ChangeCustomerStatusDialogProps) { const mutation = useArchiveCustomer(); return ( ; open: boolean; onOpenChange: (open: boolean) => void; + finalFocus?: RefObject; } export function ChangeContactStatusDialog({ contact, open, onOpenChange, + finalFocus, }: ChangeContactStatusDialogProps) { const mutation = useArchiveContact(); return ( (null); return ( <>
    - {archivedText ? : null}
    @@ -241,6 +242,18 @@ export default function ContactCard({ contact, customer }: ContactCardProps) {
    + + {archivedText ? ( + setIsStatusDialogOpen(true) + : undefined + } + /> + ) : null}
    (null); return ( <>
    - {isArchived ? : null}
    {customer.name} @@ -141,18 +144,29 @@ export default function CustomerCard({ customer }: CustomerCardProps) {
    - {/* View details footer */} - -
    - - Ver detalles - - -
    - + {isArchived ? ( + setIsStatusDialogOpen(true)} + /> + ) : ( + +
    + + Ver detalles + + +
    + + )}
    - - {label} -
    - ); -} diff --git a/apps/web/src/components/customers/shared/archived-footer.tsx b/apps/web/src/components/customers/shared/archived-footer.tsx new file mode 100644 index 0000000..4657728 --- /dev/null +++ b/apps/web/src/components/customers/shared/archived-footer.tsx @@ -0,0 +1,35 @@ +import { Button } from "@suni/ui/components/button"; +import { Archive } from "lucide-react"; + +interface ArchivedFooterProps { + label: string; + /** Names the card for screen readers, since every archived card has its own "Desarchivar". */ + name: string; + /** Absent when a parent is archived: that parent has to be unarchived first. */ + onUnarchive?: () => void; +} + +/** Closes an archived card with its state and, when possible, the way back. The title carries the state for screen readers. */ +export function ArchivedFooter({ + label, + name, + onUnarchive, +}: ArchivedFooterProps) { + return ( +
    + + + {label} + + {onUnarchive ? ( + + ) : null} +
    + ); +} diff --git a/apps/web/src/components/customers/shared/change-status-dialog.tsx b/apps/web/src/components/customers/shared/change-status-dialog.tsx index 356401a..8d85354 100644 --- a/apps/web/src/components/customers/shared/change-status-dialog.tsx +++ b/apps/web/src/components/customers/shared/change-status-dialog.tsx @@ -9,6 +9,7 @@ import { AlertDialogTitle, } from "@suni/ui/components/alert-dialog"; import { useState } from "react"; +import type { RefObject } from "react"; const ACTIONS = { archive: { @@ -40,6 +41,8 @@ interface ChangeStatusDialogProps { mutation: ArchiveMutation; open: boolean; onOpenChange: (open: boolean) => void; + /** Where focus lands on close; the button that opened the dialog may be gone once the status flips. */ + finalFocus?: RefObject; } export function ChangeStatusDialog({ @@ -48,6 +51,7 @@ export function ChangeStatusDialog({ mutation, open, onOpenChange, + finalFocus, }: ChangeStatusDialogProps) { // Freeze the status seen on open: the refetch after saving lands before the close animation ends. const [archivedOnOpen, setArchivedOnOpen] = useState(!!entity.archived); @@ -68,7 +72,7 @@ export function ChangeStatusDialog({ onOpenChange={(next) => !mutation.isPending && onOpenChange(next)} open={open} > - + ¿Quieres {action.label.toLowerCase()} {noun} {entity.name}? From c85fdccfa1f6cf6cdd582ef41b4ae18ad7a9967e Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 13:04:28 -0600 Subject: [PATCH 09/17] =?UTF-8?q?Muestra=20el=20estado=20como=20pesta?= =?UTF-8?q?=C3=B1as=20con=20conteo=20y=20el=20tipo=20como=20segmentado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clientes, sucursales y contactos cambian el select de estado por pestañas Activos, Archivados y Todos con su conteo, calculado en el cliente con la regla de archiveState. Dentro del detalle de cliente o sucursal el estado es un segmentado para no apilar dos filas de pestañas. El tipo de cliente pasa a un segmentado, la búsqueda ocupa todo el ancho con los filtros al final, y "Limpiar filtros" se reemplaza por un botón dentro del input. --- .../components/customers/branches/filters.tsx | 35 ++------- .../components/customers/branches/grid.tsx | 44 +++++++++-- .../customers/contacts/contact-filters.tsx | 40 ++-------- .../customers/contacts/contact-grid.tsx | 46 ++++++++--- .../components/customers/customer-filters.tsx | 58 +++++--------- .../customers/shared/filter-bar.tsx | 44 +++++------ .../components/customers/shared/filters.ts | 20 +++++ .../customers/shared/segmented-control.tsx | 45 +++++++++++ .../customers/shared/status-tabs.tsx | 77 +++++++++++++++++++ apps/web/src/routes/_auth/customers/index.tsx | 56 +++++++------- 10 files changed, 296 insertions(+), 169 deletions(-) create mode 100644 apps/web/src/components/customers/shared/segmented-control.tsx create mode 100644 apps/web/src/components/customers/shared/status-tabs.tsx diff --git a/apps/web/src/components/customers/branches/filters.tsx b/apps/web/src/components/customers/branches/filters.tsx index d53400f..0767025 100644 --- a/apps/web/src/components/customers/branches/filters.tsx +++ b/apps/web/src/components/customers/branches/filters.tsx @@ -2,37 +2,28 @@ import { ReactSelect } from "@suni/ui/components/react-select"; import type { ReactNode } from "react"; import { FilterBar } from "@/components/customers/shared/filter-bar"; -import { DEFAULT_BRANCH_FILTERS } from "@/components/customers/shared/filters"; -import type { - BranchFilters, - StatusFilter, -} from "@/components/customers/shared/filters"; +import type { BranchFilters } from "@/components/customers/shared/filters"; -interface Option { - value: T; +interface Option { + value: string; label: string; } -const STATUS_OPTIONS: Option[] = [ - { value: "all", label: "Todas las sucursales" }, - { value: "active", label: "Sucursales activas" }, - { value: "archived", label: "Sucursales archivadas" }, -]; - interface BranchesFiltersProps { action?: ReactNode; + /** The status control, when the page has no status tabs. */ + children?: ReactNode; filters: BranchFilters; - hasFilters: boolean; onFiltersChange: (filters: BranchFilters) => void; customers?: { id: string; name: string }[]; } export function BranchesFilters({ filters, - hasFilters, onFiltersChange, customers, action, + children, }: BranchesFiltersProps) { const customerOptions: Option[] = (customers ?? []).map((c) => ({ value: c.id, @@ -45,8 +36,6 @@ export function BranchesFilters({ return ( onFiltersChange(DEFAULT_BRANCH_FILTERS)} onSearchChange={(name) => update({ name })} search={filters.name} searchLabel="Buscar sucursal" @@ -54,7 +43,7 @@ export function BranchesFilters({ {customers ? ( update({ customerId: option?.value ?? "all" }) @@ -74,15 +63,7 @@ export function BranchesFilters({ } /> ) : null} - | null) => - update({ status: option?.value ?? "all" }) - } - options={STATUS_OPTIONS} - value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} - /> + {children} ); } diff --git a/apps/web/src/components/customers/branches/grid.tsx b/apps/web/src/components/customers/branches/grid.tsx index c2f2cd1..63ea5a5 100644 --- a/apps/web/src/components/customers/branches/grid.tsx +++ b/apps/web/src/components/customers/branches/grid.tsx @@ -7,9 +7,18 @@ import { NewEntityButton } from "@/components/customers/new-entity-button"; import { EntityGrid } from "@/components/customers/shared/entity-grid"; import { DEFAULT_BRANCH_FILTERS, + byStatus, + countByStatus, matchingName, } from "@/components/customers/shared/filters"; -import type { BranchFilters } from "@/components/customers/shared/filters"; +import type { + BranchFilters, + StatusFilter, +} from "@/components/customers/shared/filters"; +import { + StatusSegmented, + StatusTabs, +} from "@/components/customers/shared/status-tabs"; import { useListBranches } from "@/hooks/use-branches"; import { useListCustomers } from "@/hooks/use-customers"; @@ -34,7 +43,7 @@ export function BranchesList({ filters.customerId === "all" ? undefined : filters.customerId; const query = useListBranches({ - status: filters.status, + status: "all", customerId: customerId ?? pickedCustomerId, }); @@ -43,25 +52,38 @@ export function BranchesList({ customerId ? skipToken : { status: "all" } ); - const visibleBranches = useMemo( - () => matchingName(query.data ?? [], filters.name), + const rowsByStatus = useMemo( + () => byStatus(matchingName(query.data ?? [], filters.name)), [query.data, filters.name] ); + const visibleBranches = rowsByStatus[filters.status]; + const hasFilters = filters.name.trim() !== "" || - filters.status !== DEFAULT_BRANCH_FILTERS.status || (!customerId && filters.customerId !== DEFAULT_BRANCH_FILTERS.customerId); - return ( + const statusProps = { + counts: query.data ? countByStatus(rowsByStatus) : undefined, + gender: "feminine" as const, + onValueChange: (status: StatusFilter) => + onFiltersChange({ ...filters, status }), + value: filters.status, + }; + + // Inside the customer or branch detail the page already has tabs, so the status is a segmented control. + const isNested = customerId !== undefined; + + const list = ( <> + > + {isNested ? : null} + ); + + if (isNested) { + return list; + } + + return {list}; } interface BranchesGridProps { diff --git a/apps/web/src/components/customers/contacts/contact-filters.tsx b/apps/web/src/components/customers/contacts/contact-filters.tsx index 791674d..86d669c 100644 --- a/apps/web/src/components/customers/contacts/contact-filters.tsx +++ b/apps/web/src/components/customers/contacts/contact-filters.tsx @@ -1,58 +1,30 @@ -import { ReactSelect } from "@suni/ui/components/react-select"; import type { ReactNode } from "react"; import { FilterBar } from "@/components/customers/shared/filter-bar"; -import { DEFAULT_CONTACT_FILTERS } from "@/components/customers/shared/filters"; -import type { - ContactFilters, - StatusFilter, -} from "@/components/customers/shared/filters"; - -interface Option { - value: T; - label: string; -} - -const STATUS_OPTIONS: Option[] = [ - { value: "all", label: "Todos los contactos" }, - { value: "active", label: "Contactos activos" }, - { value: "archived", label: "Contactos archivados" }, -]; +import type { ContactFilters } from "@/components/customers/shared/filters"; interface ContactsFiltersProps { action?: ReactNode; + /** The status control, when the page has no status tabs. */ + children?: ReactNode; filters: ContactFilters; - hasFilters: boolean; onFiltersChange: (filters: ContactFilters) => void; } export function ContactsFilters({ filters, - hasFilters, onFiltersChange, action, + children, }: ContactsFiltersProps) { - const update = (patch: Partial) => - onFiltersChange({ ...filters, ...patch }); - return ( onFiltersChange(DEFAULT_CONTACT_FILTERS)} - onSearchChange={(name) => update({ name })} + onSearchChange={(name) => onFiltersChange({ ...filters, name })} search={filters.name} searchLabel="Buscar contacto" > - | null) => - update({ status: option?.value ?? "all" }) - } - options={STATUS_OPTIONS} - value={STATUS_OPTIONS.find((opt) => opt.value === filters.status)} - /> + {children} ); } diff --git a/apps/web/src/components/customers/contacts/contact-grid.tsx b/apps/web/src/components/customers/contacts/contact-grid.tsx index 2acb9e6..581b1ab 100644 --- a/apps/web/src/components/customers/contacts/contact-grid.tsx +++ b/apps/web/src/components/customers/contacts/contact-grid.tsx @@ -6,9 +6,18 @@ import { NewEntityButton } from "@/components/customers/new-entity-button"; import { EntityGrid } from "@/components/customers/shared/entity-grid"; import { DEFAULT_CONTACT_FILTERS, + byStatus, + countByStatus, matchingName, } from "@/components/customers/shared/filters"; -import type { ContactFilters } from "@/components/customers/shared/filters"; +import type { + ContactFilters, + StatusFilter, +} from "@/components/customers/shared/filters"; +import { + StatusSegmented, + StatusTabs, +} from "@/components/customers/shared/status-tabs"; import { useListContacts } from "@/hooks/use-contacts"; import ContactCard from "./contact-card"; @@ -31,28 +40,39 @@ export function ContactsList({ branchId, }: ContactsListProps) { const query = useListContacts({ - status: filters.status, + status: "all", customerId, branchId, }); - const visibleContacts = useMemo( - () => matchingName(query.data ?? [], filters.name), + const rowsByStatus = useMemo( + () => byStatus(matchingName(query.data ?? [], filters.name)), [query.data, filters.name] ); - const hasFilters = - filters.name.trim() !== "" || - filters.status !== DEFAULT_CONTACT_FILTERS.status; + const visibleContacts = rowsByStatus[filters.status]; - return ( + const hasFilters = filters.name.trim() !== ""; + + const statusProps = { + counts: query.data ? countByStatus(rowsByStatus) : undefined, + onValueChange: (status: StatusFilter) => + onFiltersChange({ ...filters, status }), + value: filters.status, + }; + + // Inside the customer or branch detail the page already has tabs, so the status is a segmented control. + const isNested = customerId !== undefined; + + const list = ( <> + > + {isNested ? : null} + ); + + if (isNested) { + return list; + } + + return {list}; } interface ContactsGridProps { diff --git a/apps/web/src/components/customers/customer-filters.tsx b/apps/web/src/components/customers/customer-filters.tsx index c61d3bd..06c3fcd 100644 --- a/apps/web/src/components/customers/customer-filters.tsx +++ b/apps/web/src/components/customers/customer-filters.tsx @@ -1,70 +1,50 @@ import type { AppRouterOutputs } from "@suni/api/routers/index"; import { CUSTOMER_TYPES } from "@suni/db/schema/customer-enums"; -import { ReactSelect } from "@suni/ui/components/react-select"; import { getRouteApi } from "@tanstack/react-router"; -import { useMemo } from "react"; import { FilterBar } from "@/components/customers/shared/filter-bar"; +import { SegmentedControl } from "@/components/customers/shared/segmented-control"; const routeApi = getRouteApi("/_auth/customers/"); type Search = ReturnType; -const statusOptions: { value: Search["status"]; label: string }[] = [ - { value: "active", label: "Clientes activos" }, - { value: "archived", label: "Clientes archivados" }, - { value: "all", label: "Todos los clientes" }, +const TYPE_OPTIONS: { value: Search["type"]; label: string }[] = [ + { value: "all", label: "Todos" }, + ...CUSTOMER_TYPES.map((value) => ({ value, label: value })), ]; interface CustomerFiltersProps { + /** Customers in the current tab and search, before the type filter, for the counts. */ customers: AppRouterOutputs["customers"]["list"][number][]; - hasFilters: boolean; } -export default function CustomerFilters({ - customers, - hasFilters, -}: CustomerFiltersProps) { - const { name, type, status } = routeApi.useSearch(); +export default function CustomerFilters({ customers }: CustomerFiltersProps) { + const { name, type } = routeApi.useSearch(); const navigate = routeApi.useNavigate(); const setFilters = (filters: Partial) => navigate({ search: (prev) => ({ ...prev, ...filters }), replace: true }); - const typeOptions = useMemo( - () => - CUSTOMER_TYPES.map((value) => ({ - value, - label: `${value} (${customers.filter((c) => c.type === value).length})`, - })), - [customers] - ); + const countOf = (value: Search["type"]) => + value === "all" + ? customers.length + : customers.filter((customer) => customer.type === value).length; return ( navigate({ search: {}, replace: true })} onSearchChange={(value) => setFilters({ name: value })} search={name} searchLabel="Buscar por nombre" > - setFilters({ type: option?.value ?? "all" })} - options={typeOptions} - // "all" is the empty state, so it shows as the placeholder and offers nothing to clear. - placeholder={`Todos los tipos (${customers.length})`} - value={typeOptions.find((option) => option.value === type) ?? null} - /> - setFilters({ status: option?.value ?? "active" })} - options={statusOptions} - value={statusOptions.find((option) => option.value === status)} + setFilters({ type: value })} + options={TYPE_OPTIONS.map((option) => ({ + ...option, + count: countOf(option.value), + }))} + value={type} /> ); diff --git a/apps/web/src/components/customers/shared/filter-bar.tsx b/apps/web/src/components/customers/shared/filter-bar.tsx index 7509401..fec2175 100644 --- a/apps/web/src/components/customers/shared/filter-bar.tsx +++ b/apps/web/src/components/customers/shared/filter-bar.tsx @@ -1,7 +1,7 @@ -import { Button } from "@suni/ui/components/button"; import { InputGroup, InputGroupAddon, + InputGroupButton, InputGroupInput, } from "@suni/ui/components/input-group"; import { Search, X } from "lucide-react"; @@ -12,9 +12,7 @@ interface FilterBarProps { search: string; searchLabel: string; onSearchChange: (search: string) => void; - hasFilters: boolean; - onClear: () => void; - /** The selects, each sized by its caller. */ + /** The filters, each sized by its caller, at the end of the row. */ children?: ReactNode; action?: ReactNode; } @@ -23,47 +21,47 @@ export function FilterBar({ search, searchLabel, onSearchChange, - hasFilters, - onClear, children, action, }: FilterBarProps) { const searchRef = useRef(null); - // The clear button unmounts once nothing is filtered, so focus moves to the search instead of the page. + // The clear button unmounts with the text, so focus goes back to the search instead of the page. const clear = () => { - onClear(); + onSearchChange(""); searchRef.current?.focus(); }; return ( - // Selects keep their width; the row wraps before the search gets squeezed next to the sidebar. -
    - +
    + onSearchChange(event.target.value)} - ref={searchRef} placeholder={`${searchLabel}...`} + ref={searchRef} type="search" value={search} /> + {search ? ( + + + + + + ) : null} {children} - {hasFilters || action ? ( -
    - {hasFilters ? ( - - ) : null} - {action} -
    - ) : null} + {action}
    ); } diff --git a/apps/web/src/components/customers/shared/filters.ts b/apps/web/src/components/customers/shared/filters.ts index 8ee4b3e..fbb6dce 100644 --- a/apps/web/src/components/customers/shared/filters.ts +++ b/apps/web/src/components/customers/shared/filters.ts @@ -2,6 +2,8 @@ import type { CUSTOMER_STATUSES } from "@suni/db/schema/customer-enums"; import { stripAccents } from "@/lib/string-utils"; +import { archiveState } from "./archive-state"; + export type StatusFilter = (typeof CUSTOMER_STATUSES)[number]; export interface BranchFilters { @@ -26,6 +28,24 @@ export const DEFAULT_CONTACT_FILTERS: ContactFilters = { status: "all", }; +/** Rows per status tab, using the same archive rule as the API. */ +export function byStatus[0]>( + rows: readonly T[] +): Record { + const archived = rows.filter((row) => archiveState(row).isArchived); + const active = rows.filter((row) => !archiveState(row).isArchived); + + return { active, archived, all: [...rows] }; +} + +export function countByStatus(byStatusRows: Record) { + return { + active: byStatusRows.active.length, + archived: byStatusRows.archived.length, + all: byStatusRows.all.length, + }; +} + export function byName(a: { name: string }, b: { name: string }) { return a.name.localeCompare(b.name, "es"); } diff --git a/apps/web/src/components/customers/shared/segmented-control.tsx b/apps/web/src/components/customers/shared/segmented-control.tsx new file mode 100644 index 0000000..211c525 --- /dev/null +++ b/apps/web/src/components/customers/shared/segmented-control.tsx @@ -0,0 +1,45 @@ +import { useId } from "react"; + +interface SegmentedControlProps { + legend: string; + value: T; + onValueChange: (value: T) => void; + /** `count` is omitted while loading, so no option shows a false zero. */ + options: readonly { value: T; label: string; count?: number }[]; +} + +/** Radios styled as segments: for a few options that should stay visible instead of hiding in a select. */ +export function SegmentedControl({ + legend, + value, + onValueChange, + options, +}: SegmentedControlProps) { + const name = useId(); + + return ( +
    + {legend} + {options.map((option) => ( + + ))} +
    + ); +} diff --git a/apps/web/src/components/customers/shared/status-tabs.tsx b/apps/web/src/components/customers/shared/status-tabs.tsx new file mode 100644 index 0000000..7454d32 --- /dev/null +++ b/apps/web/src/components/customers/shared/status-tabs.tsx @@ -0,0 +1,77 @@ +import { CUSTOMER_STATUSES } from "@suni/db/schema/customer-enums"; +import { + Tabs, + TabsContent, + TabsList, + TabsTrigger, +} from "@suni/ui/components/tabs"; +import type { ReactNode } from "react"; + +import type { StatusFilter } from "./filters"; +import { SegmentedControl } from "./segmented-control"; + +const LABELS = { + masculine: { active: "Activos", archived: "Archivados", all: "Todos" }, + feminine: { active: "Activas", archived: "Archivadas", all: "Todas" }, +} as const; + +interface StatusControlProps { + value: StatusFilter; + onValueChange: (status: StatusFilter) => void; + /** Omitted while loading, so no option shows a false zero. */ + counts?: Record; + gender?: keyof typeof LABELS; +} + +/** The status is the list's view, so it is a tab with its count, not one more filter. */ +export function StatusTabs({ + value, + onValueChange, + counts, + gender = "masculine", + children, +}: StatusControlProps & { children: ReactNode }) { + return ( + onValueChange(next)} + value={value} + > + + {CUSTOMER_STATUSES.map((status) => ( + + {LABELS[gender][status]} + {counts ? ( + + {counts[status]} + + ) : null} + + ))} + + +
    {children}
    +
    +
    + ); +} + +/** The status inside a page that already has tabs, so it does not read as a second row of sections. */ +export function StatusSegmented({ + value, + onValueChange, + counts, + gender = "masculine", +}: StatusControlProps) { + return ( + ({ + value: status, + label: LABELS[gender][status], + count: counts?.[status], + }))} + value={value} + /> + ); +} diff --git a/apps/web/src/routes/_auth/customers/index.tsx b/apps/web/src/routes/_auth/customers/index.tsx index bb22540..a2b477a 100644 --- a/apps/web/src/routes/_auth/customers/index.tsx +++ b/apps/web/src/routes/_auth/customers/index.tsx @@ -3,7 +3,6 @@ import { CUSTOMER_TYPES, } from "@suni/db/schema/customer-enums"; import { Button } from "@suni/ui/components/button"; -import { cn } from "@suni/ui/lib/utils"; import { Link, createFileRoute, @@ -15,9 +14,14 @@ import { z } from "zod"; import CustomerFilters from "@/components/customers/customer-filters"; import CustomerList from "@/components/customers/customer-list"; +import { + byStatus, + countByStatus, + matchingName, +} from "@/components/customers/shared/filters"; +import { StatusTabs } from "@/components/customers/shared/status-tabs"; import { PageHeader } from "@/components/page-header"; import { useListCustomers } from "@/hooks/use-customers"; -import { stripAccents } from "@/lib/string-utils"; /* oxlint-disable promise/prefer-await-to-then, github/no-then -- zod `.catch()` is not Promise.catch */ const searchSchema = z.object({ @@ -40,31 +44,26 @@ export const Route = createFileRoute("/_auth/customers/")({ function RouteComponent() { const { name, type, status } = Route.useSearch(); + const navigate = Route.useNavigate(); + // Fetch every status once so each tab shows its count and switching is instant. const { - data: customers = [], + data: customers, isError, isPending, - isPlaceholderData, - } = useListCustomers({ status }); + } = useListCustomers({ status: "all" }); - const matchingName = useMemo(() => { - const term = stripAccents(name.trim()).toLowerCase(); + const rowsByStatus = useMemo( + () => byStatus(matchingName(customers ?? [], name)), + [customers, name] + ); - return customers - .filter((customer) => - stripAccents(customer.name).toLowerCase().includes(term) - ) - .toSorted((a, b) => a.name.localeCompare(b.name, "es")); - }, [customers, name]); + const inTab = rowsByStatus[status]; const visibleCustomers = - type === "all" - ? matchingName - : matchingName.filter((customer) => customer.type === type); + type === "all" ? inTab : inTab.filter((customer) => customer.type === type); - const hasFilters = - name.trim() !== "" || type !== "all" || status !== defaultFilters.status; + const hasFilters = name.trim() !== "" || type !== "all"; return (
    @@ -84,23 +83,24 @@ function RouteComponent() { } /> - - - {/* Placeholder data is the previous filter's list; dim it until the new one arrives. */} -
    + navigate({ + search: (prev) => ({ ...prev, status: next }), + replace: true, + }) + } + value={status} > + -
    +
    ); } From cb0565e253113bfd4bf6428aa0e4e4bd393b1cd3 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 13:27:54 -0600 Subject: [PATCH 10/17] Abre sucursales y contactos en Activos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Las listas de sucursales y contactos usan Activos como estado por defecto, igual que clientes. Dentro del detalle de un cliente o sucursal archivado abren en Todos, porque ahí todo lo que cuelga también está archivado y Activos saldría vacío. --- apps/web/src/components/customers/branches/grid.tsx | 6 +++++- apps/web/src/components/customers/contacts/contact-grid.tsx | 6 +++++- apps/web/src/components/customers/shared/filters.ts | 4 ++-- apps/web/src/routes/_auth/branches/index.tsx | 2 +- apps/web/src/routes/_auth/contacts/index.tsx | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/customers/branches/grid.tsx b/apps/web/src/components/customers/branches/grid.tsx index 63ea5a5..7b6d707 100644 --- a/apps/web/src/components/customers/branches/grid.tsx +++ b/apps/web/src/components/customers/branches/grid.tsx @@ -122,7 +122,11 @@ interface BranchesGridProps { } export function BranchesGrid({ customerId, canCreate }: BranchesGridProps) { - const [filters, setFilters] = useState(DEFAULT_BRANCH_FILTERS); + // An archived customer archives all its branches, so "Activas" would always be empty. + const [filters, setFilters] = useState({ + ...DEFAULT_BRANCH_FILTERS, + status: canCreate ? "active" : "all", + }); return (
    diff --git a/apps/web/src/components/customers/contacts/contact-grid.tsx b/apps/web/src/components/customers/contacts/contact-grid.tsx index 581b1ab..f0d9e63 100644 --- a/apps/web/src/components/customers/contacts/contact-grid.tsx +++ b/apps/web/src/components/customers/contacts/contact-grid.tsx @@ -116,7 +116,11 @@ export function ContactsGrid({ branchId, canCreate, }: ContactsGridProps) { - const [filters, setFilters] = useState(DEFAULT_CONTACT_FILTERS); + // An archived parent archives everything under it, so "Activos" would always be empty. + const [filters, setFilters] = useState({ + ...DEFAULT_CONTACT_FILTERS, + status: canCreate ? "active" : "all", + }); return (
    diff --git a/apps/web/src/components/customers/shared/filters.ts b/apps/web/src/components/customers/shared/filters.ts index fbb6dce..329dec7 100644 --- a/apps/web/src/components/customers/shared/filters.ts +++ b/apps/web/src/components/customers/shared/filters.ts @@ -14,7 +14,7 @@ export interface BranchFilters { export const DEFAULT_BRANCH_FILTERS: BranchFilters = { name: "", - status: "all", + status: "active", customerId: "all", }; @@ -25,7 +25,7 @@ export interface ContactFilters { export const DEFAULT_CONTACT_FILTERS: ContactFilters = { name: "", - status: "all", + status: "active", }; /** Rows per status tab, using the same archive rule as the API. */ diff --git a/apps/web/src/routes/_auth/branches/index.tsx b/apps/web/src/routes/_auth/branches/index.tsx index f23c89d..7b4039b 100644 --- a/apps/web/src/routes/_auth/branches/index.tsx +++ b/apps/web/src/routes/_auth/branches/index.tsx @@ -10,7 +10,7 @@ import { PageHeader } from "@/components/page-header"; /* oxlint-disable promise/prefer-await-to-then, github/no-then -- zod `.catch()` is not Promise.catch */ const searchSchema = z.object({ name: z.string().default("").catch(""), - status: z.enum(CUSTOMER_STATUSES).default("all").catch("all"), + status: z.enum(CUSTOMER_STATUSES).default("active").catch("active"), customerId: z.string().default("all").catch("all"), }); /* oxlint-enable promise/prefer-await-to-then, github/no-then */ diff --git a/apps/web/src/routes/_auth/contacts/index.tsx b/apps/web/src/routes/_auth/contacts/index.tsx index c136a7c..5e7aea4 100644 --- a/apps/web/src/routes/_auth/contacts/index.tsx +++ b/apps/web/src/routes/_auth/contacts/index.tsx @@ -10,7 +10,7 @@ import { PageHeader } from "@/components/page-header"; /* oxlint-disable promise/prefer-await-to-then, github/no-then -- zod `.catch()` is not Promise.catch */ const searchSchema = z.object({ name: z.string().default("").catch(""), - status: z.enum(CUSTOMER_STATUSES).default("all").catch("all"), + status: z.enum(CUSTOMER_STATUSES).default("active").catch("active"), }); /* oxlint-enable promise/prefer-await-to-then, github/no-then */ From 18a36176930438786095fae0de209cf5751265ac Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 13:48:44 -0600 Subject: [PATCH 11/17] Quita la fecha de actualizado del detalle de cliente --- apps/web/src/routes/_auth/customers/$customerId/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/web/src/routes/_auth/customers/$customerId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/index.tsx index ef2f503..e4f64b7 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/index.tsx @@ -17,7 +17,6 @@ import { ChangeCustomerStatusDialog } from "@/components/customers/change-custom import { ContactsGrid } from "@/components/customers/contacts/contact-grid"; import { CustomerData } from "@/components/customers/data"; import { PageHeader } from "@/components/page-header"; -import { formatDate } from "@/lib/date-utils"; import { orpc } from "@/utils/orpc"; export const Route = createFileRoute("/_auth/customers/$customerId/")({ @@ -98,7 +97,6 @@ function RouteComponent() { {customer.type} - Actualizado {formatDate(customer.updatedAt)}
    } icon={ContactRound} From bae62f03474e8b16a8c56c6f82e6ff2eb6cbad5d Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 13:58:42 -0600 Subject: [PATCH 12/17] =?UTF-8?q?Elimina=20date-utils,=20que=20qued=C3=B3?= =?UTF-8?q?=20sin=20usos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/lib/date-utils.ts | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 apps/web/src/lib/date-utils.ts diff --git a/apps/web/src/lib/date-utils.ts b/apps/web/src/lib/date-utils.ts deleted file mode 100644 index 574955e..0000000 --- a/apps/web/src/lib/date-utils.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type DateInput = Date | string | number; - -const LOCALE = "es-MX"; - -export function formatDate(date: DateInput): string { - return new Date(date).toLocaleDateString(LOCALE, { - year: "numeric", - month: "short", - day: "numeric", - hour: "2-digit", - minute: "2-digit", - }); -} From 46ab3964b4dab3ec474a6f797d7ab38b69a083cc Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 14:12:02 -0600 Subject: [PATCH 13/17] Ajusta el estado de las listas del detalle al archivar o desarchivar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Las listas de sucursales y contactos del detalle se vuelven a montar cuando cambia el archivado del cliente o la sucursal, así la pestaña pasa a Todos al archivar y regresa a Activos al desarchivar en lugar de quedarse en una lista vacía. --- .../$customerId/branches/$branchId/index.tsx | 2 ++ .../_auth/customers/$customerId/index.tsx | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx index d7b01b2..27e3f9d 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/branches/$branchId/index.tsx @@ -81,6 +81,8 @@ function RouteComponent() { ), diff --git a/apps/web/src/routes/_auth/customers/$customerId/index.tsx b/apps/web/src/routes/_auth/customers/$customerId/index.tsx index e4f64b7..58f1fdb 100644 --- a/apps/web/src/routes/_auth/customers/$customerId/index.tsx +++ b/apps/web/src/routes/_auth/customers/$customerId/index.tsx @@ -51,8 +51,21 @@ function RouteComponent() { const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false); const content: Record<(typeof TABS)[number]["value"], ReactNode> = { - branches: , - contacts: , + // Keyed on the archive state so the status tab follows the new default after archive or unarchive. + branches: ( + + ), + contacts: ( + + ), quotes: null, files: null, orders: null, From 094be259967ea86a44cbdf56298929e229c07557 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 16:03:38 -0600 Subject: [PATCH 14/17] =?UTF-8?q?Agrega=20la=20suplantaci=C3=B3n=20de=20us?= =?UTF-8?q?uarios=20en=20la=20tabla=20de=20usuarios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La tabla de usuarios suma un botón para entrar como otro usuario, deshabilitado en la fila propia y en la de administradores, que Better Auth no deja suplantar. Mientras se suplanta, una barra bajo el encabezado indica a quién se está viendo y permite volver a la cuenta propia. Al entrar o salir se recarga la página para que la sesión y las consultas en caché correspondan a la cuenta activa. Los botones de acción de la tabla muestran un tooltip con lo que hacen o por qué están bloqueados. --- .../src/components/users/action-tooltip.tsx | 23 +++++++ .../users/change-user-status-dialog.tsx | 32 +++++---- apps/web/src/components/users/users-table.tsx | 65 ++++++++++++++----- apps/web/src/hooks/use-users.ts | 31 +++++++++ apps/web/src/routes/_auth/route.tsx | 28 ++++++++ 5 files changed, 150 insertions(+), 29 deletions(-) create mode 100644 apps/web/src/components/users/action-tooltip.tsx diff --git a/apps/web/src/components/users/action-tooltip.tsx b/apps/web/src/components/users/action-tooltip.tsx new file mode 100644 index 0000000..ad1bf94 --- /dev/null +++ b/apps/web/src/components/users/action-tooltip.tsx @@ -0,0 +1,23 @@ +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@suni/ui/components/tooltip"; +import type { ReactNode } from "react"; + +interface ActionTooltipProps { + label: string; + children: ReactNode; +} + +// The span takes the hover because disabled buttons have pointer-events: none. +export function ActionTooltip({ label, children }: ActionTooltipProps) { + return ( + + }> + {children} + + {label} + + ); +} diff --git a/apps/web/src/components/users/change-user-status-dialog.tsx b/apps/web/src/components/users/change-user-status-dialog.tsx index fef443b..a68ca5a 100644 --- a/apps/web/src/components/users/change-user-status-dialog.tsx +++ b/apps/web/src/components/users/change-user-status-dialog.tsx @@ -14,6 +14,7 @@ import { Button } from "@suni/ui/components/button"; import { Ban, CircleCheckBig } from "lucide-react"; import { useState } from "react"; +import { ActionTooltip } from "@/components/users/action-tooltip"; import { useChangeUserStatus } from "@/hooks/use-users"; type UserRow = AppRouterOutputs["users"]["list"]["items"][number]; @@ -22,6 +23,7 @@ type UserRow = AppRouterOutputs["users"]["list"]["items"][number]; const ACTIONS = { suspend: { label: "Suspender", + hint: "Suspender el acceso de este usuario", Icon: Ban, triggerVariant: "ghost-destructive", confirmVariant: "destructive", @@ -30,6 +32,7 @@ const ACTIONS = { }, activate: { label: "Activar", + hint: "Reactivar el acceso de este usuario", Icon: CircleCheckBig, triggerVariant: "ghost-success", confirmVariant: "default", @@ -57,21 +60,22 @@ export function ChangeUserStatusDialog({ onOpenChange={(next) => !mutation.isPending && setOpen(next)} open={open} > - - } + - - {action.label} - + + } + > + + {action.label} + + diff --git a/apps/web/src/components/users/users-table.tsx b/apps/web/src/components/users/users-table.tsx index 2d7680f..2bd3f38 100644 --- a/apps/web/src/components/users/users-table.tsx +++ b/apps/web/src/components/users/users-table.tsx @@ -18,11 +18,12 @@ import { useReactTable, } from "@tanstack/react-table"; import type { PaginationState } from "@tanstack/react-table"; -import { Pencil, Shield, User } from "lucide-react"; +import { LogIn, Pencil, Shield, User } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; +import { ActionTooltip } from "@/components/users/action-tooltip"; import { ChangeUserStatusDialog } from "@/components/users/change-user-status-dialog"; -import { useListUsers } from "@/hooks/use-users"; +import { useImpersonateUser, useListUsers } from "@/hooks/use-users"; type UserRow = AppRouterOutputs["users"]["list"]["items"][number]; @@ -66,6 +67,38 @@ function StatusBadge({ banned }: { banned: boolean }) { ); } +function ImpersonateUserButton({ + user, + currentUserId, +}: { + user: UserRow; + currentUserId: string; +}) { + const impersonate = useImpersonateUser(); + // Better Auth rejects impersonating admins by default. + let blockedReason: string | undefined; + + if (user.id === currentUserId) { + blockedReason = "No puedes suplantarte a ti mismo"; + } else if (user.role === "admin") { + blockedReason = "No puedes suplantar a un administrador"; + } + + return ( + + + + ); +} + function createColumns(currentUserId: string) { return [ columnHelper.accessor("name", { @@ -103,19 +136,21 @@ function createColumns(currentUserId: string) { return (
    - + + + + { + throwOnError(await authClient.admin.impersonateUser({ userId })); + }, + onSuccess: reloadAsCurrentSession, + onError: () => toast.error("No se pudo suplantar al usuario."), + }); +} + +export function useStopImpersonating() { + return useMutation({ + mutationFn: async () => { + throwOnError(await authClient.admin.stopImpersonating()); + }, + onSuccess: reloadAsCurrentSession, + onError: () => toast.error("No se pudo volver a tu cuenta."), + }); +} diff --git a/apps/web/src/routes/_auth/route.tsx b/apps/web/src/routes/_auth/route.tsx index f274a89..8ee59c9 100644 --- a/apps/web/src/routes/_auth/route.tsx +++ b/apps/web/src/routes/_auth/route.tsx @@ -1,3 +1,4 @@ +import { Button } from "@suni/ui/components/button"; import { Separator } from "@suni/ui/components/separator"; import { SidebarInset, @@ -9,6 +10,7 @@ import { Outlet, createFileRoute, redirect } from "@tanstack/react-router"; import { AppSidebar } from "@/components/app-sidebar"; import { DynamicBreadcrumb } from "@/components/dynamic-breadcrumb"; +import { useStopImpersonating } from "@/hooks/use-users"; import { authClient } from "@/lib/auth-client"; export const Route = createFileRoute("/_auth")({ @@ -26,6 +28,31 @@ export const Route = createFileRoute("/_auth")({ }, }); +function ImpersonationBanner() { + const { session } = Route.useRouteContext(); + const stop = useStopImpersonating(); + + if (!session.session.impersonatedBy) { + return null; + } + + return ( +
    + + Estás viendo la aplicación como {session.user.name}. + + +
    + ); +} + function AuthLayout() { return ( @@ -43,6 +70,7 @@ function AuthLayout() { /> +
    From 3e6c0dd5d5dc31fc38596feab268832816e05b24 Mon Sep 17 00:00:00 2001 From: Adrian Ayala Date: Thu, 12 Nov 2026 16:12:02 -0600 Subject: [PATCH 15/17] =?UTF-8?q?Quita=20la=20l=C3=ADnea=20bajo=20el=20enc?= =?UTF-8?q?abezado=20de=20las=20p=C3=A1ginas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/routes/_auth/route.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/routes/_auth/route.tsx b/apps/web/src/routes/_auth/route.tsx index 8ee59c9..e96c82a 100644 --- a/apps/web/src/routes/_auth/route.tsx +++ b/apps/web/src/routes/_auth/route.tsx @@ -62,7 +62,7 @@ function AuthLayout() { > -
    +
    Date: Thu, 12 Nov 2026 16:31:55 -0600 Subject: [PATCH 16/17] Permite enfocar con teclado las acciones deshabilitadas de usuarios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Los botones de suplantar y de cambiar estado usan focusableWhenDisabled, así siguen bloqueados pero reciben el foco y su tooltip muestra el motivo también con teclado. --- apps/web/src/components/users/change-user-status-dialog.tsx | 2 ++ apps/web/src/components/users/users-table.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apps/web/src/components/users/change-user-status-dialog.tsx b/apps/web/src/components/users/change-user-status-dialog.tsx index a68ca5a..79b622e 100644 --- a/apps/web/src/components/users/change-user-status-dialog.tsx +++ b/apps/web/src/components/users/change-user-status-dialog.tsx @@ -67,6 +67,8 @@ export function ChangeUserStatusDialog({ render={ );