mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
47 lines
1.8 KiB
React
47 lines
1.8 KiB
React
// ─── config/toolbar.config.jsx ────────────────────────────────────────────────
|
|
import { RefreshCw, Download, FolderPlus, Archive } from "lucide-react";
|
|
import { exportTableToExcel } from "@/utils/excel.util";
|
|
|
|
/**
|
|
* @param {Object} deps
|
|
* @param {Function} deps.fetchUsers Refetch handler from useUsers
|
|
* @param {Object} deps.pagination Current pagination state
|
|
* @param {Object} deps.exportConfig { allData, attributes, filename, sheetName }
|
|
* @param {Function} deps.navigate React Router navigate
|
|
*/
|
|
export function buildToolbarActions({ fetchGroups, pagination, exportConfig, onAddGroup, navigate, getFilters, getSort, getTableInstance }) {
|
|
return [
|
|
{
|
|
key: "refresh",
|
|
type: "button",
|
|
icon: <RefreshCw className="h-3.5 w-3.5" />,
|
|
label: "Refresh",
|
|
onClick: () => fetchGroups({ page: 1, limit: pagination.limit, filters: getFilters(), sort: getSort() }),
|
|
},
|
|
{
|
|
key: "export",
|
|
type: "button",
|
|
icon: <Download className="h-3.5 w-3.5" />,
|
|
label: "Export",
|
|
onClick: (table) => exportTableToExcel({ ...exportConfig, tableInstance: table ?? getTableInstance() }),
|
|
},
|
|
{
|
|
key: "add-group",
|
|
type: "button",
|
|
icon: <FolderPlus className="h-3.5 w-3.5" />,
|
|
label: "Add Group",
|
|
variant: "default",
|
|
className: "text-primary-foreground",
|
|
onClick: () => onAddGroup(),
|
|
},
|
|
{
|
|
key: "archived-groups",
|
|
type: "button",
|
|
icon: <Archive className="h-3.5 w-3.5" />,
|
|
label: "Archived Groups",
|
|
variant: "secondary",
|
|
className: "border border-border",
|
|
onClick: () => navigate("/admin/users/groups/archived"),
|
|
},
|
|
];
|
|
} |