feat: mejorar la interfaz de usuario en la configuración de términos de pago y optimizar acciones de fila
This commit is contained in:
parent
81da489ca8
commit
12c496e93a
@ -1,5 +1,4 @@
|
|||||||
import { RdxBadge } from "@repo/rdx-ui/components";
|
import { RdxBadge } from "@repo/rdx-ui/components";
|
||||||
import { Card, CardContent } from "@repo/shadcn-ui/components";
|
|
||||||
import { CalendarClockIcon } from "lucide-react";
|
import { CalendarClockIcon } from "lucide-react";
|
||||||
|
|
||||||
import { useTranslation } from "../../../../i18n";
|
import { useTranslation } from "../../../../i18n";
|
||||||
@ -48,8 +47,7 @@ export const PaymentTermListItem = ({
|
|||||||
const formatLocalizedDueDays = (value: number) => formatPaymentTermDueDays(value, t);
|
const formatLocalizedDueDays = (value: number) => formatPaymentTermDueDays(value, t);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="border-border/70 shadow-none">
|
<div className="flex flex-col gap-5 rounded-xl border border-border/70 bg-card p-4 sm:gap-6 sm:p-5">
|
||||||
<CardContent className="flex flex-col gap-5 p-4 sm:gap-6 sm:p-5">
|
|
||||||
<div className="flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between">
|
<div className="flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between">
|
||||||
<div className="flex min-w-0 items-start gap-3 sm:gap-4">
|
<div className="flex min-w-0 items-start gap-3 sm:gap-4">
|
||||||
<div className="flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-muted/40 text-primary sm:size-11">
|
<div className="flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-muted/40 text-primary sm:size-11">
|
||||||
@ -69,9 +67,7 @@ export const PaymentTermListItem = ({
|
|||||||
</RdxBadge>
|
</RdxBadge>
|
||||||
|
|
||||||
{paymentTerm.isSystem ? (
|
{paymentTerm.isSystem ? (
|
||||||
<RdxBadge variant="secondary">
|
<RdxBadge variant="secondary">{t("settings.paymentTerms.status.system")}</RdxBadge>
|
||||||
{t("settings.paymentTerms.status.system")}
|
|
||||||
</RdxBadge>
|
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -161,7 +157,6 @@ export const PaymentTermListItem = ({
|
|||||||
segments={segments}
|
segments={segments}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
import {
|
import { type RdxRowAction, RdxRowActions } from "@repo/rdx-ui/components";
|
||||||
Button,
|
import { Spinner } from "@repo/shadcn-ui/components";
|
||||||
DropdownMenu,
|
import { PencilIcon, PowerIcon, PowerOffIcon, Trash2Icon } from "lucide-react";
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
Spinner,
|
|
||||||
} from "@repo/shadcn-ui/components";
|
|
||||||
import { MoreHorizontalIcon } from "lucide-react";
|
|
||||||
|
|
||||||
import { useTranslation } from "../../../../i18n";
|
import { useTranslation } from "../../../../i18n";
|
||||||
import type { PaymentTermListRow } from "../../../../payment-terms/shared";
|
import type { PaymentTermListRow } from "../../../../payment-terms/shared";
|
||||||
@ -36,68 +30,50 @@ export const PaymentTermRowActions = ({
|
|||||||
const toggleDisabled = paymentTerm.isSystem || isTogglingActive;
|
const toggleDisabled = paymentTerm.isSystem || isTogglingActive;
|
||||||
const deleteDisabled = paymentTerm.isSystem;
|
const deleteDisabled = paymentTerm.isSystem;
|
||||||
|
|
||||||
|
const primaryActions: RdxRowAction[] = [
|
||||||
|
{
|
||||||
|
id: "edit",
|
||||||
|
label: t("settings.paymentTerms.actions.edit"),
|
||||||
|
icon: <PencilIcon aria-hidden className="size-4" />,
|
||||||
|
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 ? (
|
||||||
|
<Spinner aria-hidden className="size-4" />
|
||||||
|
) : paymentTerm.isActive ? (
|
||||||
|
<PowerOffIcon aria-hidden className="size-4" />
|
||||||
|
) : (
|
||||||
|
<PowerIcon aria-hidden className="size-4" />
|
||||||
|
),
|
||||||
|
disabled: toggleDisabled,
|
||||||
|
disabledReason: toggleDisabled ? activeDisabledReason : undefined,
|
||||||
|
onSelect: () => onToggleActive(paymentTerm),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const overflowActions: RdxRowAction[] = [
|
||||||
|
{
|
||||||
|
id: "delete",
|
||||||
|
label: t("settings.paymentTerms.actions.delete"),
|
||||||
|
icon: <Trash2Icon aria-hidden className="size-4" />,
|
||||||
|
destructive: true,
|
||||||
|
disabled: deleteDisabled,
|
||||||
|
disabledReason: deleteDisabled ? deleteDisabledReason : undefined,
|
||||||
|
onSelect: () => onDelete(paymentTerm),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-wrap items-center gap-2 xl:w-auto xl:justify-end">
|
<RdxRowActions
|
||||||
<Button
|
overflowActions={overflowActions}
|
||||||
aria-label={t("settings.paymentTerms.actions.edit")}
|
overflowLabel={t("settings.paymentTerms.actions.more")}
|
||||||
className="flex-1 sm:flex-none"
|
primaryActions={primaryActions}
|
||||||
disabled={editDisabled}
|
|
||||||
onClick={() => onEdit(paymentTerm)}
|
|
||||||
size="sm"
|
|
||||||
title={editDisabled ? t("settings.paymentTerms.protections.systemEdit") : undefined}
|
|
||||||
variant="outline"
|
|
||||||
>
|
|
||||||
{t("settings.paymentTerms.actions.edit")}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
aria-busy={isTogglingActive}
|
|
||||||
aria-label={
|
|
||||||
paymentTerm.isActive
|
|
||||||
? t("settings.paymentTerms.actions.disable")
|
|
||||||
: t("settings.paymentTerms.actions.enable")
|
|
||||||
}
|
|
||||||
className="flex-1 sm:flex-none"
|
|
||||||
disabled={toggleDisabled}
|
|
||||||
onClick={() => onToggleActive(paymentTerm)}
|
|
||||||
size="sm"
|
|
||||||
title={toggleDisabled ? activeDisabledReason : undefined}
|
|
||||||
variant="outline"
|
|
||||||
>
|
|
||||||
{isTogglingActive ? <Spinner aria-hidden className="mr-2 size-4" /> : null}
|
|
||||||
{paymentTerm.isActive
|
|
||||||
? t("settings.paymentTerms.actions.disable")
|
|
||||||
: t("settings.paymentTerms.actions.enable")}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger
|
|
||||||
render={
|
|
||||||
<Button
|
|
||||||
aria-label={t("settings.paymentTerms.actions.more")}
|
|
||||||
className="shrink-0"
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
>
|
|
||||||
<MoreHorizontalIcon className="size-4" />
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<DropdownMenuContent
|
|
||||||
align="end"
|
|
||||||
className="w-48"
|
|
||||||
render={
|
|
||||||
<DropdownMenuItem
|
|
||||||
disabled={deleteDisabled}
|
|
||||||
onClick={() => onDelete(paymentTerm)}
|
|
||||||
title={deleteDisabled ? deleteDisabledReason : undefined}
|
|
||||||
variant="destructive"
|
|
||||||
>
|
|
||||||
{t("settings.paymentTerms.actions.delete")}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { Button } from "@repo/shadcn-ui/components";
|
import { Button } from "@repo/shadcn-ui/components";
|
||||||
|
import { CirclePlusIcon } from "lucide-react";
|
||||||
|
|
||||||
import { useTranslation } from "../../../../i18n";
|
import { useTranslation } from "../../../../i18n";
|
||||||
|
|
||||||
@ -6,17 +7,18 @@ export const PaymentTermsEmptyState = ({ onCreate }: { onCreate: () => void }) =
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-dashed border-border bg-muted/20 p-8 text-center">
|
<Button
|
||||||
<div className="space-y-2">
|
className="h-auto min-h-28 w-full flex-col gap-2 whitespace-normal rounded-xl border-dashed px-4 py-6 text-center shadow-none transition-colors hover:bg-muted/50"
|
||||||
<h3 className="text-lg font-semibold">{t("settings.paymentTerms.empty.title")}</h3>
|
onClick={onCreate}
|
||||||
<p className="text-sm text-muted-foreground">
|
variant="outline"
|
||||||
|
>
|
||||||
|
<span className="flex items-center justify-center gap-2">
|
||||||
|
<CirclePlusIcon aria-hidden className="size-5 text-muted-foreground" />
|
||||||
|
{t("settings.paymentTerms.empty.title")}
|
||||||
|
</span>
|
||||||
|
<span className="text-sm font-normal text-muted-foreground">
|
||||||
{t("settings.paymentTerms.empty.description")}
|
{t("settings.paymentTerms.empty.description")}
|
||||||
</p>
|
</span>
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button className="mt-6" onClick={onCreate}>
|
|
||||||
{t("settings.paymentTerms.actions.create")}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
import { PageErrorState } from "@erp/core/components";
|
import { PageErrorState } from "@erp/core/components";
|
||||||
import { RdxPageContainer, RdxPageHeader, RdxPageStack } from "@repo/rdx-ui/components";
|
import { RdxPageContainer } from "@repo/rdx-ui/components";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardHeader,
|
||||||
Input,
|
Input,
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@ -10,7 +13,7 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
Spinner,
|
Spinner,
|
||||||
} from "@repo/shadcn-ui/components";
|
} from "@repo/shadcn-ui/components";
|
||||||
import { PlusIcon, SearchIcon } from "lucide-react";
|
import { CalendarClockIcon, PlusIcon, SearchIcon } from "lucide-react";
|
||||||
import type { ChangeEvent } from "react";
|
import type { ChangeEvent } from "react";
|
||||||
|
|
||||||
import { useTranslation } from "../../../../i18n";
|
import { useTranslation } from "../../../../i18n";
|
||||||
@ -85,20 +88,29 @@ export const PaymentTermsSettingsPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RdxPageContainer width="full">
|
<>
|
||||||
<RdxPageStack className="mx-auto w-full max-w-6xl" spacing="default">
|
<Card>
|
||||||
<RdxPageHeader
|
<CardHeader className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
actions={
|
<div className="flex min-w-0 items-start gap-4">
|
||||||
<Button className="w-full sm:w-auto" onClick={featureCtrl.openCreateDialog}>
|
<div className="flex size-11 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
|
||||||
<PlusIcon aria-hidden className="mr-2 size-4" />
|
<CalendarClockIcon aria-hidden className="size-6" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 space-y-1">
|
||||||
|
<h2 className="text-2xl font-semibold tracking-tight">
|
||||||
|
{t("settings.paymentTerms.title")}
|
||||||
|
</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t("settings.paymentTerms.description")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button className="shrink-0 self-start" onClick={featureCtrl.openCreateDialog}>
|
||||||
|
<PlusIcon aria-hidden className="size-4" />
|
||||||
{t("settings.paymentTerms.actions.create")}
|
{t("settings.paymentTerms.actions.create")}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
</CardHeader>
|
||||||
description={t("settings.paymentTerms.description")}
|
<CardContent className="@container space-y-4">
|
||||||
title={t("settings.paymentTerms.title")}
|
<div className="flex flex-col gap-4 rounded-xl border border-border/60 bg-card p-4 shadow-none lg:flex-row lg:items-center lg:justify-between">
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-4 rounded-xl border border-border/60 bg-card p-4 shadow-none md:p-5 lg:flex-row lg:items-center lg:justify-between">
|
|
||||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
|
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||||||
<div className="relative w-full lg:w-96 xl:w-[30rem]">
|
<div className="relative w-full lg:w-96 xl:w-[30rem]">
|
||||||
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
@ -145,7 +157,9 @@ export const PaymentTermsSettingsPage = () => {
|
|||||||
|
|
||||||
<div className="flex items-center gap-2 text-sm text-muted-foreground lg:justify-end">
|
<div className="flex items-center gap-2 text-sm text-muted-foreground lg:justify-end">
|
||||||
{ctrl.isBackgroundFetching ? <Spinner aria-hidden className="size-4" /> : null}
|
{ctrl.isBackgroundFetching ? <Spinner aria-hidden className="size-4" /> : null}
|
||||||
<span>{t("settings.paymentTerms.toolbar.totalCount", { count: ctrl.totalItems })}</span>
|
<span>
|
||||||
|
{t("settings.paymentTerms.toolbar.totalCount", { count: ctrl.totalItems })}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -176,6 +190,8 @@ export const PaymentTermsSettingsPage = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<PaymentTermFormDialog
|
<PaymentTermFormDialog
|
||||||
description={t("settings.paymentTerms.create.description")}
|
description={t("settings.paymentTerms.create.description")}
|
||||||
@ -222,7 +238,6 @@ export const PaymentTermsSettingsPage = () => {
|
|||||||
open={Boolean(featureCtrl.deletingPaymentTerm)}
|
open={Boolean(featureCtrl.deletingPaymentTerm)}
|
||||||
target={featureCtrl.deletingPaymentTerm}
|
target={featureCtrl.deletingPaymentTerm}
|
||||||
/>
|
/>
|
||||||
</RdxPageStack>
|
</>
|
||||||
</RdxPageContainer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user