strapi-plugin-payone-provider 4.6.19 → 4.6.21

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,7 +1,23 @@
1
1
  import React from "react";
2
- import { Box, Button, Flex, Typography, Tr, Td } from "@strapi/design-system";
2
+ import {
3
+ Box,
4
+ Button,
5
+ Flex,
6
+ Typography,
7
+ Tr,
8
+ Td,
9
+ SimpleMenu,
10
+ MenuItem,
11
+ Checkbox,
12
+ } from "@strapi/design-system";
3
13
  import { Table } from "@strapi/helper-plugin";
4
- import { ChevronDown, ChevronUp, ArrowUp, ArrowDown } from "@strapi/icons";
14
+ import {
15
+ ChevronDown,
16
+ ChevronUp,
17
+ ArrowUp,
18
+ ArrowDown,
19
+ Bell,
20
+ } from "@strapi/icons";
5
21
 
6
22
  import StatusBadge from "../StatusBadge";
7
23
  import FiltersPanel from "./FiltersPanel";
@@ -14,7 +30,46 @@ import {
14
30
  getPaymentMethodName,
15
31
  } from "../../../utils/transactionTableUtils";
16
32
 
33
+ const headers = [
34
+ { name: "txid", label: "TxId", sortKey: "txid", sortable: true },
35
+ {
36
+ name: "reference",
37
+ label: "Reference",
38
+ sortKey: "reference",
39
+ sortable: true,
40
+ },
41
+ { name: "amount", label: "Amount", sortKey: "amount", sortable: true },
42
+ {
43
+ name: "paymentMethod",
44
+ label: "Payment Method",
45
+ sortKey: null,
46
+ sortable: false,
47
+ },
48
+ { name: "type", label: "Type", sortKey: "request_type", sortable: true },
49
+ { name: "status", label: "Status", sortKey: "status", sortable: true },
50
+ {
51
+ name: "created_at",
52
+ label: "Created At",
53
+ sortKey: "createdAt",
54
+ sortable: true,
55
+ },
56
+ {
57
+ name: "updated_at",
58
+ label: "Updated At",
59
+ sortKey: "updatedAt",
60
+ sortable: true,
61
+ },
62
+ { name: "details", label: "Details", sortKey: null, sortable: false },
63
+ ];
64
+
17
65
  const TransactionTable = () => {
66
+ const [visibleColumns, setVisibleColumns] = React.useState(
67
+ headers.reduce((acc, col) => {
68
+ acc[col.name] = true;
69
+ return acc;
70
+ }, {}),
71
+ );
72
+
18
73
  const {
19
74
  transactions,
20
75
  isLoadingHistory,
@@ -27,21 +82,21 @@ const TransactionTable = () => {
27
82
  handleSort,
28
83
  } = useTransactionHistory();
29
84
 
30
- const headers = [
31
- { name: "txid", label: "TxId", sortKey: "txid", sortable: true },
32
- { name: "reference", label: "Reference", sortKey: "reference", sortable: true },
33
- { name: "amount", label: "Amount", sortKey: "amount", sortable: true },
34
- { name: "paymentMethod", label: "Payment Method", sortKey: null, sortable: false },
35
- { name: "type", label: "Type", sortKey: "request_type", sortable: true },
36
- { name: "status", label: "Status", sortKey: "status", sortable: true },
37
- { name: "created_at", label: "Created At", sortKey: "createdAt", sortable: true },
38
- { name: "updated_at", label: "Updated At", sortKey: "updatedAt", sortable: true },
39
- { name: "details", label: "Details", sortKey: null, sortable: false },
40
- ];
85
+ const toggleableHeaders = headers.filter(
86
+ (header) => header.name !== "details",
87
+ );
88
+ const visibleHeaders = headers.filter(
89
+ (header) => visibleColumns[header.name],
90
+ );
91
+ const visibleColumnCount = Math.max(visibleHeaders.length, 1);
92
+ const areAllToggleableColumnsVisible = toggleableHeaders.every(
93
+ (header) => visibleColumns[header.name],
94
+ );
41
95
 
42
96
  const renderHeaderLabel = (header) => {
43
97
  const isSorted = header.sortKey && sort.sort_by === header.sortKey;
44
- const SortIcon = isSorted && sort.sort_order === "asc" ? ArrowUp : ArrowDown;
98
+ const SortIcon =
99
+ isSorted && sort.sort_order === "asc" ? ArrowUp : ArrowDown;
45
100
 
46
101
  if (!header.sortable || !header.sortKey) {
47
102
  return header.label;
@@ -67,6 +122,115 @@ const TransactionTable = () => {
67
122
  );
68
123
  };
69
124
 
125
+ const toggleColumn = (key) => {
126
+ if (key === "details") {
127
+ return;
128
+ }
129
+
130
+ setVisibleColumns((prev) => {
131
+ const currentlyVisible = headers.filter(
132
+ (header) => prev[header.name],
133
+ ).length;
134
+ const isTryingToHideLastColumn = prev[key] && currentlyVisible === 1;
135
+
136
+ if (isTryingToHideLastColumn) {
137
+ return prev;
138
+ }
139
+
140
+ return {
141
+ ...prev,
142
+ [key]: !prev[key],
143
+ };
144
+ });
145
+ };
146
+
147
+ const showAllColumns = () => {
148
+ setVisibleColumns(
149
+ headers.reduce((acc, col) => {
150
+ acc[col.name] = true;
151
+ return acc;
152
+ }, {}),
153
+ );
154
+ };
155
+
156
+ const renderCellContent = (headerName, transaction, isSelected) => {
157
+ switch (headerName) {
158
+ case "txid":
159
+ return (
160
+ <Typography variant="pi" textColor="neutral600">
161
+ {transaction.txid || "N/A"}
162
+ </Typography>
163
+ );
164
+ case "reference":
165
+ return (
166
+ <Typography variant="pi" fontWeight="medium">
167
+ {transaction.reference || "N/A"}
168
+ </Typography>
169
+ );
170
+ case "amount":
171
+ return (
172
+ <Typography variant="pi" textColor="neutral600">
173
+ {formatAmount(transaction.amount, transaction.currency)}
174
+ </Typography>
175
+ );
176
+ case "paymentMethod":
177
+ return (
178
+ <Typography variant="pi">
179
+ {getPaymentMethodName(
180
+ transaction.raw_request?.clearingtype ||
181
+ transaction?.body?.raw_request?.clearingtype,
182
+ transaction.raw_request?.wallettype ||
183
+ transaction?.body?.raw_request?.wallettype,
184
+ transaction.raw_request?.cardtype ||
185
+ transaction?.body?.raw_request?.cardtype,
186
+ )}
187
+ </Typography>
188
+ );
189
+ case "type":
190
+ return (
191
+ <Typography variant="pi" fontWeight="semiBold">
192
+ {transaction.request_type ||
193
+ transaction?.body?.request_type ||
194
+ "N/A"}
195
+ </Typography>
196
+ );
197
+ case "status":
198
+ return (
199
+ <StatusBadge
200
+ status={transaction.status || transaction?.body?.status}
201
+ transaction={transaction}
202
+ />
203
+ );
204
+ case "created_at":
205
+ return (
206
+ <Typography variant="pi" textColor="neutral600">
207
+ {formatDate(transaction.createdAt ?? transaction.created_at)}
208
+ </Typography>
209
+ );
210
+ case "updated_at":
211
+ return (
212
+ <Typography variant="pi" textColor="neutral600">
213
+ {formatDate(transaction.updatedAt ?? transaction.updated_at)}
214
+ </Typography>
215
+ );
216
+
217
+ case "details":
218
+ return (
219
+ <Button
220
+ variant="tertiary"
221
+ size="S"
222
+ minWidth="100px"
223
+ startIcon={isSelected ? <ChevronUp /> : <ChevronDown />}
224
+ onClick={() => handleTransactionSelect(transaction)}
225
+ >
226
+ {isSelected ? "Hide" : "Details"}
227
+ </Button>
228
+ );
229
+ default:
230
+ return null;
231
+ }
232
+ };
233
+
70
234
  return (
71
235
  <Flex direction="column" alignItems="stretch" gap={4} minHeight={"800px"}>
72
236
  <FiltersPanel
@@ -74,16 +238,49 @@ const TransactionTable = () => {
74
238
  handleFiltersChange={handleFiltersChange}
75
239
  isLoading={isLoadingHistory}
76
240
  />
241
+
242
+ <Flex
243
+ justifyContent="flex-end"
244
+ gap={3}
245
+ alignItems="stretch"
246
+ marginBottom={2}
247
+ marginTop={4}
248
+ >
249
+ <SimpleMenu
250
+ label="Actions"
251
+ id={`actions-menu`}
252
+ as={Button}
253
+ onReachEnd={() => {}}
254
+ variant="secondary"
255
+ >
256
+ {toggleableHeaders.map((header) => (
257
+ <MenuItem
258
+ to={undefined}
259
+ href={undefined}
260
+ onClick={() => toggleColumn(header.name)}
261
+ >
262
+ <Flex alignItems="center" gap={2}>
263
+ <Checkbox
264
+ checked={visibleColumns[header.name]}
265
+ onChange={() => toggleColumn(header.name)}
266
+ />
267
+ <span>{header.label}</span>
268
+ </Flex>
269
+ </MenuItem>
270
+ ))}
271
+ </SimpleMenu>
272
+ </Flex>
273
+
77
274
  <Box>
78
275
  <Table.Root
79
- colCount={9}
276
+ colCount={visibleColumnCount}
80
277
  rows={transactions}
81
278
  isLoading={isLoadingHistory}
82
279
  isFetching={isLoadingHistory}
83
280
  >
84
281
  <Table.Content footer={null}>
85
282
  <Table.Head>
86
- {headers.map((header) => (
283
+ {visibleHeaders.map((header) => (
87
284
  <Table.HeaderCell
88
285
  fieldSchemaType="custom"
89
286
  isSortable={header.sortable}
@@ -97,7 +294,7 @@ const TransactionTable = () => {
97
294
  <Table.LoadingBody />
98
295
  {transactions.length === 0 && !isLoadingHistory && (
99
296
  <Tr>
100
- <Td colSpan={9}>
297
+ <Td colSpan={visibleColumnCount}>
101
298
  <Box padding={6}>
102
299
  <Typography textAlign="center" textColor="neutral600">
103
300
  No transactions found
@@ -112,71 +309,19 @@ const TransactionTable = () => {
112
309
  return (
113
310
  <React.Fragment key={transaction.id}>
114
311
  <Tr>
115
- <Td>
116
- <Typography variant="pi" textColor="neutral600">
117
- {transaction.txid || "N/A"}
118
- </Typography>
119
- </Td>
120
- <Td>
121
- <Typography variant="pi" fontWeight="medium">
122
- {transaction.reference || "N/A"}
123
- </Typography>
124
- </Td>
125
- <Td>
126
- <Typography variant="pi" textColor="neutral600">
127
- {formatAmount(
128
- transaction.amount,
129
- transaction.currency
130
- )}
131
- </Typography>
132
- </Td>
133
- <Td>
134
- <Typography variant="pi">
135
- {getPaymentMethodName(
136
- (transaction.raw_request?.clearingtype || transaction?.body?.raw_request?.clearingtype),
137
- (transaction.raw_request?.wallettype || transaction?.body?.raw_request?.wallettype),
138
- (transaction.raw_request?.cardtype || transaction?.body?.raw_request?.cardtype)
312
+ {visibleHeaders.map((header) => (
313
+ <Td key={`${transaction.id}-${header.name}`}>
314
+ {renderCellContent(
315
+ header.name,
316
+ transaction,
317
+ isSelected,
139
318
  )}
140
- </Typography>
141
- </Td>
142
- <Td>
143
- <Typography variant="pi" fontWeight="semiBold">
144
- {(transaction.request_type || transaction?.body?.request_type) || "N/A"}
145
- </Typography>
146
- </Td>
147
- <Td>
148
- <StatusBadge
149
- status={(transaction.status || transaction?.body?.status)}
150
- transaction={transaction}
151
- />
152
- </Td>
153
- <Td>
154
- <Typography variant="pi" textColor="neutral600">
155
- {formatDate(transaction.createdAt ?? transaction.created_at)}
156
- </Typography>
157
- </Td>
158
- <Td>
159
- <Typography variant="pi" textColor="neutral600">
160
- {formatDate(transaction.updatedAt ?? transaction.updated_at)}
161
- </Typography>
162
- </Td>
163
- <Td>
164
- <Button
165
- variant="tertiary"
166
- size="S"
167
- minWidth="100px"
168
- startIcon={
169
- isSelected ? <ChevronUp /> : <ChevronDown />
170
- }
171
- onClick={() => handleTransactionSelect(transaction)}
172
- >
173
- {isSelected ? "Hide" : "Details"}
174
- </Button>
175
- </Td>
319
+ </Td>
320
+ ))}
176
321
  </Tr>
177
322
  {isSelected && (
178
323
  <Tr>
179
- <Td colSpan={9}>
324
+ <Td colSpan={visibleColumnCount}>
180
325
  <TransactionDetails transaction={transaction} />
181
326
  </Td>
182
327
  </Tr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-payone-provider",
3
- "version": "4.6.19",
3
+ "version": "4.6.21",
4
4
  "description": "Strapi plugin for Payone payment gateway integration",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -48,4 +48,4 @@
48
48
  "kind": "plugin",
49
49
  "displayName": "Strapi Payone Provider"
50
50
  }
51
- }
51
+ }
@@ -45,7 +45,7 @@ const addPaymentMethodParams = (params, logger) => {
45
45
 
46
46
  const customParams = {};
47
47
  const knownParams = new Set([
48
- 'cardpan', 'cardexpiredate', 'cardcvc2', 'cardtype', 'wallettype',
48
+ 'cardexpiredate', 'cardtype', 'wallettype',
49
49
  'bankcountry', 'iban', 'bic', 'bankaccountholder', 'onlinebanktransfertype',
50
50
  'recurrence', 'financingtype', 'invoicetype',
51
51
  // Common defaults
@@ -65,9 +65,7 @@ const addPaymentMethodParams = (params, logger) => {
65
65
 
66
66
  const methodDefaults = {
67
67
  cc: {
68
- cardpan: "4111111111111111",
69
68
  cardexpiredate: getValidCardExpiryDate(null),
70
- cardcvc2: "123",
71
69
  cardtype: "V"
72
70
  },
73
71
  wlt: {