fix: consolidate backend changes and fix icon imports

- Add standard .gitignore patterns (node_modules, .env, IDE files)
- Coupon.php: fix data structure for DataTable, add status filter
- Order.php: fix data structure to match OrderListItem expectations
- Product.php: add multi-currency prices array, unify nonce to 'formipay-admin'
- client.js: fix AJAX action names to match PHP (underscores → hyphens)
- OrderList.js: fix icon import (Icons.list), add response handling
- OrderListItem.js: fix icon import (Icons.seen)
This commit is contained in:
dwindown
2026-04-19 06:04:10 +07:00
parent 63e62b6a3e
commit d8c81a4022
7 changed files with 131 additions and 58 deletions

View File

@@ -103,8 +103,8 @@ export const customersApi = {
* Products API
*/
export const productsApi = {
list: (params = {}) => ajaxRequest('formipay_tabledata_products', params),
get: (productId) => ajaxRequest('formipay_get_product', { post_id: productId }),
list: (params = {}) => ajaxRequest('formipay-tabledata-products', params),
get: (productId) => ajaxRequest('formipay-get-product', { post_id: productId }),
getVariables: (productId) => ajaxRequest('get_product_variables', { post_id: productId }),
};

View File

@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
import { useState, useCallback, useEffect } from '@wordpress/element';
import { SearchControl, SelectControl, Button } from '@wordpress/components';
import { Icon } from '@wordpress/icons';
import list from '@wordpress/icons/build/list';
import * as Icons from '@wordpress/icons';
import { ordersApi } from '../../api/client';
import OrderListItem from './OrderListItem';
import './OrderList.css';
@@ -37,9 +37,14 @@ export default function OrderList({ onSelectOrder }) {
offset: pagination.offset,
})
.then(result => {
if (result.data) {
setOrders(result.data.results || []);
setTotal(result.data.total || 0);
console.log('Orders API response:', result);
// Handle both response formats: with or without data wrapper
const data = result.data || result;
if (data) {
setOrders(data.results || []);
setTotal(data.total || 0);
} else {
console.error('Unexpected response structure:', result);
}
})
.catch(error => {
@@ -86,7 +91,7 @@ export default function OrderList({ onSelectOrder }) {
<div className="formipay-order-list">
<div className="formipay-orders-header">
<h2>
<Icon icon={list()} />
<Icon icon={Icons.list} />
{ __('Orders', 'formipay') }
</h2>
<span className="order-count">

View File

@@ -4,7 +4,7 @@
import { __ } from '@wordpress/i18n';
import { Icon } from '@wordpress/icons';
import seen from '@wordpress/icons/build/visible';
import * as Icons from '@wordpress/icons';
import './OrderListItem.css';
const STATUS_COLORS = {
@@ -79,7 +79,7 @@ export default function OrderListItem({ order, onSelect }) {
className="button button-small"
onClick={onSelect}
>
<Icon icon={seen()} size={16} />
<Icon icon={Icons.seen} size={16} />
{ __('View', 'formipay') }
</button>
</td>