From bbca943c87cfbdfb26ab281db357e960d138ebd5 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 5 Sep 2026 11:43:48 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20refactor=20acciones=20de=20fila=20y=20e?= =?UTF-8?q?stado=20vac=C3=ADo=20en=20la=20configuraci=C3=B3n=20de=20reg?= =?UTF-8?q?=C3=ADmenes=20fiscales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/tax-regime-row-actions.tsx | 104 ++++---- .../ui/components/tax-regimes-empty-state.tsx | 26 +- .../ui/pages/tax-regimes-settings-page.tsx | 244 ++++++++++-------- 3 files changed, 193 insertions(+), 181 deletions(-) diff --git a/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regime-row-actions.tsx b/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regime-row-actions.tsx index d8fc125b..74995bc5 100644 --- a/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regime-row-actions.tsx +++ b/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regime-row-actions.tsx @@ -1,5 +1,6 @@ -import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Spinner } from "@repo/shadcn-ui/components"; -import { MoreHorizontalIcon } from "lucide-react"; +import { type RdxRowAction, RdxRowActions } from "@repo/rdx-ui/components"; +import { Spinner } from "@repo/shadcn-ui/components"; +import { PencilIcon, PowerIcon, PowerOffIcon, Trash2Icon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; import type { TaxRegimeListRow } from "../../../../tax-regimes/shared"; @@ -29,61 +30,50 @@ export const TaxRegimeRowActions = ({ const toggleDisabled = taxRegime.isSystem || isTogglingActive; const deleteDisabled = taxRegime.isSystem; + const primaryActions: RdxRowAction[] = [ + { + id: "edit", + label: t("settings.taxRegimes.actions.edit"), + icon: , + disabled: editDisabled, + disabledReason: editDisabled ? t("settings.taxRegimes.protections.systemEdit") : undefined, + onSelect: () => onEdit(taxRegime), + }, + { + id: "toggle-active", + label: taxRegime.isActive + ? t("settings.taxRegimes.actions.disable") + : t("settings.taxRegimes.actions.enable"), + icon: isTogglingActive ? ( + + ) : taxRegime.isActive ? ( + + ) : ( + + ), + disabled: toggleDisabled, + disabledReason: toggleDisabled ? activeDisabledReason : undefined, + onSelect: () => onToggleActive(taxRegime), + }, + ]; + + const overflowActions: RdxRowAction[] = [ + { + id: "delete", + label: t("settings.taxRegimes.actions.delete"), + icon: , + destructive: true, + disabled: deleteDisabled, + disabledReason: deleteDisabled ? deleteDisabledReason : undefined, + onSelect: () => onDelete(taxRegime), + }, + ]; + return ( -
- - - - - - - - - } - /> - onDelete(taxRegime)} - title={deleteDisabled ? deleteDisabledReason : undefined} - variant="destructive" - > - {t("settings.taxRegimes.actions.delete")} - - } - /> - -
+ ); }; diff --git a/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regimes-empty-state.tsx b/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regimes-empty-state.tsx index 8bcefeb3..976be88c 100644 --- a/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regimes-empty-state.tsx +++ b/modules/catalogs/src/web/settings/tax-regimes/ui/components/tax-regimes-empty-state.tsx @@ -1,4 +1,5 @@ import { Button } from "@repo/shadcn-ui/components"; +import { CirclePlusIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; @@ -6,17 +7,18 @@ export const TaxRegimesEmptyState = ({ onCreate }: { onCreate: () => void }) => const { t } = useTranslation(); return ( -
-
-

{t("settings.taxRegimes.empty.title")}

-

- {t("settings.taxRegimes.empty.description")} -

-
- - -
+ ); }; diff --git a/modules/catalogs/src/web/settings/tax-regimes/ui/pages/tax-regimes-settings-page.tsx b/modules/catalogs/src/web/settings/tax-regimes/ui/pages/tax-regimes-settings-page.tsx index 465194c2..b48ea0fe 100644 --- a/modules/catalogs/src/web/settings/tax-regimes/ui/pages/tax-regimes-settings-page.tsx +++ b/modules/catalogs/src/web/settings/tax-regimes/ui/pages/tax-regimes-settings-page.tsx @@ -1,7 +1,8 @@ import { PageErrorState } from "@erp/core/components"; import { RdxBadge, RdxPageContainer } from "@repo/rdx-ui/components"; -import { Button, Card, CardContent } from "@repo/shadcn-ui/components"; -import { PlusIcon } from "lucide-react"; +import { Button, Card, CardContent, CardHeader } from "@repo/shadcn-ui/components"; +import { cn } from "@repo/shadcn-ui/lib/utils"; +import { CircleIcon, LandmarkIcon, PlusIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; import { useTaxRegimesSettingsPageController } from "../../controllers"; @@ -63,123 +64,142 @@ export const TaxRegimesSettingsPage = () => { }; return ( - -
-
-
-

- {t("settings.taxRegimes.title")} -

-

- {t("settings.taxRegimes.description")} -

+ <> + + +
+
+ +
+
+

+ {t("settings.taxRegimes.title")} +

+

+ {t("settings.taxRegimes.description")} +

+
- - -
- - {ctrl.list.length === 0 ? ( - - ) : ( -
- {ctrl.list.map((taxRegime) => ( - - -
-
- - {taxRegime.code} - - - {taxRegime.isSystem ? ( - - {t("settings.taxRegimes.status.system")} - - ) : null} - - - {taxRegime.isActive - ? t("settings.taxRegimes.status.active") - : t("settings.taxRegimes.status.inactive")} - + {ctrl.list.length > 0 && ( + + )} + + + {ctrl.list.length > 0 && ( +
+ {ctrl.list.map((taxRegime) => ( +
+
+
+
- -
-

{taxRegime.description}

+
+

+ {taxRegime.description} +

+
+ + + {taxRegime.isActive + ? t("settings.taxRegimes.status.active") + : t("settings.taxRegimes.status.inactive")} + + {taxRegime.isSystem && ( + + {t("settings.taxRegimes.status.system")} + + )} +
+
+ { + if (item.isActive) { + featureCtrl.disable(item); + return; + } - { - if (item.isActive) { - featureCtrl.disable(item); - return; - } + featureCtrl.enable(item); + }} + taxRegime={taxRegime} + /> +
+
+ ))} +
+ )} + {ctrl.list.length === 0 && ( + + )} + + - featureCtrl.enable(item); - }} - taxRegime={taxRegime} - /> - - - ))} -
- )} + { + if (!open) { + featureCtrl.closeCreateDialog(); + } + }} + submitLabel={t("settings.taxRegimes.actions.create")} + title={t("settings.taxRegimes.create.title")} + /> - { - if (!open) { - featureCtrl.closeCreateDialog(); - } - }} - submitLabel={t("settings.taxRegimes.actions.create")} - title={t("settings.taxRegimes.create.title")} - /> + { + if (!open) { + featureCtrl.closeEditDialog(); + } + }} + submitLabel={t("settings.taxRegimes.actions.save")} + title={t("settings.taxRegimes.edit.title")} + /> - { - if (!open) { - featureCtrl.closeEditDialog(); - } - }} - submitLabel={t("settings.taxRegimes.actions.save")} - title={t("settings.taxRegimes.edit.title")} - /> - - { - if (!open) { - featureCtrl.closeDeleteDialog(); - } - }} - open={Boolean(featureCtrl.deletingTaxRegime)} - target={featureCtrl.deletingTaxRegime} - /> -
- + { + if (!open) { + featureCtrl.closeDeleteDialog(); + } + }} + open={Boolean(featureCtrl.deletingTaxRegime)} + target={featureCtrl.deletingTaxRegime} + /> + ); };