Compare commits

...

2 Commits

Author SHA1 Message Date
04e28bce1a Arreglo en paginación que no funcionaba 2026-04-01 18:02:01 +02:00
5d15db7a7b . 2026-04-01 18:01:44 +02:00
2 changed files with 6 additions and 36 deletions

View File

@ -1,5 +1,4 @@
import type { RightPanelMode } from "@repo/rdx-ui/hooks";
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
import { useCustomerSummaryPanelController } from "./use-customer-summary-panel.controller";
@ -7,38 +6,15 @@ import { useListCustomersController } from "./use-list-customers.controller";
export const useListCustomersPageController = () => {
const listCtrl = useListCustomersController();
const [searchParams] = useSearchParams();
// -----------------------------
// URL → estado inicial (sync)
// -----------------------------
const initialPanelState = useMemo(() => {
const customerId = searchParams.get("customerId");
const panelMode = searchParams.get("panel") as RightPanelMode | null;
const customerId = searchParams.get("customerId") ?? "";
const panelMode = (searchParams.get("panel") as RightPanelMode | null) ?? "view";
if (!customerId) {
return {
customerId: "",
mode: "view" as RightPanelMode,
open: false,
};
}
return {
customerId,
mode: panelMode ?? "view",
open: true,
};
}, [searchParams]);
// -----------------------------
// Controller con estado inicial
// -----------------------------
const panelCtrl = useCustomerSummaryPanelController({
initialCustomerId: initialPanelState.customerId,
initialMode: initialPanelState.mode,
initialOpen: initialPanelState.open,
initialCustomerId: customerId,
initialMode: panelMode,
initialOpen: customerId !== "",
});
return {

View File

@ -25,12 +25,6 @@ export const useListCustomersController = () => {
const setSearchValue = (value: string) => {
setSearch(value.trim().replace(/\s+/g, " "));
setPageIndex(0);
};
const setPageSizeValue = (value: number) => {
setPageSize(value);
setPageIndex(0);
};
return {
@ -46,7 +40,7 @@ export const useListCustomersController = () => {
pageIndex,
pageSize,
setPageIndex,
setPageSize: setPageSizeValue,
setPageSize,
search,
setSearchValue,