Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5ea5853
Rediseña la navegación con el sidebar inset de shadcn y agrupa Ventas
adrrian17 Nov 11, 2026
e38d0bd
Cambia la paleta de la UI a los colores del logo de Suni
adrrian17 Nov 11, 2026
0bd8aba
Rediseña los badges y las acciones de suspender y activar usuarios
adrrian17 Nov 11, 2026
b15c6f5
Iguala el espaciado de Usuarios con Clientes y mueve el total junto a…
adrrian17 Nov 11, 2026
bc059a9
Crea usuarios desde un diálogo en lugar de una página aparte
adrrian17 Nov 11, 2026
bb8de3f
Usa el símbolo del logo como ícono del sidebar colapsado
adrrian17 Nov 11, 2026
efdca8f
Unifica filtros, controles y detalle de cliente, y aligera el sidebar
adrrian17 Nov 11, 2026
aefa5d0
Mueve el estado de archivado al pie de las tarjetas, junto a Desarchivar
adrrian17 Nov 12, 2026
c85fdcc
Muestra el estado como pestañas con conteo y el tipo como segmentado
adrrian17 Nov 12, 2026
cb0565e
Abre sucursales y contactos en Activos
adrrian17 Nov 12, 2026
18a3617
Quita la fecha de actualizado del detalle de cliente
adrrian17 Nov 12, 2026
bae62f0
Elimina date-utils, que quedó sin usos
adrrian17 Nov 12, 2026
46ab396
Ajusta el estado de las listas del detalle al archivar o desarchivar
adrrian17 Nov 12, 2026
094be25
Agrega la suplantación de usuarios en la tabla de usuarios
adrrian17 Nov 12, 2026
3e6c0dd
Quita la línea bajo el encabezado de las páginas
adrrian17 Nov 12, 2026
91304ed
Permite enfocar con teclado las acciones deshabilitadas de usuarios
adrrian17 Nov 12, 2026
51d0cfe
Anuncia el motivo de bloqueo de las acciones de usuarios
adrrian17 Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/web/public/suni-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/public/suni-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 50 additions & 6 deletions apps/web/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,69 @@ 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<typeof Sidebar>) {
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 (
<Sidebar {...props}>
<Sidebar collapsible="icon" variant="inset" {...props}>
<SidebarHeader>
<div className="px-4 py-3 text-sm font-semibold">Suni</div>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton
className="h-14 group-data-[collapsible=icon]:hidden hover:bg-transparent"
render={<Link aria-label="Suni, ir al inicio" to="/dashboard" />}
>
<img
alt=""
className="h-10 w-auto"
height={75}
src="/suni-logo.png"
width={290}
/>
</SidebarMenuButton>
<SidebarMenuButton
className="hidden justify-center group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:p-1! hover:bg-transparent"
render={<Link aria-label="Suni, ir al inicio" to="/dashboard" />}
tooltip="Suni"
>
<img
alt=""
className="size-6"
height={106}
src="/suni-mark.png"
width={106}
/>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<div className="p-2">
<NavMain />
</div>
<NavMain />
</SidebarContent>
<SidebarFooter>
<div className="text-muted-foreground px-4 py-3 text-xs">Footer</div>
<NavUser />
</SidebarFooter>
<SidebarRail />
</Sidebar>
);
}
7 changes: 3 additions & 4 deletions apps/web/src/components/customers/branches/branch-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function BranchForm({
}}
>
<fieldset className="space-y-4">
<legend className="text-brand mb-4 text-lg font-semibold">
<legend className="text-foreground mb-4 text-lg font-semibold">
Datos generales
</legend>
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
Expand All @@ -119,7 +119,7 @@ export function BranchForm({
</fieldset>

<fieldset className="space-y-4">
<legend className="text-brand mb-4 text-lg font-semibold">
<legend className="text-foreground mb-4 text-lg font-semibold">
Dirección
</legend>
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
Expand Down Expand Up @@ -206,15 +206,14 @@ export function BranchForm({
disabled={submitting}
onClick={onCancel}
type="button"
variant="outline-destructive"
variant="outline"
>
Cancelar
</Button>
<Button
className="w-full sm:w-auto"
disabled={submitting}
type="submit"
variant="green"
>
{submitting ? <Loader2 className="animate-spin" /> : null}
{branch ? "Guardar" : "Crear"}
Expand Down
17 changes: 9 additions & 8 deletions apps/web/src/components/customers/branches/branch-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -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);

Expand All @@ -37,29 +38,29 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) {
<div
className={cn(
"flex size-9 shrink-0 items-center justify-center rounded-lg",
isArchived ? "bg-muted" : "bg-brand/10"
isArchived ? "bg-muted" : "bg-primary/10"
)}
>
<Building2
className={cn(
"size-4.5",
isArchived ? "text-muted-foreground" : "text-brand"
isArchived ? "text-muted-foreground" : "text-primary"
)}
/>
</div>
<div className="flex min-w-0 items-center gap-2">
<h1
className={cn(
"truncate text-xl font-bold",
isArchived ? "text-muted-foreground" : "text-brand"
isArchived ? "text-muted-foreground" : "text-primary"
)}
>
{branch.name}
</h1>
{isArchived ? (
<Badge className="shrink-0" variant="secondary">
<Archive className="size-3" />
{isCustomerArchived ? "Cliente archivado" : "Archivada"}
{archivedLabel(archive, "Archivada")}
</Badge>
) : null}
</div>
Expand All @@ -80,7 +81,7 @@ export function BranchHeader({ branch, onEdit }: BranchHeaderProps) {
{onEdit && !isCustomerArchived ? (
<div className="flex shrink-0 items-center gap-2">
{isArchived ? null : (
<Button onClick={onEdit} size="sm" variant="green">
<Button onClick={onEdit} size="sm">
<Pencil className="size-3.5" />
Editar
</Button>
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/components/customers/branches/branch-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function BranchInfoContent({
return (
<div className="flex flex-col gap-6">
<section>
<h3 className="text-brand mb-3 text-lg font-semibold">Dirección</h3>
<h3 className="text-foreground mb-3 text-lg font-semibold">
Dirección
</h3>
<div className="text-muted-foreground flex flex-col gap-3 text-sm">
<div className="flex items-start gap-2.5">
<MapPin className="text-muted-foreground/70 mt-0.5 size-4 shrink-0" />
Expand All @@ -47,7 +49,7 @@ export function BranchInfoContent({
</section>

<section>
<h3 className="text-brand mb-3 text-lg font-semibold">
<h3 className="text-foreground mb-3 text-lg font-semibold">
Imagen de fachada
</h3>
<div className="group relative aspect-video w-full overflow-hidden rounded-lg">
Expand Down
68 changes: 42 additions & 26 deletions apps/web/src/components/customers/branches/card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Badge } from "@suni/ui/components/badge";
import { Button } from "@suni/ui/components/button";
import {
DropdownMenu,
Expand All @@ -19,10 +18,12 @@ import {
Pencil,
Phone,
} from "lucide-react";
import { useState } from "react";
import { useRef, useState } from "react";

import { ArchivedFooter } from "@/components/customers/shared/archived-footer";

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";
Expand Down Expand Up @@ -53,32 +54,29 @@ function BranchImage({ name, src, isArchived }: BranchImageProps) {
src={src}
/>
<div className="absolute inset-0 bg-linear-to-t from-black/40 via-transparent to-transparent" />
{isArchived && (
<Badge className="absolute top-2 right-2" variant="secondary">
<Archive className="size-3" />
Archivada
</Badge>
)}
</div>
);
}

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);
const cardRef = useRef<HTMLDivElement>(null);
const address = formatAddress(branch);

return (
<>
<div
ref={cardRef}
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 hover:border-success/30 hover:shadow-md"
? "border-border bg-muted/30"
: "border-border hover:border-primary/30 hover:shadow-md"
)}
>
<BranchImage
Expand All @@ -98,10 +96,15 @@ export default function BranchCard({ branch, customer }: BranchCardProps) {
<h2
className={cn(
"line-clamp-2 text-lg leading-tight font-semibold transition-colors hover:underline",
isArchived ? "text-muted-foreground" : "text-success"
isArchived
? "text-muted-foreground decoration-muted-foreground/50 underline underline-offset-4"
: "text-primary"
)}
>
{branch.name}
{archivedText ? (
<span className="sr-only">, {archivedText}</span>
) : null}
</h2>
</Link>

Expand All @@ -117,7 +120,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}
Expand Down Expand Up @@ -181,17 +184,29 @@ export default function BranchCard({ branch, customer }: BranchCardProps) {
)}
</div>

<Link
params={{ customerId: branch.customerId, branchId: branch.id }}
to="/customers/$customerId/branches/$branchId"
>
<div className="border-border bg-card group-hover:bg-muted/30 flex items-center justify-between border-t px-4 py-3 transition-colors">
<span className="text-muted-foreground text-sm font-medium">
Ver detalles
</span>
<ChevronRight className="text-muted-foreground/70 group-hover:text-success size-4 transition-colors" />
</div>
</Link>
{archivedText ? (
<ArchivedFooter
label={archivedText}
name={branch.name}
onUnarchive={
archive.archivedBy === "self"
? () => setIsStatusDialogOpen(true)
: undefined
}
/>
) : (
<Link
params={{ customerId: branch.customerId, branchId: branch.id }}
to="/customers/$customerId/branches/$branchId"
>
<div className="border-border bg-card group-hover:bg-muted/30 flex items-center justify-between border-t px-4 py-3 transition-colors">
<span className="text-muted-foreground text-sm font-medium">
Ver detalles
</span>
<ChevronRight className="text-muted-foreground/70 group-hover:text-primary size-4 transition-colors" />
</div>
</Link>
)}
</div>

<BranchFormDialog
Expand All @@ -201,6 +216,7 @@ export default function BranchCard({ branch, customer }: BranchCardProps) {
open={isUpdateFormOpen}
/>
<ChangeBranchStatusDialog
finalFocus={cardRef}
branch={branch}
onOpenChange={setIsStatusDialogOpen}
open={isStatusDialogOpen}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AppRouterOutputs } from "@suni/api/routers/index";
import type { RefObject } from "react";

import { ChangeStatusDialog } from "@/components/customers/shared/change-status-dialog";
import { useArchiveBranch } from "@/hooks/use-branches";
Expand All @@ -9,18 +10,21 @@ interface ChangeBranchStatusDialogProps {
branch: Pick<Row, "id" | "name" | "archived">;
open: boolean;
onOpenChange: (open: boolean) => void;
finalFocus?: RefObject<HTMLElement | null>;
}

export function ChangeBranchStatusDialog({
branch,
open,
onOpenChange,
finalFocus,
}: ChangeBranchStatusDialogProps) {
const mutation = useArchiveBranch();

return (
<ChangeStatusDialog
entity={branch}
finalFocus={finalFocus}
mutation={mutation}
noun="la sucursal"
onOpenChange={onOpenChange}
Expand Down
Loading
Loading