Repaso PROFORMAS

This commit is contained in:
David Arranz 2026-04-05 21:35:07 +02:00
parent e32dbfa3f1
commit 994417e48f
5 changed files with 27 additions and 25 deletions

View File

@ -1,18 +0,0 @@
import type { Proforma, ProformaListRow } from "../../shared";
import type { DeleteProformaTarget } from "../entities";
export const buildDeleteProformaTargetFromListRow = (
proforma: ProformaListRow
): DeleteProformaTarget => ({
id: proforma.id,
reference: proforma.reference,
});
export const buildDeleteProformaTargetFromEntity = (proforma: Proforma): DeleteProformaTarget => ({
id: proforma.id,
reference: proforma.reference,
});
export const buildDeleteProformaTargetsFromListRows = (
proformas: ProformaListRow[]
): DeleteProformaTarget[] => proformas.map(buildDeleteProformaTargetFromListRow);

View File

@ -1 +1 @@
export * from "./build-delete-proforma-targets";
export * from "./prepare-delete-proforma-targets";

View File

@ -0,0 +1,15 @@
import type { Proforma, ProformaListRow } from "../../shared";
import type { DeleteProformaTarget } from "../entities";
export const prepareDeleteProformaTargets = (
input: Proforma | ProformaListRow | Array<Proforma | ProformaListRow>
): DeleteProformaTarget[] => {
const items = Array.isArray(input) ? input : [input];
return items.map(mapToDeleteProformaTarget);
};
const mapToDeleteProformaTarget = (proforma: Proforma | ProformaListRow): DeleteProformaTarget => ({
id: proforma.id,
reference: proforma.reference,
});

View File

@ -1,11 +1,15 @@
import type { RightPanelMode } from "@repo/rdx-ui/hooks";
import { useSearchParams } from "react-router-dom";
import { useDeleteProformaDialogController } from "../../delete";
import { useListProformasController } from "./use-list-proformas.controller";
import { useProformaSummaryPanelController } from "./use-proforma-summary-panel.controller";
export const useListProformasPageController = () => {
const listCtrl = useListProformasController();
const deleteDialogCtrl = useDeleteProformaDialogController();
const [searchParams] = useSearchParams();
const proformaId = searchParams.get("proformaId") ?? "";
@ -20,5 +24,7 @@ export const useListProformasPageController = () => {
return {
listCtrl,
panelCtrl,
deleteDialogCtrl,
};
};

View File

@ -15,8 +15,8 @@ import { FilterIcon, PlusIcon } from "lucide-react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "../../../../i18n";
import { DeleteProformaDialog, useDeleteProformaDialogController } from "../../../delete";
import { buildDeleteProformaTargetFromListRow } from "../../../delete/utils";
import { DeleteProformaDialog } from "../../../delete";
import { prepareDeleteProformaTargets } from "../../../delete/utils";
import type { ProformaListRow } from "../../../shared";
import { useListProformasPageController } from "../../controllers";
import { ProformaSummaryPanel, ProformasGrid, useProformasGridColumns } from "../blocks";
@ -25,11 +25,10 @@ export const ListProformasPage = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const { listCtrl, panelCtrl } = useListProformasPageController();
const deleteDialogCtrl = useDeleteProformaDialogController();
const { listCtrl, panelCtrl, deleteDialogCtrl } = useListProformasPageController();
const handleDeleteProforma = (proforma: ProformaListRow) => {
deleteDialogCtrl.openDialog([buildDeleteProformaTargetFromListRow(proforma)]);
const handleDeleteProforma = (proformaRow: ProformaListRow) => {
deleteDialogCtrl.openDialog(prepareDeleteProformaTargets(proformaRow));
};
const columns = useProformasGridColumns({