diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-04 09:39:21 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-04 09:39:21 +0000 |
| commit | 53ad72732f781e6c6d5ddb3776ea47aec010af8e (patch) | |
| tree | e676287827f8634be767a674b8ad08b6ed7eb3e6 /lib/pq/table/pq-lists-toolbar.tsx | |
| parent | 3e4d15271322397764601dee09441af8a5b3adf5 (diff) | |
(최겸) PQ/실사 수정 및 개발
Diffstat (limited to 'lib/pq/table/pq-lists-toolbar.tsx')
| -rw-r--r-- | lib/pq/table/pq-lists-toolbar.tsx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/pq/table/pq-lists-toolbar.tsx b/lib/pq/table/pq-lists-toolbar.tsx new file mode 100644 index 00000000..3a85327d --- /dev/null +++ b/lib/pq/table/pq-lists-toolbar.tsx @@ -0,0 +1,61 @@ +"use client"
+
+import * as React from "react"
+import { Button } from "@/components/ui/button"
+import { Trash, CopyPlus, Plus } from "lucide-react"
+import { type Table } from "@tanstack/react-table"
+import type { PQList } from "./pq-lists-columns"
+// import { PqListForm } from "./add-pq-list-dialog"
+
+interface PQListsToolbarActionsProps {
+ table: Table<PQList>;
+ onAddClick: () => void;
+ onCopyClick: () => void;
+ onToggleActive: (rows: PQList[], newIsDeleted: boolean) => void;
+}
+
+export function PQListsToolbarActions({
+ table,
+ onAddClick,
+ onCopyClick,
+ onToggleActive,
+}: PQListsToolbarActionsProps) {
+ const selected = table.getFilteredSelectedRowModel().rows.map(r => r.original);
+ const allActive = selected.length > 0 && selected.every(item => !item.isDeleted);
+ const allDeleted = selected.length > 0 && selected.every(item => item.isDeleted);
+
+ let toggleLabel = "";
+ let newState: boolean | undefined;
+ if (selected.length > 0) {
+ if (allActive) {
+ toggleLabel = "비활성화";
+ newState = true;
+ } else if (allDeleted) {
+ toggleLabel = "활성화";
+ newState = false;
+ }
+ }
+
+ return (
+ <div className="flex items-center gap-2">
+ {selected.length > 0 && (allActive || allDeleted) && newState !== undefined && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => onToggleActive(selected, newState!)}
+ >
+ <Trash className="mr-2 h-4 w-4" />
+ {toggleLabel}
+ </Button>
+ )}
+ <Button size="sm" onClick={onAddClick}>
+ <Plus className="mr-2 h-4 w-4" />
+ 추가
+ </Button>
+ <Button size="sm" variant="outline" onClick={onCopyClick}>
+ <CopyPlus className="mr-2 h-4 w-4" />
+ 복사
+ </Button>
+ </div>
+ );
+}
|
