mobigrid-module 1.1.31 → 1.1.36
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.
- package/README.md +72 -32
- package/dist/components/Layout/PageHeader.d.ts +8 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/examples/transportors/src/App.d.ts +0 -2
- package/dist/examples/transportors/src/App.test.d.ts +0 -1
- package/dist/examples/transportors/src/components/ui/dialog.d.ts +0 -19
- package/dist/examples/transportors/src/index.d.ts +0 -1
- package/dist/examples/transportors/src/reportWebVitals.d.ts +0 -3
- package/dist/examples/transportors/src/setupTests.d.ts +0 -1
package/README.md
CHANGED
|
@@ -17,16 +17,17 @@ import MobigridModule from 'mobigrid-module';
|
|
|
17
17
|
import 'mobigrid-module/dist/index.css'; // Import styles if necessary
|
|
18
18
|
|
|
19
19
|
function App() {
|
|
20
|
-
const
|
|
21
|
-
console.log('
|
|
20
|
+
const handlePrint = (row) => {
|
|
21
|
+
console.log('Print ticket:', row.ticket_numbers);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
console.log('
|
|
24
|
+
const handleRefund = (row) => {
|
|
25
|
+
console.log('Refund transaction:', row.request_id);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// Callback to determine if print button should be shown
|
|
29
|
+
const canPrintTicket = (row) => {
|
|
30
|
+
return row.status === 'PAID' && row.canPrint === true;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
return (
|
|
@@ -34,11 +35,11 @@ function App() {
|
|
|
34
35
|
configUrl="https://api.example.com/config"
|
|
35
36
|
// OR provide configJson directly
|
|
36
37
|
// configJson={myConfigObject}
|
|
37
|
-
dataUrl="https://api.example.com/
|
|
38
|
+
dataUrl="https://api.example.com/transactions"
|
|
38
39
|
callbacks={{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
onPrint: handlePrint,
|
|
41
|
+
onRefund: handleRefund,
|
|
42
|
+
checkPrint: canPrintTicket
|
|
42
43
|
}}
|
|
43
44
|
customHeaders={{
|
|
44
45
|
'Authorization': 'Bearer token123'
|
|
@@ -69,22 +70,27 @@ The `MobigridModule` accepts the following props:
|
|
|
69
70
|
|
|
70
71
|
The configuration object defines the structure of the table, filters, and columns. You can provide this via the `configUrl` endpoint or directly via the `configJson` prop.
|
|
71
72
|
|
|
73
|
+
### Example Configuration (Payment History)
|
|
74
|
+
|
|
72
75
|
```json
|
|
73
76
|
{
|
|
74
|
-
"title": "
|
|
75
|
-
"data_url": "https://api.example.com/
|
|
77
|
+
"title": "Payment History",
|
|
78
|
+
"data_url": "https://api.example.com/payments",
|
|
76
79
|
"Filters": [
|
|
77
80
|
[
|
|
78
81
|
{
|
|
79
82
|
"type": "Text",
|
|
80
|
-
"name": "
|
|
81
|
-
"label": "
|
|
83
|
+
"name": "request_id",
|
|
84
|
+
"label": "Request ID"
|
|
82
85
|
},
|
|
83
86
|
{
|
|
84
87
|
"type": "Select",
|
|
85
|
-
"name": "
|
|
86
|
-
"label": "
|
|
87
|
-
"
|
|
88
|
+
"name": "status",
|
|
89
|
+
"label": "Status",
|
|
90
|
+
"options": [
|
|
91
|
+
{ "label": "Paid", "value": "PAID" },
|
|
92
|
+
{ "label": "Failed", "value": "FAILED" }
|
|
93
|
+
]
|
|
88
94
|
}
|
|
89
95
|
],
|
|
90
96
|
[
|
|
@@ -100,32 +106,43 @@ The configuration object defines the structure of the table, filters, and column
|
|
|
100
106
|
}
|
|
101
107
|
]
|
|
102
108
|
],
|
|
103
|
-
"colomns": [
|
|
109
|
+
"colomns": [
|
|
104
110
|
{
|
|
105
|
-
"title": "
|
|
106
|
-
"key": "
|
|
111
|
+
"title": "Request ID",
|
|
112
|
+
"key": "request_id",
|
|
107
113
|
"type": "text"
|
|
108
114
|
},
|
|
115
|
+
{
|
|
116
|
+
"title": "Date",
|
|
117
|
+
"key": "created_date",
|
|
118
|
+
"type": "date",
|
|
119
|
+
"pattern": "dd/MM/yyyy HH:mm"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"title": "POS Code",
|
|
123
|
+
"key": "pos_code",
|
|
124
|
+
"type": "text"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"title": "Amount",
|
|
128
|
+
"key": "amount",
|
|
129
|
+
"type": "money",
|
|
130
|
+
"currency": "MAD"
|
|
131
|
+
},
|
|
109
132
|
{
|
|
110
133
|
"title": "Status",
|
|
111
134
|
"key": "status",
|
|
112
135
|
"type": "status"
|
|
113
136
|
},
|
|
114
|
-
{
|
|
115
|
-
"title": "Created At",
|
|
116
|
-
"key": "createdAt",
|
|
117
|
-
"type": "date",
|
|
118
|
-
"pattern": "dd/MM/yyyy"
|
|
119
|
-
},
|
|
120
137
|
{
|
|
121
138
|
"title": "Actions",
|
|
122
139
|
"key": "ACTIONS_BUTTONS",
|
|
123
140
|
"actions": [
|
|
124
141
|
{
|
|
125
|
-
"label": "
|
|
126
|
-
"icon": "icon-
|
|
127
|
-
"action": "
|
|
128
|
-
"condition": "
|
|
142
|
+
"label": "Print",
|
|
143
|
+
"icon": "icon-printer",
|
|
144
|
+
"action": "onPrint",
|
|
145
|
+
"condition": "checkPrint"
|
|
129
146
|
}
|
|
130
147
|
]
|
|
131
148
|
}
|
|
@@ -151,15 +168,38 @@ Filters are defined as an array of arrays (rows of filters).
|
|
|
151
168
|
Defines the table columns.
|
|
152
169
|
|
|
153
170
|
- **`title`**: Header text for the column.
|
|
154
|
-
- **`key`**: The key in the data object to display.
|
|
171
|
+
- **`key`**: The key in the data object to display (e.g., `request_id`, `amount`).
|
|
155
172
|
- **`type`**: formatting type.
|
|
156
173
|
- `"text"`: Default display.
|
|
157
174
|
- `"date"`: Formats date using `pattern` (default: `dd-MM-yyyy`).
|
|
158
|
-
- `"money"`: Formats as currency. Usage: `currency` prop required.
|
|
175
|
+
- `"money"`: Formats as currency. Usage: `currency` prop required (e.g., "MAD").
|
|
159
176
|
- `"status"`: Displays a colored badge based on status value (PENDING, PAID, CANCELLED, etc.).
|
|
160
177
|
- `"ACTIONS_BUTTONS"`: Special column for action buttons.
|
|
161
178
|
- **`scroll`**: If true, limits height and adds scrollbar for long content.
|
|
162
179
|
|
|
180
|
+
### Extra Metrics Configuration (`extra`)
|
|
181
|
+
|
|
182
|
+
Aggregates the API returns alongside the rows, under an `EXTRA` array in the
|
|
183
|
+
response (`{ "DATA": [...], "EXTRA": [{ "sumamounts": 50502 }], "PAGESNUM": 2379 }`).
|
|
184
|
+
The first `EXTRA` object is read; each configured metric is displayed as a badge
|
|
185
|
+
next to the row count in the page header.
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
"extra": [
|
|
189
|
+
{
|
|
190
|
+
"title": "Volume",
|
|
191
|
+
"key": "sumamounts",
|
|
192
|
+
"type": "money",
|
|
193
|
+
"currency": "DH"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
- **`key`**: The key in the `EXTRA` object. Keys missing from the response are skipped.
|
|
199
|
+
- **`title`**: (Optional) Shown as the badge tooltip.
|
|
200
|
+
- **`type`**: `"money"` and `"number"` are grouped by thousands (`50502` -> `50 502`);
|
|
201
|
+
`"money"` appends `currency`. Anything else is displayed as-is.
|
|
202
|
+
|
|
163
203
|
### Actions Configuration
|
|
164
204
|
|
|
165
205
|
For columns with `key: "ACTIONS_BUTTONS"`, you can define an `actions` array.
|
|
@@ -6,10 +6,17 @@ interface PageHeaderProps {
|
|
|
6
6
|
setFilters: (filters: any) => void;
|
|
7
7
|
onSearch: () => void;
|
|
8
8
|
count: number;
|
|
9
|
+
extra?: Record<string, any> | null;
|
|
10
|
+
extraConfig?: Array<{
|
|
11
|
+
title?: string;
|
|
12
|
+
key: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
currency?: string;
|
|
15
|
+
}>;
|
|
9
16
|
isLoading: boolean;
|
|
10
17
|
setCurrentPage: (page: number) => void;
|
|
11
18
|
handleOptionsSearch: (filter: any, search: string) => void;
|
|
12
19
|
optionsLoading: boolean;
|
|
13
20
|
}
|
|
14
|
-
export declare function PageHeader({ title, filters, setFilters, configFilters, onSearch, count, isLoading, setCurrentPage, handleOptionsSearch, optionsLoading, }: PageHeaderProps): React.JSX.Element;
|
|
21
|
+
export declare function PageHeader({ title, filters, setFilters, configFilters, onSearch, count, extra, extraConfig, isLoading, setCurrentPage, handleOptionsSearch, optionsLoading, }: PageHeaderProps): React.JSX.Element;
|
|
15
22
|
export {};
|