mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
60 lines
1.5 KiB
React
60 lines
1.5 KiB
React
import { Plus, RefreshCw, Download, Archive } from "lucide-react";
|
|
import { exportTableToExcel } from "@/utils/excel.util";
|
|
|
|
export function buildToolbarActions({
|
|
fetchPlans,
|
|
pagination,
|
|
exportConfig,
|
|
navigate,
|
|
showArchived,
|
|
onToggleArchived,
|
|
getFilters,
|
|
getSort,
|
|
getTableInstance,
|
|
}) {
|
|
return [
|
|
{
|
|
key: "refresh",
|
|
type: "button",
|
|
label: "Refresh",
|
|
icon: <RefreshCw className="h-3.5 w-3.5" />,
|
|
variant: "outline",
|
|
onClick: () => fetchPlans({
|
|
page: 1,
|
|
limit: pagination?.limit ?? 10,
|
|
filters: getFilters(),
|
|
sort: getSort(),
|
|
archived: showArchived,
|
|
}),
|
|
},
|
|
{
|
|
key: "export",
|
|
type: "button",
|
|
label: "Export",
|
|
icon: <Download className="h-3.5 w-3.5" />,
|
|
variant: "outline",
|
|
onClick: () => exportTableToExcel({
|
|
...exportConfig,
|
|
tableInstance: getTableInstance(),
|
|
}),
|
|
},
|
|
{
|
|
key: "create",
|
|
type: "button",
|
|
label: "New Plan",
|
|
icon: <Plus className="h-3.5 w-3.5" />,
|
|
variant: "default",
|
|
hidden: showArchived,
|
|
onClick: () => navigate("/admin/tiers/plans/add"),
|
|
},
|
|
{
|
|
key: "toggle-archived",
|
|
type: "button",
|
|
icon: <Archive className="h-3.5 w-3.5" />,
|
|
label: showArchived ? "Active Plans" : "Archived Plans",
|
|
variant: "secondary",
|
|
className: "border border-border",
|
|
onClick: onToggleArchived,
|
|
},
|
|
];
|
|
} |