mobigrid-module 1.1.31 → 1.1.35

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 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 handleEdit = (row) => {
21
- console.log('Edit row:', row);
20
+ const handlePrint = (row) => {
21
+ console.log('Print ticket:', row.ticket_numbers);
22
22
  };
23
23
 
24
- const handleDelete = (row) => {
25
- console.log('Delete row:', row);
24
+ const handleRefund = (row) => {
25
+ console.log('Refund transaction:', row.request_id);
26
26
  };
27
27
 
28
- const checkEditPermission = (row) => {
29
- return row.status !== 'LOCKED';
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/data"
38
+ dataUrl="https://api.example.com/transactions"
38
39
  callbacks={{
39
- onEdit: handleEdit,
40
- onDelete: handleDelete,
41
- canEdit: checkEditPermission
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": "User Management",
75
- "data_url": "https://api.example.com/users",
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": "search",
81
- "label": "Search Users"
83
+ "name": "request_id",
84
+ "label": "Request ID"
82
85
  },
83
86
  {
84
87
  "type": "Select",
85
- "name": "role",
86
- "label": "Role",
87
- "urlSource": "https://api.example.com/roles" // Dynamic options
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": [ // Note: spelling is 'colomns' in current version
109
+ "colomns": [
110
+ {
111
+ "title": "Request ID",
112
+ "key": "request_id",
113
+ "type": "text"
114
+ },
115
+ {
116
+ "title": "Date",
117
+ "key": "created_date",
118
+ "type": "date",
119
+ "pattern": "dd/MM/yyyy HH:mm"
120
+ },
104
121
  {
105
- "title": "Name",
106
- "key": "fullName",
122
+ "title": "POS Code",
123
+ "key": "pos_code",
107
124
  "type": "text"
108
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": "Edit",
126
- "icon": "icon-edit",
127
- "action": "onEdit",
128
- "condition": "canEdit"
142
+ "label": "Print",
143
+ "icon": "icon-printer",
144
+ "action": "onPrint",
145
+ "condition": "checkPrint"
129
146
  }
130
147
  ]
131
148
  }
@@ -151,11 +168,11 @@ 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.