diff --git a/includes/Admin/ReactAdmin.php b/includes/Admin/ReactAdmin.php index c7bd80de4..07cfafd6b 100644 --- a/includes/Admin/ReactAdmin.php +++ b/includes/Admin/ReactAdmin.php @@ -65,6 +65,8 @@ class ReactAdmin { 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'restUrl' => rest_url( 'formipay/v1' ), 'nonce' => wp_create_nonce( 'formipay-admin' ), + 'pluginUrl' => FORMIPAY_URL, + 'siteUrl' => site_url(), ] ); // Debug logging @@ -149,7 +151,7 @@ class ReactAdmin { public static function render_mount_point( $page ) { printf( - '
Unknown page: {page}
+Unknown page: {currentPage}
| - | ; + } + const step = price.currency_decimal_digits ? 1 / Math.pow(10, price.currency_decimal_digits) : 0.01; diff --git a/src/admin/components/shared/DataTable.css b/src/admin/components/shared/DataTable.css index bafd3c92f..077a14ad0 100644 --- a/src/admin/components/shared/DataTable.css +++ b/src/admin/components/shared/DataTable.css @@ -21,6 +21,18 @@ min-width: 150px; } +.formipay-table-toolbar *:is(button,input,select) { + height: 40px!important; +} + +.formipay-table-toolbar .components-base-control__field { + margin-bottom: unset!important; +} + +.formipay-table-toolbar *:is(button, input, select, .components-input-control__backdrop){ + border-radius: 4px!important; +} + /* Filter Tabs */ .formipay-filter-tabs { display: flex; @@ -112,6 +124,14 @@ background-color: #f0f0f1; } +.formipay-table *:is(td, th):first-child { + text-align: center; +} + +.formipay-table th.column-select > input { + margin-left: 0; +} + /* Checkbox Column */ .formipay-table .column-select { width: 40px; diff --git a/src/admin/components/shared/DataTable.js b/src/admin/components/shared/DataTable.js index 07be80d2f..7d23ee35b 100644 --- a/src/admin/components/shared/DataTable.js +++ b/src/admin/components/shared/DataTable.js @@ -60,6 +60,9 @@ export default function DataTable({ tableAction, // e.g., 'formipay-tabledata-forms' deleteAction, duplicateAction, + + // Selection callback + onSelectionChange, }) { // State const [data, setData] = useState(initialData); @@ -82,6 +85,13 @@ export default function DataTable({ const [selectedRows, setSelectedRows] = useState(new Set()); const [selectAll, setSelectAll] = useState(false); + // Notify parent of selection changes + useEffect(() => { + if (onSelectionChange) { + onSelectionChange(selectedRows); + } + }, [selectedRows, onSelectionChange]); + // Add New Modal const [isAddModalOpen, setIsAddModalOpen] = useState(false); const [newItemTitle, setNewItemTitle] = useState(''); @@ -89,8 +99,6 @@ export default function DataTable({ // Derive action names from tableAction const baseActionName = tableAction.replace('formipay-tabledata-', ''); const bulkDeleteAction = actions.bulkDelete?.action || `formipay-bulk-delete-${baseActionName}`; - const deleteActionName = deleteAction || `formipay-delete-${baseActionName}`; - const duplicateActionName = duplicateAction || `formipay-duplicate-${baseActionName}`; // Load data const loadData = useCallback(async () => { @@ -213,56 +221,6 @@ export default function DataTable({ } }; - // Handle inline delete - const handleDelete = async (id) => { - const result = await Swal.fire({ - icon: 'info', - html: __('Do you want to delete this item?', 'formipay'), - showCancelButton: true, - confirmButtonText: __('Delete Permanently', 'formipay'), - cancelButtonText: __('Cancel', 'formipay'), - }); - - if (result.isConfirmed) { - await fetch(`${ajaxUrl}?action=${deleteActionName}`, { - method: 'POST', - credentials: 'same-origin', - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: new URLSearchParams({ - id, - _wpnonce: nonce, - }), - }); - - loadData(); - } - }; - - // Handle duplicate - const handleDuplicate = async (id) => { - const result = await Swal.fire({ - icon: 'info', - html: __('Do you want to duplicate this item?', 'formipay'), - showCancelButton: true, - confirmButtonText: __('Confirm', 'formipay'), - cancelButtonText: __('Cancel', 'formipay'), - }); - - if (result.isConfirmed) { - await fetch(`${ajaxUrl}?action=${duplicateActionName}`, { - method: 'POST', - credentials: 'same-origin', - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: new URLSearchParams({ - id, - _wpnonce: nonce, - }), - }); - - loadData(); - } - }; - // Handle Add New const handleAddNew = async () => { if (!newItemTitle.trim()) { @@ -356,6 +314,15 @@ export default function DataTable({ }} /> )} + + {/* Refresh Button */} + {/* Filter Tabs */} @@ -408,10 +375,6 @@ export default function DataTable({ {column.label} ))} - {/* Actions column */} - {actions.inline && ( -{__('Actions', 'formipay')} | - )} @@ -435,41 +398,6 @@ export default function DataTable({ {column.render ? column.render(row) : row[column.key]} ))} - {/* Actions */} - {actions.inline && ( -- - {__('Edit', 'formipay')} - - {' | '} - - - {' | '} - - - | - )} ); })} @@ -531,7 +459,7 @@ export default function DataTable({ )} - {/* Add New Modal - only render when actually open */} + {/* Add New Modal - only render when open */} {actions.addNew && isAddModalOpen && (
|---|