strapi-plugin-payone-provider 4.6.9 → 5.6.10

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 (104) hide show
  1. package/README.md +156 -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 -26
  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 +98 -31
  74. package/server/policies/index.js +2 -1
  75. package/server/policies/is-auth.js +9 -3
  76. package/server/policies/is-payone-notification.js +31 -0
  77. package/server/policies/isSuperAdmin.js +7 -5
  78. package/server/routes/index.js +11 -0
  79. package/server/services/paymentService.js +6 -22
  80. package/server/services/payone.js +10 -3
  81. package/server/services/settingsService.js +13 -3
  82. package/server/services/testConnectionService.js +11 -73
  83. package/server/services/transactionService.js +62 -99
  84. package/server/services/transactionStatusService.js +87 -0
  85. package/server/utils/normalize.js +0 -12
  86. package/server/utils/paymentMethodParams.js +0 -1
  87. package/server/utils/requestBuilder.js +34 -5
  88. package/server/utils/responseParser.js +9 -14
  89. package/strapi-admin.js +3 -1
  90. package/admin/src/pages/App/components/ConfigurationPanel.jsx +0 -517
  91. package/admin/src/pages/App/components/CustomerInfoPopover.jsx +0 -147
  92. package/admin/src/pages/App/components/HistoryPanel.jsx +0 -94
  93. package/admin/src/pages/App/components/PaymentActionsPanel.jsx +0 -280
  94. package/admin/src/pages/App/components/RawDataPopover.jsx +0 -113
  95. package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTableFilters.jsx +0 -113
  96. package/admin/src/pages/App/components/TransactionHistoryTable/TransactionHistoryTablePagination.jsx +0 -180
  97. package/admin/src/pages/App/components/TransactionHistoryTable/index.jsx +0 -225
  98. package/admin/src/pages/App/components/paymentActions/ApplePayPanel.jsx +0 -95
  99. package/admin/src/pages/App/components/paymentActions/AuthorizationForm.jsx +0 -197
  100. package/admin/src/pages/App/components/paymentActions/CaptureForm.jsx +0 -65
  101. package/admin/src/pages/App/components/paymentActions/PaymentMethodSelector.jsx +0 -306
  102. package/admin/src/pages/App/components/paymentActions/PaymentResult.jsx +0 -192
  103. package/admin/src/pages/App/components/paymentActions/PreauthorizationForm.jsx +0 -142
  104. package/admin/src/pages/App/components/paymentActions/RefundForm.jsx +0 -90
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useState } from "react";
1
+ import * as React from "react";
2
2
  import { Box, Flex, Typography } from "@strapi/design-system";
3
3
  import { injectGooglePayScript } from "../../utils/injectGooglePayScript";
4
4
 
@@ -7,43 +7,43 @@ const GooglePayButton = ({
7
7
  currency = "EUR",
8
8
  onTokenReceived,
9
9
  onError,
10
- settings
10
+ settings,
11
11
  }) => {
12
- const [isReady, setIsReady] = useState(false);
13
- const [isLoading, setIsLoading] = useState(true);
14
- const buttonContainerRef = useRef(null);
15
- const paymentsClientRef = useRef(null);
12
+ const [isReady, setIsReady] = React.useState(false);
13
+ const [isLoading, setIsLoading] = React.useState(true);
14
+ const buttonContainerRef = React.useRef(null);
15
+ const paymentsClientRef = React.useRef(null);
16
16
 
17
17
  const baseRequest = {
18
18
  apiVersion: 2,
19
- apiVersionMinor: 0
19
+ apiVersionMinor: 0,
20
20
  };
21
21
 
22
22
  const getGooglePayConfig = (settings) => {
23
- const gatewayMerchantId = settings?.mid || settings?.portalid || '';
23
+ const gatewayMerchantId = settings?.mid || settings?.portalid || "";
24
24
 
25
25
  const allowedCardNetworks = ["MASTERCARD", "VISA"];
26
26
  const allowedAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
27
27
 
28
28
  const tokenizationSpecification = {
29
- type: 'PAYMENT_GATEWAY',
29
+ type: "PAYMENT_GATEWAY",
30
30
  parameters: {
31
- 'gateway': 'payonegmbh',
32
- 'gatewayMerchantId': gatewayMerchantId
33
- }
31
+ gateway: "payonegmbh",
32
+ gatewayMerchantId: gatewayMerchantId,
33
+ },
34
34
  };
35
35
 
36
36
  const baseCardPaymentMethod = {
37
37
  type: "CARD",
38
38
  parameters: {
39
39
  allowedCardNetworks,
40
- allowedAuthMethods
41
- }
40
+ allowedAuthMethods,
41
+ },
42
42
  };
43
43
 
44
44
  const cardPaymentMethod = {
45
45
  ...baseCardPaymentMethod,
46
- tokenizationSpecification
46
+ tokenizationSpecification,
47
47
  };
48
48
  return {
49
49
  baseCardPaymentMethod,
@@ -51,14 +51,16 @@ const GooglePayButton = ({
51
51
  };
52
52
  };
53
53
 
54
- useEffect(() => {
54
+ React.useEffect(() => {
55
55
  injectGooglePayScript();
56
56
 
57
57
  const checkGooglePay = () => {
58
58
  try {
59
- return typeof window !== 'undefined' &&
60
- typeof window.google !== 'undefined' &&
61
- window.google.payments?.api?.PaymentsClient;
59
+ return (
60
+ typeof window !== "undefined" &&
61
+ typeof window.google !== "undefined" &&
62
+ window.google.payments?.api?.PaymentsClient
63
+ );
62
64
  } catch (e) {
63
65
  return false;
64
66
  }
@@ -80,7 +82,11 @@ const GooglePayButton = ({
80
82
  const handleScriptError = () => {
81
83
  setIsLoading(false);
82
84
  if (onError) {
83
- onError(new Error("Failed to load Google Pay script. Please check CSP settings."));
85
+ onError(
86
+ new Error(
87
+ "Failed to load Google Pay script. Please check CSP settings."
88
+ )
89
+ );
84
90
  }
85
91
  };
86
92
 
@@ -99,7 +105,11 @@ const GooglePayButton = ({
99
105
  if (!checkGooglePay()) {
100
106
  setIsLoading(false);
101
107
  if (onError) {
102
- onError(new Error("Google Pay API is not available. Please check if the script is loaded and CSP allows pay.google.com"));
108
+ onError(
109
+ new Error(
110
+ "Google Pay API is not available. Please check if the script is loaded and CSP allows pay.google.com"
111
+ )
112
+ );
103
113
  }
104
114
  }
105
115
  }, 15000);
@@ -116,32 +126,48 @@ const GooglePayButton = ({
116
126
  if (!settings || (!settings.mid && !settings.portalid)) {
117
127
  setIsLoading(false);
118
128
  if (onError) {
119
- onError(new Error("Google Pay settings missing. Please configure mid or portalid in settings."));
129
+ onError(
130
+ new Error(
131
+ "Google Pay settings missing. Please configure mid or portalid in settings."
132
+ )
133
+ );
120
134
  }
121
135
  return;
122
136
  }
123
137
 
124
138
  try {
125
- if (typeof window === 'undefined' || typeof window.google === 'undefined' || !window.google.payments?.api?.PaymentsClient) {
139
+ if (
140
+ typeof window === "undefined" ||
141
+ typeof window.google === "undefined" ||
142
+ !window.google.payments?.api?.PaymentsClient
143
+ ) {
126
144
  setIsLoading(false);
127
145
  if (onError) {
128
- onError(new Error("Google Pay API is not loaded. Please check browser console for CSP errors."));
146
+ onError(
147
+ new Error(
148
+ "Google Pay API is not loaded. Please check browser console for CSP errors."
149
+ )
150
+ );
129
151
  }
130
152
  return;
131
153
  }
132
154
 
133
-
134
155
  const environment = settings?.mode === "live" ? "PRODUCTION" : "TEST";
135
- paymentsClientRef.current = new window.google.payments.api.PaymentsClient({
136
- environment: environment
137
- });
156
+ paymentsClientRef.current = new window.google.payments.api.PaymentsClient(
157
+ {
158
+ environment: environment,
159
+ }
160
+ );
138
161
 
139
162
  const config = getGooglePayConfig(settings);
140
163
 
141
164
  const isReadyToPayRequest = Object.assign({}, baseRequest);
142
- isReadyToPayRequest.allowedPaymentMethods = [config.baseCardPaymentMethod];
165
+ isReadyToPayRequest.allowedPaymentMethods = [
166
+ config.baseCardPaymentMethod,
167
+ ];
143
168
 
144
- paymentsClientRef.current.isReadyToPay(isReadyToPayRequest)
169
+ paymentsClientRef.current
170
+ .isReadyToPay(isReadyToPayRequest)
145
171
  .then((response) => {
146
172
  if (response.result) {
147
173
  setIsReady(true);
@@ -193,17 +219,17 @@ const GooglePayButton = ({
193
219
 
194
220
  buttonContainerRef.current.innerHTML = "";
195
221
 
196
- const gatewayMerchantId = settings?.mid || settings?.portalid || '';
222
+ const gatewayMerchantId = settings?.mid || settings?.portalid || "";
197
223
  const paymentDataRequest = Object.assign({}, baseRequest);
198
224
  paymentDataRequest.allowedPaymentMethods = [config.cardPaymentMethod];
199
225
  paymentDataRequest.transactionInfo = {
200
226
  totalPriceStatus: "FINAL",
201
227
  totalPrice: (parseFloat(amount) / 100).toFixed(2),
202
- currencyCode: currency
228
+ currencyCode: currency,
203
229
  };
204
230
  paymentDataRequest.merchantInfo = {
205
231
  merchantId: gatewayMerchantId,
206
- merchantName: settings?.merchantName || 'Demo Shop'
232
+ merchantName: settings?.merchantName || "Demo Shop",
207
233
  };
208
234
 
209
235
  try {
@@ -211,7 +237,7 @@ const GooglePayButton = ({
211
237
  onClick: () => handleGooglePayClick(paymentDataRequest),
212
238
  buttonColor: "black",
213
239
  buttonType: "pay",
214
- buttonSizeMode: "fill"
240
+ buttonSizeMode: "fill",
215
241
  });
216
242
 
217
243
  if (buttonContainerRef.current) {
@@ -235,7 +261,8 @@ const GooglePayButton = ({
235
261
  throw new Error("Google Pay client not initialized");
236
262
  }
237
263
 
238
- const paymentData = await paymentsClientRef.current.loadPaymentData(paymentDataRequest);
264
+ const paymentData =
265
+ await paymentsClientRef.current.loadPaymentData(paymentDataRequest);
239
266
  const rawToken = paymentData.paymentMethodData?.tokenizationData?.token;
240
267
 
241
268
  if (!rawToken) {
@@ -246,12 +273,16 @@ const GooglePayButton = ({
246
273
 
247
274
  try {
248
275
  const tokenObj = JSON.parse(token);
249
- if (!tokenObj.signature || !tokenObj.protocolVersion || !tokenObj.signedMessage) {
276
+ if (
277
+ !tokenObj.signature ||
278
+ !tokenObj.protocolVersion ||
279
+ !tokenObj.signedMessage
280
+ ) {
250
281
  throw new Error("Google Pay token is missing required fields");
251
282
  }
252
283
  token = btoa(unescape(encodeURIComponent(rawToken)));
253
284
  } catch (e) {
254
- if (typeof token === 'string') {
285
+ if (typeof token === "string") {
255
286
  token = btoa(unescape(encodeURIComponent(token)));
256
287
  } else {
257
288
  throw new Error(`Invalid Google Pay token format: ${e.message}`);
@@ -272,26 +303,53 @@ const GooglePayButton = ({
272
303
  <Box width="100%">
273
304
  <Flex direction="column" gap={3} alignItems="stretch">
274
305
  {isLoading && (
275
- <Typography variant="pi" textColor="neutral600" style={{ textAlign: "left" }}>
306
+ <Typography
307
+ variant="pi"
308
+ textColor="neutral600"
309
+ style={{ textAlign: "left" }}
310
+ >
276
311
  Loading Google Pay...
277
312
  </Typography>
278
313
  )}
279
314
  {!isLoading && !isReady && (
280
- <Typography variant="pi" textColor="neutral600" style={{ textAlign: "left" }}>
315
+ <Typography
316
+ variant="pi"
317
+ textColor="neutral600"
318
+ style={{ textAlign: "left" }}
319
+ >
281
320
  Google Pay is not available
282
321
  </Typography>
283
322
  )}
284
323
  {!isLoading && isReady && (
285
324
  <>
286
- <Typography variant="sigma" textColor="neutral700" fontWeight="semiBold" style={{ textAlign: "left" }}>
325
+ <Typography
326
+ variant="sigma"
327
+ textColor="neutral700"
328
+ fontWeight="semiBold"
329
+ style={{ textAlign: "left" }}
330
+ >
287
331
  Google Pay Payment
288
332
  </Typography>
289
- <Typography variant="pi" textColor="neutral600" style={{ textAlign: "left" }}>
290
- Click the button below to pay with Google Pay. The token will be automatically sent to Payone.
333
+ <Typography
334
+ variant="pi"
335
+ textColor="neutral600"
336
+ style={{ textAlign: "left" }}
337
+ >
338
+ Click the button below to pay with Google Pay. The token will be
339
+ automatically sent to Payone.
291
340
  </Typography>
292
341
  </>
293
342
  )}
294
- <Box ref={buttonContainerRef} style={{ minHeight: "40px", width: "100%", maxWidth: "200px", display: "flex", justifyContent: "flex-start", }} />
343
+ <Box
344
+ ref={buttonContainerRef}
345
+ style={{
346
+ minHeight: "40px",
347
+ width: "100%",
348
+ maxWidth: "200px",
349
+ display: "flex",
350
+ justifyContent: "flex-start",
351
+ }}
352
+ />
295
353
  </Flex>
296
354
  </Box>
297
355
  );
@@ -0,0 +1,94 @@
1
+ import {
2
+ Field,
3
+ Flex,
4
+ DesignSystemProvider,
5
+ Tooltip,
6
+ Typography,
7
+ darkTheme,
8
+ lightTheme,
9
+ } from "@strapi/design-system";
10
+ import { Information } from "@strapi/icons";
11
+ import { InputComponent } from "../../utils/getInputComponent";
12
+ import { shouldShowTooltip } from "../../utils/tooltipHelpers";
13
+ import { useSystemTheme } from "../../hooks/use-system-theme";
14
+
15
+ const RenderInput = ({
16
+ hint,
17
+ label,
18
+ name,
19
+ value,
20
+ onChange,
21
+ inputType = "textInput",
22
+ options = [],
23
+ tooltipContent = "",
24
+ additionalMessage = "",
25
+ required = false,
26
+ placeholder,
27
+ onLabel,
28
+ offLabel,
29
+ type = "text",
30
+ className = "payment-input",
31
+ labelStyle = {},
32
+ labelDirection = "column",
33
+ ...props
34
+ }) => {
35
+ const systemTheme = useSystemTheme();
36
+ const theme = systemTheme === "dark" ? darkTheme : lightTheme;
37
+ const getLabelStyle = () => {
38
+ if (labelDirection === "row") {
39
+ return {
40
+ display: "flex",
41
+ flexDirection: "row",
42
+ justifyContent: "space-between",
43
+ };
44
+ }
45
+ return { display: "flex", flexDirection: "column" };
46
+ };
47
+
48
+ return (
49
+ <Flex direction="column" gap={2} alignItems={"stretch"} width={"100%"}>
50
+ <Field.Root hint={hint} width={"100%"} style={getLabelStyle()}>
51
+ <Flex alignItems="center" gap={1} style={{ marginBottom: "5px" }}>
52
+ <Field.Label style={labelStyle}>{label}</Field.Label>
53
+ {shouldShowTooltip(inputType, tooltipContent) && (
54
+ <DesignSystemProvider theme={theme}>
55
+ <Tooltip label={tooltipContent}>
56
+ <Information
57
+ style={{
58
+ cursor: "pointer",
59
+ color: systemTheme === "dark" ? "#fff" : "#000",
60
+ }}
61
+ />
62
+ </Tooltip>
63
+ </DesignSystemProvider>
64
+ )}
65
+ </Flex>
66
+ <InputComponent
67
+ inputType={inputType}
68
+ name={name}
69
+ value={value}
70
+ onChange={onChange}
71
+ tooltipContent={tooltipContent}
72
+ options={options}
73
+ required={required}
74
+ className={className}
75
+ placeholder={placeholder}
76
+ onLabel={onLabel}
77
+ offLabel={offLabel}
78
+ systemTheme={systemTheme}
79
+ theme={theme}
80
+ type={type}
81
+ {...props}
82
+ />
83
+ <Field.Hint />
84
+ </Field.Root>
85
+ {additionalMessage && (
86
+ <Typography variant="pi" textColor={"ActiveText"}>
87
+ {additionalMessage}
88
+ </Typography>
89
+ )}
90
+ </Flex>
91
+ );
92
+ };
93
+
94
+ export default RenderInput;
@@ -1,81 +1,34 @@
1
- import React, { useState } from "react";
2
- import { Badge, Box, Typography, Flex } from "@strapi/design-system";
3
- import { ExclamationMarkCircle } from "@strapi/icons";
1
+ import * as React from "@strapi/strapi/admin";
2
+ import {
3
+ Badge,
4
+ DesignSystemProvider,
5
+ darkTheme,
6
+ lightTheme,
7
+ } from "@strapi/design-system";
8
+ import { useSystemTheme } from "../../hooks/use-system-theme";
4
9
 
5
- const StatusBadge = ({ status, transaction }) => {
6
- const [isHovered, setIsHovered] = useState(false);
7
-
10
+ const StatusBadge = ({ status, size = "S" }) => {
8
11
  const statusColors = {
9
12
  APPROVED: "success200",
10
13
  PENDING: "warning200",
11
14
  ERROR: "danger200",
12
- CANCELLED: "warning100",
13
- REDIRECTED: "success100",
14
- CREATED: "success100"
15
+ FAILED: "danger200",
16
+ INVALID: "danger200",
17
+ REDIRECT: "success100",
15
18
  };
16
-
17
- const getDisplayText = () => {
18
- if (status === "ERROR" && transaction?.raw_response?.Error?.ErrorCode) {
19
- return `${status} - ${transaction.raw_response.Error.ErrorCode}`;
20
- }
21
- return status;
22
- };
23
-
24
- const displayText = getDisplayText();
25
- const errorMessage = status === "ERROR" && transaction?.raw_response?.Error?.ErrorMessage
26
- ? transaction.raw_response.Error.ErrorMessage
27
- : null;
28
-
29
- const errorCode = status === "ERROR" && transaction?.raw_response?.Error?.ErrorCode
30
- ? transaction.raw_response.Error.ErrorCode
31
- : null;
32
-
33
- const showExclamationIcon = status === "ERROR" && !errorCode && !errorMessage;
34
-
19
+ const systemTheme = useSystemTheme();
20
+ const theme = systemTheme === "dark" ? darkTheme : lightTheme;
35
21
  return (
36
- <Box
37
- position="relative"
38
- onMouseEnter={() => setIsHovered(true)}
39
- onMouseLeave={() => setIsHovered(false)}
40
- style={{ display: "inline-block", cursor: status === "ERROR" ? "pointer" : "default" }}
41
- >
42
- <Flex gap={2} alignItems="center">
43
- <Badge backgroundColor={statusColors[status] || "warning100"}>
44
- {displayText}
45
- </Badge>
46
- {showExclamationIcon && (
47
- <ExclamationMarkCircle color="danger500"
48
- style={{
49
- width: "16px",
50
- height: "16px"
51
- }}
52
- />
53
- )}
54
- </Flex>
55
- {isHovered && errorMessage && (
56
- <Box
57
- position="absolute"
58
- zIndex={1000}
59
- bottom="100%"
60
- left="50%"
61
- transform="translateX(-50%)"
62
- marginBottom={2}
63
- padding={3}
64
- background="neutral900"
65
- hasRadius
66
- style={{
67
- whiteSpace: "pre-line",
68
- minWidth: "200px",
69
- maxWidth: "300px",
70
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
71
- }}
72
- >
73
- <Typography variant="pi" textColor="neutral0" style={{ fontSize: "12px" }}>
74
- Error: {errorMessage}
75
- </Typography>
76
- </Box>
77
- )}
78
- </Box>
22
+ <DesignSystemProvider theme={theme}>
23
+ <Badge
24
+ borderColor={statusColors[status]}
25
+ background={"transparent"}
26
+ textColor={statusColors[status]}
27
+ size={size}
28
+ >
29
+ {status || "UNKNOWN"}
30
+ </Badge>
31
+ </DesignSystemProvider>
79
32
  );
80
33
  };
81
34