From 1bf85a05ff8fbdeb5c8097a139ca75d4407abc52 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 29 Jul 2026 22:40:38 +0200 Subject: [PATCH] feat: implement proforma deletion and listing enhancements - Added endpoint for retrieving deleted proformas with logical deletion. - Updated proforma listing to support active, archived, and deleted scopes. - Refactored repository and service layers to accommodate new proforma list scope. - Enhanced UI to display separate views for active, archived, and deleted proformas. - Updated localization files to reflect changes in proforma management. - Improved query handling to filter proformas based on their status and scope. --- apps/web/src/layout/app-sidebar-nav.tsx | 144 +++++++++++++++--- apps/web/src/layout/app-sidebar.config.ts | 31 +++- .../proforma-archive-contract.md | 49 +++--- .../proforma-delete-contract.md | 53 +++---- .../proforma-list-contract.md | 49 ++---- .../proforma-repository.interface.ts | 2 + .../proformas/services/proforma-finder.ts | 5 +- .../use-cases/list-proformas.use-case.ts | 12 +- .../controllers/list-proformas.controller.ts | 10 +- .../proformas/express/proformas.routes.ts | 25 ++- .../repositories/proforma-v2.repository.ts | 29 +++- .../repositories/proforma.repository.ts | 2 + .../src/common/locales/en.json | 21 ++- .../src/common/locales/es.json | 21 ++- .../src/web/customer-invoice-routes.tsx | 16 ++ .../use-list-proformas-page.controller.ts | 5 +- .../use-list-proformas.controller.ts | 35 +---- .../list/types/proforma-list-filters.ts | 2 +- .../use-proforma-grid-columns.tsx | 84 ++++++---- .../list/ui/pages/list-proformas-page.tsx | 129 ++++++++++------ .../utils/build-list-proformas-criteria.ts | 18 +-- .../api/list-proformas-by-criteria.api.ts | 10 +- .../src/web/proformas/shared/hooks/keys.ts | 7 +- .../shared/hooks/use-proformas-list-query.ts | 7 +- 24 files changed, 483 insertions(+), 283 deletions(-) diff --git a/apps/web/src/layout/app-sidebar-nav.tsx b/apps/web/src/layout/app-sidebar-nav.tsx index 6f700ac2..b9a646aa 100644 --- a/apps/web/src/layout/app-sidebar-nav.tsx +++ b/apps/web/src/layout/app-sidebar-nav.tsx @@ -8,13 +8,20 @@ import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, + SidebarMenuSub, + SidebarMenuSubButton, + SidebarMenuSubItem, } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { ChevronDownIcon } from "lucide-react"; import * as React from "react"; -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; -import type { AppSidebarNavSection, AppSidebarSectionAccent } from "./app-sidebar.config"; +import type { + AppSidebarNavItem, + AppSidebarNavSection, + AppSidebarSectionAccent, +} from "./app-sidebar.config"; interface AppSidebarNavProps { sections: AppSidebarNavSection[]; @@ -29,9 +36,11 @@ interface SidebarSectionAccentStyles { } export const AppSidebarNav = ({ sections }: AppSidebarNavProps) => { + const { pathname } = useLocation(); const [openSections, setOpenSections] = React.useState>(() => Object.fromEntries(sections.map((s) => [s.title, true])) ); + const [openItems, setOpenItems] = React.useState>({}); const sectionAccentStyles: Record = { blue: { @@ -67,6 +76,25 @@ export const AppSidebarNav = ({ sections }: AppSidebarNavProps) => { }, }; + const isRouteActive = React.useCallback( + (item: AppSidebarNavItem): boolean => { + if (item.items?.length) { + return item.items.some((child) => isRouteActive(child)); + } + + if (!item.href) { + return false; + } + + if (item.exact) { + return pathname === item.href; + } + + return pathname === item.href || pathname.startsWith(`${item.href}/`); + }, + [pathname] + ); + return (