strapi-plugin-payone-provider 4.6.9 → 5.6.9

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.
Files changed (99) hide show
  1. package/README.md +24 -11
  2. package/admin/src/components/Initializer/index.jsx +3 -3
  3. package/admin/src/components/PluginIcon/index.jsx +3 -3
  4. package/admin/src/index.js +33 -11
  5. package/admin/src/pages/App/components/AppHeader.jsx +17 -32
  6. package/admin/src/pages/App/components/AppTabs.jsx +36 -162
  7. package/admin/src/pages/App/components/ApplePayBtn.jsx +9 -11
  8. package/admin/src/pages/App/components/ApplePayConfig.jsx +221 -161
  9. package/admin/src/pages/App/components/ApplePayConfigPanel.jsx +33 -45
  10. package/admin/src/pages/App/components/DocsPanel.jsx +66 -1726
  11. package/admin/src/pages/App/components/GooglePayConfig.jsx +136 -169
  12. package/admin/src/pages/App/components/GooglePayConfigPanel.jsx +37 -55
  13. package/admin/src/pages/App/components/GooglePaybutton.jsx +101 -43
  14. package/admin/src/pages/App/components/RenderInput.jsx +94 -0
  15. package/admin/src/pages/App/components/StatusBadge.jsx +24 -71
  16. package/admin/src/pages/App/components/configuration/ConfigurationFields.jsx +255 -0
  17. package/admin/src/pages/App/components/configuration/ConfigurationPanel.jsx +54 -0
  18. package/admin/src/pages/App/components/configuration/TestConnection.jsx +130 -0
  19. package/admin/src/pages/App/components/docs/ApplePaySection.jsx +260 -0
  20. package/admin/src/pages/App/components/docs/BaseUrlSection.jsx +53 -0
  21. package/admin/src/pages/App/components/docs/CaptureRefundSection.jsx +113 -0
  22. package/admin/src/pages/App/components/docs/CodeBlock.jsx +59 -0
  23. package/admin/src/pages/App/components/docs/CreditCardSection.jsx +93 -0
  24. package/admin/src/pages/App/components/docs/GooglePaySection.jsx +248 -0
  25. package/admin/src/pages/App/components/docs/PayPalSection.jsx +116 -0
  26. package/admin/src/pages/App/components/docs/PaymentMethodsSection.jsx +55 -0
  27. package/admin/src/pages/App/components/docs/TableOfContents.jsx +47 -0
  28. package/admin/src/pages/App/components/docs/TestCredentialsSection.jsx +304 -0
  29. package/admin/src/pages/App/components/docs/ThreeDSecureSection.jsx +188 -0
  30. package/admin/src/pages/App/components/icons/BankIcon.jsx +1 -1
  31. package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +1 -1
  32. package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +1 -1
  33. package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +1 -1
  34. package/admin/src/pages/App/components/icons/ErrorIcon.jsx +1 -1
  35. package/admin/src/pages/App/components/icons/InfoIcon.jsx +1 -1
  36. package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -0
  37. package/admin/src/pages/App/components/icons/PaymentIcon.jsx +1 -1
  38. package/admin/src/pages/App/components/icons/PendingIcon.jsx +1 -1
  39. package/admin/src/pages/App/components/icons/PersonIcon.jsx +1 -1
  40. package/admin/src/pages/App/components/icons/SuccessIcon.jsx +1 -1
  41. package/admin/src/pages/App/components/icons/WalletIcon.jsx +1 -1
  42. package/admin/src/pages/App/components/payment-actions/ApplePayPanel.jsx +51 -0
  43. package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +341 -0
  44. package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +128 -0
  45. package/admin/src/pages/App/components/{paymentActions → payment-actions}/CardDetailsInput.jsx +77 -72
  46. package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +194 -0
  47. package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +313 -0
  48. package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +133 -0
  49. package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +280 -0
  50. package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +121 -0
  51. package/admin/src/pages/App/components/transaction-history/FiltersPanel.jsx +145 -0
  52. package/admin/src/pages/App/components/transaction-history/HistoryPanel.jsx +50 -0
  53. package/admin/src/pages/App/components/transaction-history/TransactionTable.jsx +163 -0
  54. package/admin/src/pages/App/components/transaction-history/details/TransactionDetails.jsx +156 -0
  55. package/admin/src/pages/App/components/{TransactionHistoryItem.jsx → transaction-history/details/TransactionHistoryItem.jsx} +16 -28
  56. package/admin/src/pages/App/index.jsx +27 -70
  57. package/admin/src/pages/App/styles.css +46 -169
  58. package/admin/src/pages/constants/paymentConstants.js +52 -16
  59. package/admin/src/pages/hooks/use-system-theme.js +27 -0
  60. package/admin/src/pages/hooks/usePaymentActions.js +273 -210
  61. package/admin/src/pages/hooks/useSettings.js +87 -48
  62. package/admin/src/pages/hooks/useTransactionHistory.js +105 -108
  63. package/admin/src/pages/utils/api.js +57 -72
  64. package/admin/src/pages/utils/applePayConstants.js +2 -28
  65. package/admin/src/pages/utils/countryLanguageUtils.js +280 -0
  66. package/admin/src/pages/utils/getInputComponent.jsx +225 -0
  67. package/admin/src/pages/utils/googlePayConstants.js +2 -9
  68. package/admin/src/pages/utils/paymentUtils.js +13 -25
  69. package/admin/src/pages/utils/tooltipHelpers.js +18 -0
  70. package/admin/src/pages/utils/transactionTableUtils.js +60 -0
  71. package/package.json +8 -14
  72. package/server/config/index.js +18 -2
  73. package/server/controllers/payone.js +80 -31
  74. package/server/policies/is-auth.js +9 -3
  75. package/server/policies/isSuperAdmin.js +7 -5
  76. package/server/services/paymentService.js +6 -22
  77. package/server/services/payone.js +3 -3
  78. package/server/services/settingsService.js +13 -3
  79. package/server/services/testConnectionService.js +11 -73
  80. package/server/services/transactionService.js +63 -98
  81. package/server/utils/normalize.js +0 -12
  82. package/server/utils/paymentMethodParams.js +0 -1
  83. package/server/utils/responseParser.js +9 -14
  84. package/strapi-admin.js +3 -1
  85. package/admin/src/pages/App/components/ConfigurationPanel.jsx +0 -517
  86. package/admin/src/pages/App/components/CustomerInfoPopover.jsx +0 -147
  87. package/admin/src/pages/App/components/HistoryPanel.jsx +0 -94
  88. package/admin/src/pages/App/components/PaymentActionsPanel.jsx +0 -280
  89. package/admin/src/pages/App/components/RawDataPopover.jsx +0 -113
  90. package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTableFilters.jsx +0 -113
  91. package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTablePagination.jsx +0 -180
  92. package/admin/src/pages/App/components/TransactionHistoryTable/index.jsx +0 -225
  93. package/admin/src/pages/App/components/paymentActions/ApplePayPanel.jsx +0 -95
  94. package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +0 -197
  95. package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +0 -65
  96. package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +0 -306
  97. package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +0 -192
  98. package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +0 -142
  99. package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +0 -90
@@ -1,94 +0,0 @@
1
- import React from "react";
2
- import {
3
- Box,
4
- Button,
5
- Card,
6
- CardBody,
7
- Flex,
8
- Stack,
9
- Typography,
10
- TextInput,
11
- Select,
12
- Option,
13
- Divider,
14
- } from "@strapi/design-system";
15
- import { Search } from "@strapi/icons";
16
- import TransactionHistoryItem from "./TransactionHistoryItem";
17
- import TransactionHistoryTable from "./TransactionHistoryTable";
18
-
19
- const HistoryPanel = ({
20
- filters,
21
- onFilterChange,
22
- onFilterApply,
23
- sorting,
24
- onSort,
25
- isLoadingHistory,
26
- transactionHistory,
27
- paginatedTransactions,
28
- currentPage,
29
- totalPages,
30
- pageSize,
31
- onRefresh,
32
- onPageChange,
33
- onPageSizeChange,
34
- }) => {
35
- console.log(transactionHistory);
36
-
37
- return (
38
- <Box
39
- className="payment-container"
40
- paddingTop={8}
41
- paddingBottom={8}
42
- paddingLeft={8}
43
- paddingRight={8}
44
- >
45
- <Flex direction="column" alignItems="stretch" gap={8}>
46
- <Box>
47
- <Typography
48
- variant="beta"
49
- as="h2"
50
- className="payment-title"
51
- style={{ fontSize: "20px", marginBottom: "4px" }}
52
- >
53
- Transaction Management
54
- </Typography>
55
- <Typography
56
- variant="pi"
57
- textColor="neutral600"
58
- className="payment-subtitle"
59
- style={{ fontSize: "14px", marginTop: "4px" }}
60
- >
61
- View and filter all payment transactions processed through Payone
62
- </Typography>
63
- </Box>
64
-
65
- {/* Transaction Table */}
66
- <TransactionHistoryTable
67
- transactions={paginatedTransactions}
68
- isLoading={isLoadingHistory}
69
- filters={filters}
70
- onFilterChange={onFilterChange}
71
- onFilterApply={onFilterApply}
72
- sorting={sorting}
73
- onSort={onSort}
74
- currentPage={currentPage}
75
- totalPages={totalPages}
76
- pageSize={pageSize}
77
- totalItems={transactionHistory.length}
78
- onPageChange={onPageChange}
79
- onPageSizeChange={onPageSizeChange}
80
- />
81
-
82
- <Box paddingTop={4}>
83
- <Typography variant="sigma" textColor="neutral600">
84
- Note: This shows all Payone transactions processed through this
85
- plugin. Transactions are automatically logged with detailed
86
- request/response data.
87
- </Typography>
88
- </Box>
89
- </Flex>
90
- </Box>
91
- );
92
- };
93
-
94
- export default HistoryPanel;
@@ -1,280 +0,0 @@
1
- import React from "react";
2
- import { Box, Flex, Typography } from "@strapi/design-system";
3
- import PaymentMethodSelector from "./paymentActions/PaymentMethodSelector";
4
- import PreauthorizationForm from "./paymentActions/PreauthorizationForm";
5
- import AuthorizationForm from "./paymentActions/AuthorizationForm";
6
- import CaptureForm from "./paymentActions/CaptureForm";
7
- import RefundForm from "./paymentActions/RefundForm";
8
- import PaymentResult from "./paymentActions/PaymentResult";
9
- import ApplePayPanel from "./paymentActions/ApplePayPanel";
10
-
11
- const PaymentActionsPanel = ({
12
- paymentAmount,
13
- setPaymentAmount,
14
- preauthReference,
15
- setPreauthReference,
16
- authReference,
17
- setAuthReference,
18
- captureTxid,
19
- setCaptureTxid,
20
- refundTxid,
21
- setRefundTxid,
22
- refundSequenceNumber,
23
- setRefundSequenceNumber,
24
- refundReference,
25
- setRefundReference,
26
- paymentMethod,
27
- setPaymentMethod,
28
- captureMode,
29
- setCaptureMode,
30
- isProcessingPayment,
31
- paymentError,
32
- paymentResult,
33
- onPreauthorization,
34
- onAuthorization,
35
- onCapture,
36
- onRefund,
37
- settings,
38
- setGooglePayToken,
39
- applePayToken,
40
- setApplePayToken,
41
- cardtype,
42
- setCardtype,
43
- cardpan,
44
- setCardpan,
45
- cardexpiredate,
46
- setCardexpiredate,
47
- cardcvc2,
48
- setCardcvc2,
49
- onNavigateToConfig,
50
- }) => {
51
- const mode = (settings?.mode || "test").toLowerCase();
52
- const isLiveMode = mode === "live";
53
-
54
- React.useEffect(() => {
55
- if (isLiveMode && paymentMethod !== "apl") {
56
- setPaymentMethod("apl");
57
- }
58
- }, [isLiveMode, paymentMethod]);
59
-
60
- if (isLiveMode && paymentMethod !== "apl") {
61
- return (
62
- <Box
63
- style={{
64
- display: "flex",
65
- flexDirection: "column",
66
- alignItems: "center",
67
- justifyContent: "center",
68
- gap: "8px",
69
- marginTop: "44px",
70
- }}
71
- >
72
- <Typography variant="pi" textColor="neutral600">
73
- Test Payments are only works in test mode.
74
- </Typography>
75
- <Typography variant="pi" textColor="neutral600">
76
- Please switch to test mode in plugin settings to use test payments.
77
- </Typography>
78
- </Box>
79
- );
80
- }
81
-
82
- if (paymentMethod === "apl") {
83
- return (
84
- <ApplePayPanel
85
- paymentAmount={paymentAmount}
86
- setPaymentAmount={setPaymentAmount}
87
- authReference={authReference}
88
- setAuthReference={setAuthReference}
89
- isProcessingPayment={isProcessingPayment}
90
- onAuthorization={onAuthorization}
91
- paymentMethod={paymentMethod}
92
- setPaymentMethod={setPaymentMethod}
93
- captureMode={captureMode}
94
- setCaptureMode={setCaptureMode}
95
- settings={settings}
96
- setGooglePayToken={setGooglePayToken}
97
- applePayToken={applePayToken}
98
- setApplePayToken={setApplePayToken}
99
- cardtype={cardtype}
100
- setCardtype={setCardtype}
101
- cardpan={cardpan}
102
- setCardpan={setCardpan}
103
- cardexpiredate={cardexpiredate}
104
- setCardexpiredate={setCardexpiredate}
105
- cardcvc2={cardcvc2}
106
- setCardcvc2={setCardcvc2}
107
- onNavigateToConfig={onNavigateToConfig}
108
- isLiveMode={isLiveMode}
109
- />
110
- );
111
- }
112
-
113
- return (
114
- <Box
115
- className="payment-container"
116
- paddingTop={8}
117
- paddingBottom={8}
118
- paddingLeft={8}
119
- paddingRight={8}
120
- >
121
- <Flex direction="column" alignItems="stretch" gap={6}>
122
- <Box
123
- style={{
124
- display: "flex",
125
- flexDirection: "column",
126
- alignItems: "flex-start",
127
- gap: "8px",
128
- }}
129
- >
130
- <Typography
131
- variant="beta"
132
- as="h2"
133
- className="payment-title"
134
- style={{ fontSize: "20px", marginBottom: "4px" }}
135
- >
136
- Payment Actions
137
- </Typography>
138
- <Typography
139
- variant="pi"
140
- textColor="neutral600"
141
- className="payment-subtitle"
142
- style={{ fontSize: "14px" }}
143
- >
144
- Process payments, captures, and refunds with multiple payment
145
- methods
146
- </Typography>
147
- </Box>
148
-
149
- <PaymentMethodSelector
150
- paymentMethod={paymentMethod}
151
- setPaymentMethod={setPaymentMethod}
152
- captureMode={captureMode}
153
- setCaptureMode={setCaptureMode}
154
- onNavigateToConfig={onNavigateToConfig}
155
- settings={settings}
156
- isLiveMode={isLiveMode}
157
- />
158
-
159
- <hr className="payment-divider" />
160
-
161
- <Box
162
- className="payment-form-section"
163
- style={{
164
- opacity: isLiveMode ? 0.5 : 1,
165
- pointerEvents: isLiveMode ? "none" : "auto",
166
- }}
167
- >
168
- <PreauthorizationForm
169
- paymentAmount={paymentAmount}
170
- setPaymentAmount={setPaymentAmount}
171
- preauthReference={preauthReference}
172
- setPreauthReference={setPreauthReference}
173
- isProcessingPayment={isProcessingPayment}
174
- onPreauthorization={onPreauthorization}
175
- paymentMethod={paymentMethod}
176
- settings={settings}
177
- setGooglePayToken={setGooglePayToken}
178
- applePayToken={applePayToken}
179
- setApplePayToken={setApplePayToken}
180
- cardtype={cardtype}
181
- setCardtype={setCardtype}
182
- cardpan={cardpan}
183
- setCardpan={setCardpan}
184
- cardexpiredate={cardexpiredate}
185
- setCardexpiredate={setCardexpiredate}
186
- cardcvc2={cardcvc2}
187
- setCardcvc2={setCardcvc2}
188
- isLiveMode={isLiveMode}
189
- />
190
- </Box>
191
-
192
- <hr className="payment-divider" />
193
-
194
- <Box className="payment-form-section">
195
- <AuthorizationForm
196
- paymentAmount={paymentAmount}
197
- setPaymentAmount={setPaymentAmount}
198
- authReference={authReference}
199
- setAuthReference={setAuthReference}
200
- isProcessingPayment={isProcessingPayment}
201
- onAuthorization={onAuthorization}
202
- paymentMethod={paymentMethod}
203
- settings={settings}
204
- setGooglePayToken={setGooglePayToken}
205
- applePayToken={applePayToken}
206
- setApplePayToken={setApplePayToken}
207
- cardtype={cardtype}
208
- setCardtype={setCardtype}
209
- cardpan={cardpan}
210
- setCardpan={setCardpan}
211
- cardexpiredate={cardexpiredate}
212
- setCardexpiredate={setCardexpiredate}
213
- cardcvc2={cardcvc2}
214
- setCardcvc2={setCardcvc2}
215
- isLiveMode={isLiveMode}
216
- />
217
- </Box>
218
-
219
- <hr className="payment-divider" />
220
-
221
- <Box
222
- className="payment-form-section"
223
- style={{
224
- opacity: isLiveMode ? 0.5 : 1,
225
- pointerEvents: isLiveMode ? "none" : "auto",
226
- }}
227
- >
228
- <CaptureForm
229
- paymentAmount={paymentAmount}
230
- setPaymentAmount={setPaymentAmount}
231
- captureTxid={captureTxid}
232
- setCaptureTxid={setCaptureTxid}
233
- isProcessingPayment={isProcessingPayment}
234
- onCapture={onCapture}
235
- />
236
- </Box>
237
-
238
- <hr className="payment-divider" />
239
-
240
- <Box
241
- className="payment-form-section"
242
- style={{
243
- opacity: isLiveMode ? 0.5 : 1,
244
- pointerEvents: isLiveMode ? "none" : "auto",
245
- }}
246
- >
247
- <RefundForm
248
- paymentAmount={paymentAmount}
249
- setPaymentAmount={setPaymentAmount}
250
- refundTxid={refundTxid}
251
- setRefundTxid={setRefundTxid}
252
- refundSequenceNumber={refundSequenceNumber}
253
- setRefundSequenceNumber={setRefundSequenceNumber}
254
- refundReference={refundReference}
255
- setRefundReference={setRefundReference}
256
- isProcessingPayment={isProcessingPayment}
257
- onRefund={onRefund}
258
- />
259
- </Box>
260
-
261
- <hr className="payment-divider" />
262
-
263
- <PaymentResult
264
- paymentError={paymentError}
265
- paymentResult={paymentResult}
266
- />
267
-
268
- <Box paddingTop={4}>
269
- <Typography variant="sigma" textColor="neutral600">
270
- Note: These payment actions allow you to test the complete payment
271
- flow: Preauthorization → Capture → Refund. Make sure to use valid
272
- Transaction IDs for capture and refund operations.
273
- </Typography>
274
- </Box>
275
- </Flex>
276
- </Box>
277
- );
278
- };
279
-
280
- export default PaymentActionsPanel;
@@ -1,113 +0,0 @@
1
- import React, { useState, useRef, useEffect } from "react";
2
- import { Box, Typography } from "@strapi/design-system";
3
- import JsonView from "@uiw/react-json-view";
4
-
5
- const RawDataPopover = ({ transaction, children }) => {
6
- const [isOpen, setIsOpen] = useState(false);
7
- const [position, setPosition] = useState("top"); // 'top' or 'bottom'
8
- const popoverRef = useRef(null);
9
- const buttonRef = useRef(null);
10
-
11
- const calculatePosition = (buttonElement) => {
12
- if (!buttonElement) return "top";
13
-
14
- const buttonRect = buttonElement.getBoundingClientRect();
15
- // Find the scrollable parent container
16
- let scrollableParent = buttonElement.parentElement;
17
- while (scrollableParent && scrollableParent !== document.body) {
18
- const style = window.getComputedStyle(scrollableParent);
19
- if (style.overflow === 'auto' || style.overflowY === 'auto' || style.overflow === 'scroll' || style.overflowY === 'scroll') {
20
- const parentRect = scrollableParent.getBoundingClientRect();
21
- const spaceAbove = buttonRect.top - parentRect.top;
22
- const spaceBelow = parentRect.bottom - parentRect.bottom;
23
- // RawDataPopover can be up to 500px tall, so we need more space
24
- // If there's less space above than below (or less than 520px), show popover below
25
- return spaceAbove < 520 || spaceAbove < spaceBelow ? "bottom" : "top";
26
- }
27
- scrollableParent = scrollableParent.parentElement;
28
- }
29
- // Fallback: use viewport space
30
- const spaceAbove = buttonRect.top;
31
- return spaceAbove < 520 ? "bottom" : "top";
32
- };
33
-
34
- const handleButtonClick = () => {
35
- if (!isOpen && buttonRef.current) {
36
- // Calculate position before opening
37
- const newPosition = calculatePosition(buttonRef.current);
38
- setPosition(newPosition);
39
- }
40
- setIsOpen(!isOpen);
41
- };
42
-
43
- useEffect(() => {
44
- const handleClickOutside = (event) => {
45
- if (
46
- popoverRef.current &&
47
- buttonRef.current &&
48
- !popoverRef.current.contains(event.target) &&
49
- !buttonRef.current.contains(event.target)
50
- ) {
51
- setIsOpen(false);
52
- }
53
- };
54
-
55
- if (isOpen) {
56
- document.addEventListener("mousedown", handleClickOutside);
57
- return () => {
58
- document.removeEventListener("mousedown", handleClickOutside);
59
- };
60
- }
61
- }, [isOpen]);
62
-
63
- if (!transaction) {
64
- return children;
65
- }
66
-
67
- return (
68
- <Box position="relative" style={{ display: "inline-block" }}>
69
- <Box
70
- ref={buttonRef}
71
- onClick={handleButtonClick}
72
- style={{ display: "inline-block" }}
73
- >
74
- {children}
75
- </Box>
76
- {isOpen && (
77
- <Box
78
- ref={popoverRef}
79
- position="absolute"
80
- zIndex={1000}
81
- left={0}
82
- {...(position === "top"
83
- ? { bottom: "100%", marginBottom: 2 }
84
- : { top: "100%", marginTop: 2 }
85
- )}
86
- padding={3}
87
- background="neutral0"
88
- hasRadius
89
- style={{
90
- minWidth: "400px",
91
- maxWidth: "600px",
92
- maxHeight: "500px",
93
- overflow: "auto",
94
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
95
- border: "1px solid var(--strapi-colors-neutral200)",
96
- }}
97
- >
98
- <Box paddingBottom={2}>
99
- <Typography variant="pi" fontWeight="bold" textColor="neutral800">
100
- Raw Transaction Data
101
- </Typography>
102
- </Box>
103
- <Box>
104
- <JsonView value={transaction} style={{ fontSize: "12px" }} />
105
- </Box>
106
- </Box>
107
- )}
108
- </Box>
109
- );
110
- };
111
-
112
- export default RawDataPopover;
113
-
@@ -1,113 +0,0 @@
1
- import React from "react";
2
- import {
3
- Box,
4
- Flex,
5
- Select,
6
- Option,
7
- Button,
8
- TextInput,
9
- Typography,
10
- } from "@strapi/design-system";
11
- import { Search } from "@strapi/icons";
12
-
13
- const TransactionHistoryTableFilters = ({
14
- filters,
15
- onFilterChange,
16
- onFilterApply,
17
- isLoading,
18
- }) => {
19
- const handleDateFromClick = (e) => {
20
- const input = e.target.closest('div')?.querySelector('input[type="date"]');
21
- if (input) {
22
- input.showPicker?.();
23
- }
24
- };
25
-
26
- const handleDateToClick = (e) => {
27
- const input = e.target.closest('div')?.querySelector('input[type="date"]');
28
- if (input) {
29
- input.showPicker?.();
30
- }
31
- };
32
- return (
33
- <Box marginBottom={2}>
34
- <Flex gap={3} marginBottom={3} alignItems="center">
35
- <TextInput
36
- label="Search"
37
- name="search"
38
- value={filters?.search || ""}
39
- onChange={(e) => onFilterChange("search", e.target.value)}
40
- placeholder="Search by Status, Transaction ID, or Reference"
41
- style={{ flex: 1, minWidth: "250px" }}
42
- />
43
- <Select
44
- label="Status"
45
- name="status"
46
- value={filters?.status || ""}
47
- onChange={(value) => onFilterChange("status", value)}
48
- placeholder="All Statuses"
49
- style={{ width: "180px", minWidth: "180px" }}
50
- >
51
- <Option value="">All Statuses</Option>
52
- <Option value="APPROVED">APPROVED</Option>
53
- <Option value="PENDING">PENDING</Option>
54
- <Option value="ERROR">ERROR</Option>
55
- <Option value="CANCELLED">CANCELLED</Option>
56
- <Option value="REDIRECTED">REDIRECTED</Option>
57
- <Option value="CREATED">CREATED</Option>
58
- </Select>
59
- <Select
60
- label="Request Type"
61
- name="request_type"
62
- value={filters?.request_type || ""}
63
- onChange={(value) => onFilterChange("request_type", value)}
64
- placeholder="Select request type"
65
- style={{ width: "220px", minWidth: "220px" }}
66
- >
67
- <Option value="">All Types</Option>
68
- <Option value="preauthorization">Preauthorization</Option>
69
- <Option value="authorization">Authorization</Option>
70
- <Option value="capture">Capture</Option>
71
- <Option value="refund">Refund</Option>
72
- </Select>
73
- </Flex>
74
- <Flex gap={3} marginBottom={3} alignItems="center">
75
- <Box onClick={handleDateFromClick} style={{ cursor: "pointer" }}>
76
- <TextInput
77
- label="Date From"
78
- name="date_from"
79
- value={filters?.date_from || ""}
80
- onChange={(e) => onFilterChange("date_from", e.target.value)}
81
- placeholder="YYYY-MM-DD"
82
- type="date"
83
- style={{ minWidth: "150px" }}
84
- />
85
- </Box>
86
- <Box onClick={handleDateToClick} style={{ cursor: "pointer" }}>
87
- <TextInput
88
- label="Date To"
89
- name="date_to"
90
- value={filters?.date_to || ""}
91
- onChange={(e) => onFilterChange("date_to", e.target.value)}
92
- placeholder="YYYY-MM-DD"
93
- type="date"
94
- style={{ minWidth: "150px" }}
95
- />
96
- </Box>
97
- <Typography variant="pi" textColor="neutral600" style={{ fontSize: "12px", marginTop: "20px" }}>
98
- By default, the last 30 days are shown
99
- </Typography>
100
- </Flex>
101
- <Button
102
- variant="default"
103
- onClick={onFilterApply}
104
- loading={isLoading}
105
- startIcon={<Search />}
106
- >
107
- Apply Filters
108
- </Button>
109
- </Box>
110
- );
111
- };
112
-
113
- export default TransactionHistoryTableFilters;