Repaso PROFORMAS
This commit is contained in:
parent
e32dbfa3f1
commit
994417e48f
@ -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);
|
||||
@ -1 +1 @@
|
||||
export * from "./build-delete-proforma-targets";
|
||||
export * from "./prepare-delete-proforma-targets";
|
||||
|
||||
@ -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,
|
||||
});
|
||||
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
@ -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({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user