vasuzex 2.1.18 → 2.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Eye, Edit2, Trash2 } from "lucide-react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ActionDefaults - Production Ready
|
|
5
5
|
*
|
|
6
6
|
* Default configurations for common DataTable actions
|
|
7
7
|
* Provides sensible defaults for edit, view, delete, and switch actions
|
|
8
|
+
* Uses lucide-react icons matching RowActionsCell design
|
|
8
9
|
*
|
|
9
10
|
* @module components/DataTable/ActionDefaults
|
|
10
11
|
*/
|
|
@@ -13,26 +14,26 @@ export const ACTION_DEFAULTS = {
|
|
|
13
14
|
edit: {
|
|
14
15
|
type: "link",
|
|
15
16
|
label: "Edit",
|
|
16
|
-
icon:
|
|
17
|
+
icon: Edit2,
|
|
17
18
|
title: "Edit",
|
|
18
19
|
extraClass:
|
|
19
|
-
"
|
|
20
|
+
"p-1.5 text-gray-600 hover:text-emerald-600 hover:bg-emerald-50 rounded-md transition-colors dark:text-gray-400 dark:hover:text-emerald-400 dark:hover:bg-emerald-950/30",
|
|
20
21
|
},
|
|
21
22
|
view: {
|
|
22
23
|
type: "button",
|
|
23
24
|
label: "View Details",
|
|
24
|
-
icon:
|
|
25
|
+
icon: Eye,
|
|
25
26
|
title: "View Details",
|
|
26
27
|
extraClass:
|
|
27
|
-
"
|
|
28
|
+
"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded-md transition-colors dark:text-gray-400 dark:hover:text-blue-400 dark:hover:bg-blue-950/30",
|
|
28
29
|
},
|
|
29
30
|
delete: {
|
|
30
31
|
type: "button",
|
|
31
32
|
label: "Delete",
|
|
32
|
-
icon:
|
|
33
|
+
icon: Trash2,
|
|
33
34
|
title: "Delete",
|
|
34
35
|
extraClass:
|
|
35
|
-
"
|
|
36
|
+
"p-1.5 text-gray-600 hover:text-rose-600 hover:bg-rose-50 rounded-md transition-colors dark:text-gray-400 dark:hover:text-rose-400 dark:hover:bg-rose-950/30",
|
|
36
37
|
},
|
|
37
38
|
switch: {
|
|
38
39
|
type: "button",
|
|
@@ -42,7 +42,10 @@ export function RowActionsCell({
|
|
|
42
42
|
}) {
|
|
43
43
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
44
44
|
const menuRef = useRef(null);
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
// Determine which approval actions to show based on current status
|
|
47
|
+
const showApprove = hasApproval && (row.approval_status === 'pending' || row.approval_status === 'rejected');
|
|
48
|
+
const showReject = hasApproval && (row.approval_status === 'pending' || row.approval_status === 'approved');
|
|
46
49
|
|
|
47
50
|
// Close menu when clicking outside
|
|
48
51
|
useEffect(() => {
|
|
@@ -106,10 +109,10 @@ export function RowActionsCell({
|
|
|
106
109
|
|
|
107
110
|
{isMenuOpen && (
|
|
108
111
|
<div className="absolute right-0 mt-1 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50 py-1">
|
|
109
|
-
{/* Approval Actions -
|
|
110
|
-
{
|
|
112
|
+
{/* Approval Actions - Show based on current status */}
|
|
113
|
+
{(showApprove || showReject) && (
|
|
111
114
|
<>
|
|
112
|
-
{onApprove && (
|
|
115
|
+
{showApprove && onApprove && (
|
|
113
116
|
<button
|
|
114
117
|
onClick={() => {
|
|
115
118
|
onApprove(row);
|
|
@@ -118,10 +121,10 @@ export function RowActionsCell({
|
|
|
118
121
|
className="w-full flex items-center gap-3 px-4 py-2 text-sm text-emerald-700 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-950/30"
|
|
119
122
|
>
|
|
120
123
|
<CheckCircle className="h-4 w-4" />
|
|
121
|
-
<span>Approve</span>
|
|
124
|
+
<span>{row.approval_status === 'rejected' ? 'Re-approve' : 'Approve'}</span>
|
|
122
125
|
</button>
|
|
123
126
|
)}
|
|
124
|
-
{onReject && (
|
|
127
|
+
{showReject && onReject && (
|
|
125
128
|
<button
|
|
126
129
|
onClick={() => {
|
|
127
130
|
onReject(row);
|
|
@@ -130,7 +133,7 @@ export function RowActionsCell({
|
|
|
130
133
|
className="w-full flex items-center gap-3 px-4 py-2 text-sm text-rose-700 hover:bg-rose-50 dark:text-rose-400 dark:hover:bg-rose-950/30"
|
|
131
134
|
>
|
|
132
135
|
<XCircle className="h-4 w-4" />
|
|
133
|
-
<span>Reject</span>
|
|
136
|
+
<span>{row.approval_status === 'approved' ? 'Revoke/Reject' : 'Reject'}</span>
|
|
134
137
|
</button>
|
|
135
138
|
)}
|
|
136
139
|
<div className="border-t border-gray-200 dark:border-gray-700 my-1" />
|
|
@@ -75,7 +75,7 @@ export function TableBody({
|
|
|
75
75
|
|
|
76
76
|
{/* Render Actions */}
|
|
77
77
|
{actions && (
|
|
78
|
-
<td className="px-
|
|
78
|
+
<td className="px-2 py-2 text-right">
|
|
79
79
|
<div className="flex items-center justify-end gap-2">
|
|
80
80
|
{actions.map((userAction, actionIdx) => {
|
|
81
81
|
// Check visibility first
|
|
@@ -146,7 +146,7 @@ export function TableBody({
|
|
|
146
146
|
const content = action.renderContent ? (
|
|
147
147
|
action.renderContent(row)
|
|
148
148
|
) : Icon ? (
|
|
149
|
-
<Icon className="h-
|
|
149
|
+
<Icon className="h-4 w-4" />
|
|
150
150
|
) : (
|
|
151
151
|
action.label
|
|
152
152
|
);
|