From d062c4b5fe719e82c234f07a20afba909f8771b5 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 4 Nov 2025 17:01:13 +0100 Subject: [PATCH] Clientes -> arreglos varios: imports, formateo, quitar AG Grid --- modules/core/package.json | 2 - .../core/src/common/catalogs/taxes/index.ts | 3 +- .../taxes/json-tax-catalog.provider.ts | 2 +- .../components/form/simple-search-input.tsx | 257 +++++++++--------- modules/core/src/web/components/index.ts | 4 - .../core/src/web/components/page-header.tsx | 25 +- modules/core/src/web/manifest.ts | 2 +- 7 files changed, 139 insertions(+), 156 deletions(-) diff --git a/modules/core/package.json b/modules/core/package.json index c75c862d..c21afcf5 100644 --- a/modules/core/package.json +++ b/modules/core/package.json @@ -39,7 +39,6 @@ "@repo/rdx-utils": "workspace:*", "@repo/shadcn-ui": "workspace:*", "@tanstack/react-query": "^5.75.4", - "ag-grid-community": "^33.3.0", "axios": "^1.9.0", "express": "^4.18.2", "http-status": "^2.1.0", @@ -48,7 +47,6 @@ "react-hook-form": "^7.58.1", "react-i18next": "^15.5.1", "react-router-dom": "^6.26.0", - "sequelize": "^6.37.5", "zod": "^4.1.11" } } diff --git a/modules/core/src/common/catalogs/taxes/index.ts b/modules/core/src/common/catalogs/taxes/index.ts index a4c9e8e9..46705257 100644 --- a/modules/core/src/common/catalogs/taxes/index.ts +++ b/modules/core/src/common/catalogs/taxes/index.ts @@ -1,5 +1,4 @@ export * from "./json-tax-catalog.provider"; export * from "./spain-tax-catalog.provider"; -export * from "./tax-catalog-types"; export * from "./tax-catalog.provider"; - +export * from "./tax-catalog-types"; diff --git a/modules/core/src/common/catalogs/taxes/json-tax-catalog.provider.ts b/modules/core/src/common/catalogs/taxes/json-tax-catalog.provider.ts index 1f7b9a0e..6830da9f 100644 --- a/modules/core/src/common/catalogs/taxes/json-tax-catalog.provider.ts +++ b/modules/core/src/common/catalogs/taxes/json-tax-catalog.provider.ts @@ -1,8 +1,8 @@ // --- Adaptador que carga el catálogo JSON en memoria e indexa por code --- import { Maybe } from "@repo/rdx-utils"; -import { TaxCatalogType, TaxItemType, TaxLookupItems } from "./tax-catalog-types"; import { TaxCatalogProvider } from "./tax-catalog.provider"; +import { TaxCatalogType, TaxItemType, TaxLookupItems } from "./tax-catalog-types"; export class JsonTaxCatalogProvider implements TaxCatalogProvider { // Índice por código normalizado diff --git a/modules/core/src/web/components/form/simple-search-input.tsx b/modules/core/src/web/components/form/simple-search-input.tsx index 0a349f78..872d00e1 100644 --- a/modules/core/src/web/components/form/simple-search-input.tsx +++ b/modules/core/src/web/components/form/simple-search-input.tsx @@ -1,9 +1,9 @@ -import { useDebounce } from '@repo/rdx-ui/components'; +import { useDebounce } from "@repo/rdx-ui/components"; import { - InputGroup, - InputGroupAddon, - InputGroupButton, - InputGroupInput + InputGroup, + InputGroupAddon, + InputGroupButton, + InputGroupInput, } from "@repo/shadcn-ui/components"; import { Spinner } from "@repo/shadcn-ui/components/spinner"; import { SearchIcon, XIcon } from "lucide-react"; @@ -11,153 +11,140 @@ import { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; type SimpleSearchInputProps = { - onSearchChange: (value: string) => void; - loading?: boolean; - maxHistory?: number; + onSearchChange: (value: string) => void; + loading?: boolean; + maxHistory?: number; }; const SEARCH_HISTORY_KEY = "search_history"; export const SimpleSearchInput = ({ - onSearchChange, - loading = false, - maxHistory = 8, + onSearchChange, + loading = false, + maxHistory = 8, }: SimpleSearchInputProps) => { - const { t } = useTranslation(); - const [searchValue, setSearchValue] = useState(""); - const [lastSearch, setLastSearch] = useState(""); - const [history, setHistory] = useState([]); - const [open, setOpen] = useState(false); - const inputRef = useRef(null); + const { t } = useTranslation(); + const [searchValue, setSearchValue] = useState(""); + const [lastSearch, setLastSearch] = useState(""); + const [history, setHistory] = useState([]); + const [open, setOpen] = useState(false); + const inputRef = useRef(null); - const debouncedValue = useDebounce(searchValue, 300); + const debouncedValue = useDebounce(searchValue, 300); - // Load from localStorage on mount - useEffect(() => { - const stored = localStorage.getItem(SEARCH_HISTORY_KEY); - if (stored) setHistory(JSON.parse(stored)); - }, []); + // Load from localStorage on mount + useEffect(() => { + const stored = localStorage.getItem(SEARCH_HISTORY_KEY); + if (stored) setHistory(JSON.parse(stored)); + }, []); - // Emit changes after debounce - useEffect(() => { - onSearchChange(debouncedValue); - }, [debouncedValue, onSearchChange]); + // Emit changes after debounce + useEffect(() => { + onSearchChange(debouncedValue); + }, [debouncedValue, onSearchChange]); - // Save history to localStorage - const saveHistory = (term: string) => { - if (!term.trim()) return; - const cleaned = term.trim(); - const newHistory = [cleaned, ...history.filter((h) => h !== cleaned)].slice( - 0, - maxHistory - ); - setHistory(newHistory); - localStorage.setItem(SEARCH_HISTORY_KEY, JSON.stringify(newHistory)); - }; + // Save history to localStorage + const saveHistory = (term: string) => { + if (!term.trim()) return; + const cleaned = term.trim(); + const newHistory = [cleaned, ...history.filter((h) => h !== cleaned)].slice(0, maxHistory); + setHistory(newHistory); + localStorage.setItem(SEARCH_HISTORY_KEY, JSON.stringify(newHistory)); + }; - const clearHistory = () => { - setHistory([]); - localStorage.removeItem(SEARCH_HISTORY_KEY); - }; + const clearHistory = () => { + setHistory([]); + localStorage.removeItem(SEARCH_HISTORY_KEY); + }; - // Input handlers - const handleInputChange = (e: React.ChangeEvent) => { - const cleaned = e.target.value.trimStart().replace(/\s+/g, " "); - setSearchValue(cleaned); - }; + // Input handlers + const handleInputChange = (e: React.ChangeEvent) => { + const cleaned = e.target.value.trimStart().replace(/\s+/g, " "); + setSearchValue(cleaned); + }; - const handleClear = () => { - setSearchValue(""); - onSearchChange(""); - }; + const handleClear = () => { + setSearchValue(""); + onSearchChange(""); + }; - const handleKeyDown = (e: React.KeyboardEvent) => { - // Enter → búsqueda inmediata - if (e.key === "Enter" && !e.shiftKey && !e.metaKey && !e.ctrlKey) { - e.preventDefault(); - onSearchChange(searchValue); - setLastSearch(searchValue); - saveHistory(searchValue); - setOpen(false); - } + const handleKeyDown = (e: React.KeyboardEvent) => { + // Enter → búsqueda inmediata + if (e.key === "Enter" && !e.shiftKey && !e.metaKey && !e.ctrlKey) { + e.preventDefault(); + onSearchChange(searchValue); + setLastSearch(searchValue); + saveHistory(searchValue); + setOpen(false); + } - // Shift+Enter → repetir última búsqueda - if (e.key === "Enter" && e.shiftKey) { - e.preventDefault(); - if (lastSearch) { - onSearchChange(lastSearch); - setSearchValue(lastSearch); - } - } + // Shift+Enter → repetir última búsqueda + if (e.key === "Enter" && e.shiftKey) { + e.preventDefault(); + if (lastSearch) { + onSearchChange(lastSearch); + setSearchValue(lastSearch); + } + } - // Ctrl/Cmd+Enter → limpiar - if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { - e.preventDefault(); - handleClear(); - inputRef.current?.focus(); - } - }; + // Ctrl/Cmd+Enter → limpiar + if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { + e.preventDefault(); + handleClear(); + inputRef.current?.focus(); + } + }; - const handleSelectHistory = (term: string) => { - setSearchValue(term); - onSearchChange(term); - setLastSearch(term); - setOpen(false); - }; + const handleSelectHistory = (term: string) => { + setSearchValue(term); + onSearchChange(term); + setLastSearch(term); + setOpen(false); + }; - return ( -
+ return ( +
+ + history.length > 0 && setOpen(true)} + /> + + + - - history.length > 0 && setOpen(true)} - /> - - - - - - {loading && ( - - )} - {!searchValue && !loading && ( - onSearchChange(searchValue)} - > - {t("common.search", "Search")} - - )} - {searchValue && !loading && ( - - - {t("common.clear", "Clear")} - - )} - - - - - -
- - ); + + {loading && } + {!searchValue && !loading && ( + onSearchChange(searchValue)} + > + {t("common.search", "Search")} + + )} + {searchValue && !loading && ( + + + {t("common.clear", "Clear")} + + )} + + +
+ ); }; diff --git a/modules/core/src/web/components/index.ts b/modules/core/src/web/components/index.ts index 5fc6d843..7ae52b84 100644 --- a/modules/core/src/web/components/index.ts +++ b/modules/core/src/web/components/index.ts @@ -1,6 +1,2 @@ -import { AllCommunityModule, ModuleRegistry } from "ag-grid-community"; - -ModuleRegistry.registerModules([AllCommunityModule]); - export * from "./form"; export * from "./page-header"; diff --git a/modules/core/src/web/components/page-header.tsx b/modules/core/src/web/components/page-header.tsx index a268b2a1..625ac2cf 100644 --- a/modules/core/src/web/components/page-header.tsx +++ b/modules/core/src/web/components/page-header.tsx @@ -1,10 +1,8 @@ -import { Button } from '@repo/shadcn-ui/components'; -import { cn } from '@repo/shadcn-ui/lib/utils'; -import { ChevronLeftIcon } from 'lucide-react'; -// features/common/components/page-header.tsx +import { Button } from "@repo/shadcn-ui/components"; +import { cn } from "@repo/shadcn-ui/lib/utils"; +import { ChevronLeftIcon } from "lucide-react"; import type { ReactNode } from "react"; - interface PageHeaderProps { backIcon?: ReactNode; title: ReactNode; @@ -15,8 +13,13 @@ interface PageHeaderProps { className?: string; } - -export function PageHeader({ backIcon, title, description, rightSlot, className }: PageHeaderProps) { +export function PageHeader({ + backIcon, + title, + description, + rightSlot, + className, +}: PageHeaderProps) { return (
{/* Lado izquierdo */} @@ -34,16 +37,16 @@ export function PageHeader({ backIcon, title, description, rightSlot, className )}
-

{title}

+

+ {title} +

{description &&

{description}

}
{/* Lado derecho parametrizable */} -
- {rightSlot} -
+
{rightSlot}
); } diff --git a/modules/core/src/web/manifest.ts b/modules/core/src/web/manifest.ts index 7d3fd59a..4af731e3 100644 --- a/modules/core/src/web/manifest.ts +++ b/modules/core/src/web/manifest.ts @@ -6,7 +6,7 @@ const MODULE_VERSION = "1.0.0"; export const CoreModuleManifiest: IModuleClient = { name: MODULE_NAME, version: MODULE_VERSION, - dependencies: ["core"], + dependencies: [], protected: true, layout: "app",