@@ -2,6 +2,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { buildColumns } from "@/utils/table.util";
|
||||
import { buildSelectionColumn } from "@/components/generic/Table/buildSelectionColumn";
|
||||
import { buildRowActionsColumn } from "@/components/generic/Table/buildRowActionsColumn";
|
||||
import { resolveTierBadge } from "@/utils/tierBadge.util";
|
||||
|
||||
export const columnPinning = {
|
||||
right: ["actions"],
|
||||
@@ -17,39 +18,35 @@ const STATUS_BADGE = {
|
||||
refunded: "outline",
|
||||
};
|
||||
|
||||
const TIER_BADGE = { premium: "default", exclusive: "destructive" };
|
||||
|
||||
const cellOverrides = {
|
||||
status: (info) => (
|
||||
<Badge variant={STATUS_BADGE[info.getValue()] ?? "outline"} className="capitalize">
|
||||
{info.getValue()}
|
||||
</Badge>
|
||||
),
|
||||
amount: (info) => {
|
||||
const row = info.row.original;
|
||||
return (
|
||||
<span className="text-sm font-medium">
|
||||
{row.currency} {Number(info.getValue()).toFixed(2)}
|
||||
export function buildDataColumns(attributes, rowActions, fmtDateTime = (v) => v ? new Date(v).toLocaleString() : "—", tierMap = {}) {
|
||||
const cellOverrides = {
|
||||
status: (info) => (
|
||||
<Badge variant={STATUS_BADGE[info.getValue()] ?? "outline"} className="capitalize">
|
||||
{info.getValue()}
|
||||
</Badge>
|
||||
),
|
||||
amount: (info) => {
|
||||
const row = info.row.original;
|
||||
return (
|
||||
<span className="text-sm font-medium">
|
||||
{row.currency} {Number(info.getValue()).toFixed(2)}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
"plan.tier": (info) => {
|
||||
const { cls, label } = resolveTierBadge(info.getValue(), tierMap);
|
||||
return <Badge className={`${cls} capitalize`}>{label}</Badge>;
|
||||
},
|
||||
paid_at: (info) => (
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{fmtDateTime(info.getValue())}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
"plan.tier": (info) => (
|
||||
<Badge variant={TIER_BADGE[info.getValue()] ?? "outline"} className="capitalize">
|
||||
{info.getValue()}
|
||||
</Badge>
|
||||
),
|
||||
paid_at: (info) => (
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{info.getValue() ? new Date(info.getValue()).toLocaleString() : "—"}
|
||||
</span>
|
||||
),
|
||||
"user.email": (info) => (
|
||||
<span className="text-sm">{info.getValue() ?? "—"}</span>
|
||||
),
|
||||
|
||||
};
|
||||
),
|
||||
"user.email": (info) => (
|
||||
<span className="text-sm">{info.getValue() ?? "—"}</span>
|
||||
),
|
||||
};
|
||||
|
||||
export function buildDataColumns(attributes, rowActions) {
|
||||
const visibleAttributes = attributes.filter((a) => !a.hidden);
|
||||
return [
|
||||
buildSelectionColumn(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Plus, RefreshCw, Download, Archive } from "lucide-react";
|
||||
import { Plus, RefreshCw, Download, Archive, Layers } from "lucide-react";
|
||||
import { exportTableToExcel } from "@/utils/excel.util";
|
||||
|
||||
export function buildToolbarActions({
|
||||
@@ -7,6 +7,7 @@ export function buildToolbarActions({
|
||||
exportConfig,
|
||||
navigate,
|
||||
showArchived,
|
||||
hasAvailableCategories,
|
||||
onToggleArchived,
|
||||
getFilters,
|
||||
getSort,
|
||||
@@ -38,13 +39,21 @@ export function buildToolbarActions({
|
||||
tableInstance: getTableInstance(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: "categories",
|
||||
type: "button",
|
||||
label: "Tier Categories",
|
||||
icon: <Layers className="h-3.5 w-3.5" />,
|
||||
variant: "outline",
|
||||
onClick: () => navigate("/admin/tiers/categories"),
|
||||
},
|
||||
{
|
||||
key: "create",
|
||||
type: "button",
|
||||
label: "New Plan",
|
||||
icon: <Plus className="h-3.5 w-3.5" />,
|
||||
variant: "default",
|
||||
hidden: showArchived,
|
||||
hidden: showArchived || !hasAvailableCategories,
|
||||
onClick: () => navigate("/admin/tiers/plans/add"),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user