mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
34 lines
1.3 KiB
React
34 lines
1.3 KiB
React
// config/selection.config.jsx
|
|
import { Download, Archive, Trash2 } from "lucide-react";
|
|
import { exportTableToExcel } from "@/utils/excel.util";
|
|
|
|
/**
|
|
* @param {Object} deps
|
|
* @param {Object} deps.exportConfig { allData, attributes, filename, sheetName }
|
|
* @param {Function} deps.archiveUser Archive handler from useManagement
|
|
* @param {Function} deps.deleteUser Delete handler from useManagement
|
|
*/
|
|
export function buildSelectionActions({ exportConfig, archiveGroup, archiveGroups, getTableInstance }) {
|
|
return [
|
|
{
|
|
key: "export-selected",
|
|
label: "Export",
|
|
icon: <Download className="h-3.5 w-3.5" />,
|
|
onClick: (rows, table) =>
|
|
exportTableToExcel({ ...exportConfig, selectedRows: rows, tableInstance: table ?? getTableInstance(), }),
|
|
},
|
|
{
|
|
key: "archive-selected",
|
|
label: "Archive",
|
|
icon: <Archive className="h-3.5 w-3.5" />,
|
|
className: "text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive",
|
|
onClick: (rows) => {
|
|
const ids = rows.map((r) => r.group_id);
|
|
ids.length === 1
|
|
? archiveGroup(rows[0]) // opens single dialog
|
|
: archiveGroups(ids); // opens bulk dialog
|
|
},
|
|
hidden: (rows) => rows.every((r) => r.status === "archived"),
|
|
},
|
|
];
|
|
} |