diff --git a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-list-item.tsx b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-list-item.tsx index f9688eb4..d3dd7046 100644 --- a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-list-item.tsx +++ b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-list-item.tsx @@ -1,5 +1,4 @@ import { RdxBadge } from "@repo/rdx-ui/components"; -import { Card, CardContent } from "@repo/shadcn-ui/components"; import { CalendarClockIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; @@ -48,120 +47,116 @@ export const PaymentTermListItem = ({ const formatLocalizedDueDays = (value: number) => formatPaymentTermDueDays(value, t); return ( - - -
-
-
- -
+
+
+
+
+ +
-
-
-

- {paymentTerm.name} -

+
+
+

+ {paymentTerm.name} +

- - {paymentTerm.isActive - ? t("settings.paymentTerms.status.active") - : t("settings.paymentTerms.status.inactive")} - + + {paymentTerm.isActive + ? t("settings.paymentTerms.status.active") + : t("settings.paymentTerms.status.inactive")} + - {paymentTerm.isSystem ? ( - - {t("settings.paymentTerms.status.system")} - - ) : null} -
- - {paymentTerm.description ? ( -

{paymentTerm.description}

+ {paymentTerm.isSystem ? ( + {t("settings.paymentTerms.status.system")} ) : null}
-
- -
- -
-
-

- {t("settings.paymentTerms.summary.installmentsLabel")} -

-

- {t("settings.paymentTerms.summary.installmentsCount", { count: installmentCount })} -

-
- -
-

- {t("settings.paymentTerms.summary.lastInstallmentLabel")} -

-

- {lastDueDays === null ? "-" : formatLocalizedDueDays(lastDueDays)} -

-
- -
-

- {t("settings.paymentTerms.summary.distributionLabel")} -

-

- {percentageDistribution.map(formatLocalizedPercentage).join(" / ")} -

+ {paymentTerm.description ? ( +

{paymentTerm.description}

+ ) : null}
-
-
-

- {t("settings.paymentTerms.details.title")} -

+ +
-
- {sortedDueRules.map((rule, index) => ( -
-
-
- {index + 1} -
+
+
+

+ {t("settings.paymentTerms.summary.installmentsLabel")} +

+

+ {t("settings.paymentTerms.summary.installmentsCount", { count: installmentCount })} +

+
-
-

- {formatLocalizedPercentage(rule.percentage)} ·{" "} - {formatLocalizedDueDays(rule.dueDays)} -

-

- {rule.dueDays === 0 - ? t("settings.paymentTerms.details.sameDay") - : t("settings.paymentTerms.details.baseDate")} -

-
+
+

+ {t("settings.paymentTerms.summary.lastInstallmentLabel")} +

+

+ {lastDueDays === null ? "-" : formatLocalizedDueDays(lastDueDays)} +

+
+ +
+

+ {t("settings.paymentTerms.summary.distributionLabel")} +

+

+ {percentageDistribution.map(formatLocalizedPercentage).join(" / ")} +

+
+
+ +
+
+

+ {t("settings.paymentTerms.details.title")} +

+ +
+ {sortedDueRules.map((rule, index) => ( +
+
+
+ {index + 1} +
+ +
+

+ {formatLocalizedPercentage(rule.percentage)} ·{" "} + {formatLocalizedDueDays(rule.dueDays)} +

+

+ {rule.dueDays === 0 + ? t("settings.paymentTerms.details.sameDay") + : t("settings.paymentTerms.details.baseDate")} +

- ))} -
+
+ ))}
- -
- - + + +
+
); }; diff --git a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-row-actions.tsx b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-row-actions.tsx index b2654981..ebcce09c 100644 --- a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-row-actions.tsx +++ b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-term-row-actions.tsx @@ -1,12 +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 { PaymentTermListRow } from "../../../../payment-terms/shared"; @@ -36,68 +30,50 @@ export const PaymentTermRowActions = ({ const toggleDisabled = paymentTerm.isSystem || isTogglingActive; const deleteDisabled = paymentTerm.isSystem; + const primaryActions: RdxRowAction[] = [ + { + id: "edit", + label: t("settings.paymentTerms.actions.edit"), + icon: , + disabled: editDisabled, + disabledReason: editDisabled ? t("settings.paymentTerms.protections.systemEdit") : undefined, + onSelect: () => onEdit(paymentTerm), + }, + { + id: "toggle-active", + label: paymentTerm.isActive + ? t("settings.paymentTerms.actions.disable") + : t("settings.paymentTerms.actions.enable"), + icon: isTogglingActive ? ( + + ) : paymentTerm.isActive ? ( + + ) : ( + + ), + disabled: toggleDisabled, + disabledReason: toggleDisabled ? activeDisabledReason : undefined, + onSelect: () => onToggleActive(paymentTerm), + }, + ]; + + const overflowActions: RdxRowAction[] = [ + { + id: "delete", + label: t("settings.paymentTerms.actions.delete"), + icon: , + destructive: true, + disabled: deleteDisabled, + disabledReason: deleteDisabled ? deleteDisabledReason : undefined, + onSelect: () => onDelete(paymentTerm), + }, + ]; + return ( -
- - - - - - - - - } - /> - onDelete(paymentTerm)} - title={deleteDisabled ? deleteDisabledReason : undefined} - variant="destructive" - > - {t("settings.paymentTerms.actions.delete")} - - } - /> - -
+ ); }; diff --git a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-terms-empty-state.tsx b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-terms-empty-state.tsx index 1d6131c4..da6aaf7e 100644 --- a/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-terms-empty-state.tsx +++ b/modules/catalogs/src/web/settings/payment-terms/ui/components/payment-terms-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 PaymentTermsEmptyState = ({ onCreate }: { onCreate: () => void }) = const { t } = useTranslation(); return ( -
-
-

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

-

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

-
- - -
+ ); }; diff --git a/modules/catalogs/src/web/settings/payment-terms/ui/pages/payment-terms-settings-page.tsx b/modules/catalogs/src/web/settings/payment-terms/ui/pages/payment-terms-settings-page.tsx index 64212044..3c5b0ab9 100644 --- a/modules/catalogs/src/web/settings/payment-terms/ui/pages/payment-terms-settings-page.tsx +++ b/modules/catalogs/src/web/settings/payment-terms/ui/pages/payment-terms-settings-page.tsx @@ -1,7 +1,10 @@ import { PageErrorState } from "@erp/core/components"; -import { RdxPageContainer, RdxPageHeader, RdxPageStack } from "@repo/rdx-ui/components"; +import { RdxPageContainer } from "@repo/rdx-ui/components"; import { Button, + Card, + CardContent, + CardHeader, Input, Select, SelectContent, @@ -10,7 +13,7 @@ import { SelectValue, Spinner, } from "@repo/shadcn-ui/components"; -import { PlusIcon, SearchIcon } from "lucide-react"; +import { CalendarClockIcon, PlusIcon, SearchIcon } from "lucide-react"; import type { ChangeEvent } from "react"; import { useTranslation } from "../../../../i18n"; @@ -85,144 +88,156 @@ export const PaymentTermsSettingsPage = () => { }; return ( - - - - - {t("settings.paymentTerms.actions.create")} - - } - description={t("settings.paymentTerms.description")} - title={t("settings.paymentTerms.title")} - /> - -
-
-
- - - {ctrl.isBackgroundFetching ? ( - + + +
+
+ +
+
+

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

+

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

+
+
+ +
+ +
+
+
+ + - ) : null} + {ctrl.isBackgroundFetching ? ( + + ) : null} +
+ +
+ + {t("settings.paymentTerms.toolbar.statusLabel")} + + +
-
- - {t("settings.paymentTerms.toolbar.statusLabel")} +
+ {ctrl.isBackgroundFetching ? : null} + + {t("settings.paymentTerms.toolbar.totalCount", { count: ctrl.totalItems })} -
-
- {ctrl.isBackgroundFetching ? : null} - {t("settings.paymentTerms.toolbar.totalCount", { count: ctrl.totalItems })} -
-
+ {ctrl.hasEmptyState ? ( + + ) : ctrl.hasNoResults ? ( + + ) : ( +
+ {ctrl.list.map((paymentTerm) => ( + { + if (item.isActive) { + featureCtrl.disable(item); + return; + } - {ctrl.hasEmptyState ? ( - - ) : ctrl.hasNoResults ? ( - - ) : ( -
- {ctrl.list.map((paymentTerm) => ( - { - if (item.isActive) { - featureCtrl.disable(item); - return; - } + featureCtrl.enable(item); + }} + paymentTerm={paymentTerm} + /> + ))} +
+ )} + + - featureCtrl.enable(item); - }} - paymentTerm={paymentTerm} - /> - ))} -
- )} + { + if (!open) { + featureCtrl.closeCreateDialog(); + } + }} + submitLabel={t("settings.paymentTerms.actions.create")} + title={t("settings.paymentTerms.create.title")} + /> - { - if (!open) { - featureCtrl.closeCreateDialog(); - } - }} - submitLabel={t("settings.paymentTerms.actions.create")} - title={t("settings.paymentTerms.create.title")} - /> + { + if (!open) { + featureCtrl.closeEditDialog(); + } + }} + submitLabel={t("settings.paymentTerms.actions.save")} + title={t("settings.paymentTerms.edit.title")} + /> - { - if (!open) { - featureCtrl.closeEditDialog(); - } - }} - submitLabel={t("settings.paymentTerms.actions.save")} - title={t("settings.paymentTerms.edit.title")} - /> - - { - if (!open) { - featureCtrl.closeDeleteDialog(); - } - }} - open={Boolean(featureCtrl.deletingPaymentTerm)} - target={featureCtrl.deletingPaymentTerm} - /> - - + { + if (!open) { + featureCtrl.closeDeleteDialog(); + } + }} + open={Boolean(featureCtrl.deletingPaymentTerm)} + target={featureCtrl.deletingPaymentTerm} + /> + ); };