strapi-plugin-payone-provider 5.7.24 → 5.7.26
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 +1191 -1191
- package/admin/src/components/Initializer/index.jsx +16 -16
- package/admin/src/components/PluginIcon/index.jsx +17 -17
- package/admin/src/index.js +57 -57
- package/admin/src/pages/App/components/AppHeader.jsx +45 -45
- package/admin/src/pages/App/components/AppTabs.jsx +105 -105
- package/admin/src/pages/App/components/ApplePayBtn.jsx +355 -355
- package/admin/src/pages/App/components/ApplePayConfig.jsx +357 -357
- package/admin/src/pages/App/components/DocsPanel.jsx +53 -53
- package/admin/src/pages/App/components/RenderInput.jsx +78 -78
- package/admin/src/pages/App/components/StatusBadge.jsx +87 -87
- package/admin/src/pages/App/components/icons/BankIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/ChevronDownIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ChevronUpIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/CreditCardIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/ErrorIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/InfoIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/MarkCircle.jsx +19 -19
- package/admin/src/pages/App/components/icons/PaymentIcon.jsx +10 -10
- package/admin/src/pages/App/components/icons/PendingIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/PersonIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/SuccessIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/WalletIcon.jsx +9 -9
- package/admin/src/pages/App/components/icons/index.jsx +12 -12
- package/admin/src/pages/App/components/payment-actions/AuthorizationForm.jsx +334 -334
- package/admin/src/pages/App/components/payment-actions/CaptureForm.jsx +120 -120
- package/admin/src/pages/App/components/payment-actions/PaymentActionsPanel.jsx +183 -183
- package/admin/src/pages/App/components/payment-actions/PaymentMethodSelector.jsx +315 -315
- package/admin/src/pages/App/components/payment-actions/PaymentResult.jsx +129 -129
- package/admin/src/pages/App/components/payment-actions/PreauthorizationForm.jsx +273 -273
- package/admin/src/pages/App/components/payment-actions/RefundForm.jsx +114 -114
- package/admin/src/pages/App/components/transaction-history/ImportExportBar.jsx +153 -153
- package/admin/src/pages/App/components/transaction-history/details/TransactionHistoryItem.jsx +526 -526
- package/admin/src/pages/App/index.jsx +96 -96
- package/admin/src/pages/App/styles.css +176 -176
- package/admin/src/pages/constants/paymentConstants.js +71 -71
- package/admin/src/pages/hooks/use-system-theme.js +27 -27
- package/admin/src/pages/hooks/usePaymentActions.js +498 -498
- package/admin/src/pages/hooks/usePluginTranslations.js +12 -12
- package/admin/src/pages/hooks/useSettings.js +183 -183
- package/admin/src/pages/hooks/useTransactionHistory.js +148 -148
- package/admin/src/pages/utils/api.js +97 -97
- package/admin/src/pages/utils/applePayConstants.js +196 -196
- package/admin/src/pages/utils/formatTransactionData.js +15 -15
- package/admin/src/pages/utils/getInputComponent.jsx +200 -200
- package/admin/src/pages/utils/paymentUtils.js +661 -661
- package/admin/src/pages/utils/tooltipHelpers.js +18 -18
- package/admin/src/pages/utils/transactionTableUtils.js +71 -71
- package/admin/src/pluginId.js +9 -9
- package/admin/src/translations/de.json +235 -235
- package/admin/src/translations/en.json +235 -235
- package/admin/src/translations/fr.json +235 -235
- package/admin/src/translations/ru.json +235 -235
- package/admin/src/utils/prefixPluginTranslations.js +13 -13
- package/package.json +45 -45
- package/server/bootstrap.js +107 -107
- package/server/config/index.js +83 -83
- package/server/content-types/index.js +4 -4
- package/server/content-types/transactions/index.js +4 -4
- package/server/content-types/transactions/schema.json +86 -86
- package/server/controllers/index.js +7 -7
- package/server/controllers/payone.js +506 -451
- package/server/destroy.js +5 -5
- package/server/index.js +23 -23
- package/server/policies/index.js +7 -7
- package/server/policies/is-auth.js +29 -29
- package/server/policies/isSuperAdmin.js +20 -20
- package/server/register.js +5 -5
- package/server/routes/index.js +218 -218
- package/server/services/applePayService.js +295 -295
- package/server/services/index.js +9 -9
- package/server/services/paymentService.js +223 -223
- package/server/services/payone.js +78 -78
- package/server/services/settingsService.js +59 -59
- package/server/services/testConnectionService.js +115 -115
- package/server/services/transactionService.js +262 -262
- package/server/utils/csvTransactions.js +82 -82
- package/server/utils/normalize.js +39 -39
- package/server/utils/paymentMethodParams.js +288 -288
- package/server/utils/requestBuilder.js +100 -100
- package/server/utils/responseParser.js +141 -141
- package/strapi-admin.js +4 -4
- package/strapi-server.js +3 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import pluginId from "../../pluginId";
|
|
3
|
-
|
|
4
|
-
const Initializer = ({ setPlugin }) => {
|
|
5
|
-
const ref = React.useRef(setPlugin);
|
|
6
|
-
|
|
7
|
-
React.useEffect(() => {
|
|
8
|
-
if (ref.current) {
|
|
9
|
-
ref.current(pluginId);
|
|
10
|
-
}
|
|
11
|
-
}, []);
|
|
12
|
-
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default Initializer;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import pluginId from "../../pluginId";
|
|
3
|
+
|
|
4
|
+
const Initializer = ({ setPlugin }) => {
|
|
5
|
+
const ref = React.useRef(setPlugin);
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
if (ref.current) {
|
|
9
|
+
ref.current(pluginId);
|
|
10
|
+
}
|
|
11
|
+
}, []);
|
|
12
|
+
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default Initializer;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
const PluginIcon = () => (
|
|
3
|
-
<svg
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
xmlSpace="preserve"
|
|
6
|
-
width={18}
|
|
7
|
-
height={18}
|
|
8
|
-
fill="currentColor"
|
|
9
|
-
version="1.1"
|
|
10
|
-
viewBox="0 0 438.254 438.254"
|
|
11
|
-
>
|
|
12
|
-
<path d="M402.612 177.546H368.25V63.187c0-19.652-15.988-35.64-35.64-35.64H35.641C15.988 27.547 0 43.535 0 63.187v161.88c0 19.652 15.988 35.64 35.641 35.64h34.357v114.358c0 19.653 15.989 35.642 35.642 35.642h296.973c19.652 0 35.642-15.989 35.642-35.642V213.188c-.001-19.653-15.99-35.642-35.643-35.642m-64.362-45.839H30v-20h308.25zM35.641 57.547h296.97c3.109 0 5.64 2.53 5.64 5.64v28.52H30v-28.52c0-3.11 2.53-5.64 5.641-5.64m0 173.16a5.647 5.647 0 0 1-5.641-5.64v-73.36h308.25v25.839H105.64c-19.652 0-35.642 15.989-35.642 35.642v17.519zm372.613 144.358a5.65 5.65 0 0 1-5.642 5.642H105.64a5.65 5.65 0 0 1-5.642-5.642V213.188a5.65 5.65 0 0 1 5.642-5.642h296.973a5.65 5.65 0 0 1 5.642 5.642z"></path>
|
|
13
|
-
<path d="M358.585 287.966c-6.941 0-13.48 1.74-19.216 4.797-5.885-3.15-12.429-4.797-19.265-4.797-22.607 0-41 18.393-41 41s18.393 41 41 41c6.835 0 13.379-1.647 19.265-4.796a40.74 40.74 0 0 0 19.216 4.796c22.607 0 41-18.393 41-41s-18.393-41-41-41m-59.481 41c0-11.579 9.421-21 21-21 1.065 0 2.113.09 3.145.243-3.593 6.093-5.664 13.186-5.664 20.757s2.071 14.664 5.664 20.757c-1.032.153-2.08.243-3.145.243-11.58 0-21-9.42-21-21m59.481 21c-11.579 0-21-9.421-21-21s9.421-21 21-21 21 9.421 21 21-9.421 21-21 21M177.126 241.707h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10s-4.478-10-10-10M237.793 241.707h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10s-4.478-10-10-10M308.459 251.707c0-5.523-4.478-10-10-10h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10M331.126 261.707h28c5.522 0 10-4.477 10-10s-4.478-10-10-10h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10"></path>
|
|
14
|
-
</svg>
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
export default PluginIcon;
|
|
1
|
+
|
|
2
|
+
const PluginIcon = () => (
|
|
3
|
+
<svg
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
xmlSpace="preserve"
|
|
6
|
+
width={18}
|
|
7
|
+
height={18}
|
|
8
|
+
fill="currentColor"
|
|
9
|
+
version="1.1"
|
|
10
|
+
viewBox="0 0 438.254 438.254"
|
|
11
|
+
>
|
|
12
|
+
<path d="M402.612 177.546H368.25V63.187c0-19.652-15.988-35.64-35.64-35.64H35.641C15.988 27.547 0 43.535 0 63.187v161.88c0 19.652 15.988 35.64 35.641 35.64h34.357v114.358c0 19.653 15.989 35.642 35.642 35.642h296.973c19.652 0 35.642-15.989 35.642-35.642V213.188c-.001-19.653-15.99-35.642-35.643-35.642m-64.362-45.839H30v-20h308.25zM35.641 57.547h296.97c3.109 0 5.64 2.53 5.64 5.64v28.52H30v-28.52c0-3.11 2.53-5.64 5.641-5.64m0 173.16a5.647 5.647 0 0 1-5.641-5.64v-73.36h308.25v25.839H105.64c-19.652 0-35.642 15.989-35.642 35.642v17.519zm372.613 144.358a5.65 5.65 0 0 1-5.642 5.642H105.64a5.65 5.65 0 0 1-5.642-5.642V213.188a5.65 5.65 0 0 1 5.642-5.642h296.973a5.65 5.65 0 0 1 5.642 5.642z"></path>
|
|
13
|
+
<path d="M358.585 287.966c-6.941 0-13.48 1.74-19.216 4.797-5.885-3.15-12.429-4.797-19.265-4.797-22.607 0-41 18.393-41 41s18.393 41 41 41c6.835 0 13.379-1.647 19.265-4.796a40.74 40.74 0 0 0 19.216 4.796c22.607 0 41-18.393 41-41s-18.393-41-41-41m-59.481 41c0-11.579 9.421-21 21-21 1.065 0 2.113.09 3.145.243-3.593 6.093-5.664 13.186-5.664 20.757s2.071 14.664 5.664 20.757c-1.032.153-2.08.243-3.145.243-11.58 0-21-9.42-21-21m59.481 21c-11.579 0-21-9.421-21-21s9.421-21 21-21 21 9.421 21 21-9.421 21-21 21M177.126 241.707h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10s-4.478-10-10-10M237.793 241.707h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10s-4.478-10-10-10M308.459 251.707c0-5.523-4.478-10-10-10h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10h28c5.522 0 10-4.477 10-10M331.126 261.707h28c5.522 0 10-4.477 10-10s-4.478-10-10-10h-28c-5.522 0-10 4.477-10 10s4.478 10 10 10"></path>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default PluginIcon;
|
package/admin/src/index.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
import pluginPkg from '../../package.json';
|
|
3
|
-
import pluginId from './pluginId';
|
|
4
|
-
import Initializer from './components/Initializer';
|
|
5
|
-
import PluginIcon from './components/PluginIcon';
|
|
6
|
-
import { injectGooglePayScript } from './pages/utils/injectGooglePayScript';
|
|
7
|
-
import { injectApplePayScript } from './pages/utils/injectApplePayScript';
|
|
8
|
-
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
9
|
-
|
|
10
|
-
const name = pluginPkg.strapi.name;
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
register(app) {
|
|
14
|
-
app.addMenuLink({
|
|
15
|
-
to: `/plugins/${pluginId}`,
|
|
16
|
-
icon: PluginIcon,
|
|
17
|
-
intlLabel: {
|
|
18
|
-
id: `${pluginId}.plugin.name`,
|
|
19
|
-
defaultMessage: 'Payone Provider',
|
|
20
|
-
},
|
|
21
|
-
Component: async () => {
|
|
22
|
-
const App = await import('./pages/App');
|
|
23
|
-
return App;
|
|
24
|
-
},
|
|
25
|
-
permissions: [],
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.registerPlugin({
|
|
29
|
-
id: pluginId,
|
|
30
|
-
initializer: Initializer,
|
|
31
|
-
isReady: false,
|
|
32
|
-
name,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
bootstrap() {
|
|
37
|
-
injectGooglePayScript();
|
|
38
|
-
injectApplePayScript();
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
async registerTrads({ locales }) {
|
|
42
|
-
const importedTrads = await Promise.all(
|
|
43
|
-
locales.map((locale) =>
|
|
44
|
-
import(`./translations/${locale}.json`)
|
|
45
|
-
.then(({ default: data }) => ({
|
|
46
|
-
data: prefixPluginTranslations(data, pluginId),
|
|
47
|
-
locale,
|
|
48
|
-
}))
|
|
49
|
-
.catch(() => ({
|
|
50
|
-
data: {},
|
|
51
|
-
locale,
|
|
52
|
-
}))
|
|
53
|
-
)
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return Promise.resolve(importedTrads);
|
|
57
|
-
},
|
|
1
|
+
|
|
2
|
+
import pluginPkg from '../../package.json';
|
|
3
|
+
import pluginId from './pluginId';
|
|
4
|
+
import Initializer from './components/Initializer';
|
|
5
|
+
import PluginIcon from './components/PluginIcon';
|
|
6
|
+
import { injectGooglePayScript } from './pages/utils/injectGooglePayScript';
|
|
7
|
+
import { injectApplePayScript } from './pages/utils/injectApplePayScript';
|
|
8
|
+
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
9
|
+
|
|
10
|
+
const name = pluginPkg.strapi.name;
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
register(app) {
|
|
14
|
+
app.addMenuLink({
|
|
15
|
+
to: `/plugins/${pluginId}`,
|
|
16
|
+
icon: PluginIcon,
|
|
17
|
+
intlLabel: {
|
|
18
|
+
id: `${pluginId}.plugin.name`,
|
|
19
|
+
defaultMessage: 'Payone Provider',
|
|
20
|
+
},
|
|
21
|
+
Component: async () => {
|
|
22
|
+
const App = await import('./pages/App');
|
|
23
|
+
return App;
|
|
24
|
+
},
|
|
25
|
+
permissions: [],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
app.registerPlugin({
|
|
29
|
+
id: pluginId,
|
|
30
|
+
initializer: Initializer,
|
|
31
|
+
isReady: false,
|
|
32
|
+
name,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
bootstrap() {
|
|
37
|
+
injectGooglePayScript();
|
|
38
|
+
injectApplePayScript();
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async registerTrads({ locales }) {
|
|
42
|
+
const importedTrads = await Promise.all(
|
|
43
|
+
locales.map((locale) =>
|
|
44
|
+
import(`./translations/${locale}.json`)
|
|
45
|
+
.then(({ default: data }) => ({
|
|
46
|
+
data: prefixPluginTranslations(data, pluginId),
|
|
47
|
+
locale,
|
|
48
|
+
}))
|
|
49
|
+
.catch(() => ({
|
|
50
|
+
data: {},
|
|
51
|
+
locale,
|
|
52
|
+
}))
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return Promise.resolve(importedTrads);
|
|
57
|
+
},
|
|
58
58
|
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import * as React from '@strapi/strapi/admin';
|
|
2
|
-
import { Button } from "@strapi/design-system";
|
|
3
|
-
import { Layouts } from "@strapi/strapi/admin";
|
|
4
|
-
import { Check, ArrowLeft } from "@strapi/icons";
|
|
5
|
-
import { usePluginTranslations } from "../../hooks/usePluginTranslations";
|
|
6
|
-
|
|
7
|
-
const AppHeader = ({ activeTab, isSaving, onSave, title, onBack }) => {
|
|
8
|
-
const { t } = usePluginTranslations();
|
|
9
|
-
const pluginName = t("plugin.name", "Payone Provider");
|
|
10
|
-
const isConfigPage = title && title !== pluginName;
|
|
11
|
-
|
|
12
|
-
const subtitle =
|
|
13
|
-
title === "Apple Pay Configuration"
|
|
14
|
-
? t("header.subtitleApplePay", "Configure Apple Pay settings for your payment gateway")
|
|
15
|
-
: title === "Google Pay Configuration"
|
|
16
|
-
? t("header.subtitleGooglePay", "Configure Google Pay settings for your payment gateway")
|
|
17
|
-
: t("header.subtitle", "Configure your Payone integration and manage payment transactions");
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Layouts.Header
|
|
21
|
-
title={title || pluginName}
|
|
22
|
-
subtitle={subtitle}
|
|
23
|
-
primaryAction={
|
|
24
|
-
isConfigPage ? (
|
|
25
|
-
<Button onClick={onBack} startIcon={<ArrowLeft />} size="L" variant="secondary">
|
|
26
|
-
{t("header.backToMain", "Back to Main")}
|
|
27
|
-
</Button>
|
|
28
|
-
) : activeTab === 2 ? (
|
|
29
|
-
<Button
|
|
30
|
-
loading={isSaving}
|
|
31
|
-
onClick={onSave}
|
|
32
|
-
startIcon={<Check />}
|
|
33
|
-
size="M"
|
|
34
|
-
variant="default"
|
|
35
|
-
className="payment-button payment-button-success"
|
|
36
|
-
>
|
|
37
|
-
{t("header.saveConfiguration", "Save Configuration")}
|
|
38
|
-
</Button>
|
|
39
|
-
) : null
|
|
40
|
-
}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default AppHeader;
|
|
1
|
+
import * as React from '@strapi/strapi/admin';
|
|
2
|
+
import { Button } from "@strapi/design-system";
|
|
3
|
+
import { Layouts } from "@strapi/strapi/admin";
|
|
4
|
+
import { Check, ArrowLeft } from "@strapi/icons";
|
|
5
|
+
import { usePluginTranslations } from "../../hooks/usePluginTranslations";
|
|
6
|
+
|
|
7
|
+
const AppHeader = ({ activeTab, isSaving, onSave, title, onBack }) => {
|
|
8
|
+
const { t } = usePluginTranslations();
|
|
9
|
+
const pluginName = t("plugin.name", "Payone Provider");
|
|
10
|
+
const isConfigPage = title && title !== pluginName;
|
|
11
|
+
|
|
12
|
+
const subtitle =
|
|
13
|
+
title === "Apple Pay Configuration"
|
|
14
|
+
? t("header.subtitleApplePay", "Configure Apple Pay settings for your payment gateway")
|
|
15
|
+
: title === "Google Pay Configuration"
|
|
16
|
+
? t("header.subtitleGooglePay", "Configure Google Pay settings for your payment gateway")
|
|
17
|
+
: t("header.subtitle", "Configure your Payone integration and manage payment transactions");
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Layouts.Header
|
|
21
|
+
title={title || pluginName}
|
|
22
|
+
subtitle={subtitle}
|
|
23
|
+
primaryAction={
|
|
24
|
+
isConfigPage ? (
|
|
25
|
+
<Button onClick={onBack} startIcon={<ArrowLeft />} size="L" variant="secondary">
|
|
26
|
+
{t("header.backToMain", "Back to Main")}
|
|
27
|
+
</Button>
|
|
28
|
+
) : activeTab === 2 ? (
|
|
29
|
+
<Button
|
|
30
|
+
loading={isSaving}
|
|
31
|
+
onClick={onSave}
|
|
32
|
+
startIcon={<Check />}
|
|
33
|
+
size="M"
|
|
34
|
+
variant="default"
|
|
35
|
+
className="payment-button payment-button-success"
|
|
36
|
+
>
|
|
37
|
+
{t("header.saveConfiguration", "Save Configuration")}
|
|
38
|
+
</Button>
|
|
39
|
+
) : null
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default AppHeader;
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Typography, Tabs } from "@strapi/design-system";
|
|
3
|
-
import ConfigurationPanel from "./configuration/ConfigurationPanel";
|
|
4
|
-
import HistoryPanel from "./transaction-history/HistoryPanel";
|
|
5
|
-
import PaymentActionsPanel from "./payment-actions/PaymentActionsPanel";
|
|
6
|
-
import DocsPanel from "./DocsPanel";
|
|
7
|
-
import { usePluginTranslations } from "../../hooks/usePluginTranslations";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Error boundary to prevent a single tab's error from crashing the entire plugin.
|
|
11
|
-
* Automatically resets when the user switches tabs.
|
|
12
|
-
*/
|
|
13
|
-
class TabErrorBoundary extends React.Component {
|
|
14
|
-
constructor(props) {
|
|
15
|
-
super(props);
|
|
16
|
-
this.state = { hasError: false, error: null };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static getDerivedStateFromError(error) {
|
|
20
|
-
return { hasError: true, error };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
componentDidCatch(error, errorInfo) {
|
|
24
|
-
console.error("Payone Tab Error:", error, errorInfo);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
componentDidUpdate(prevProps) {
|
|
28
|
-
// Auto-reset when the user switches to a different tab
|
|
29
|
-
if (prevProps.activeTab !== this.props.activeTab && this.state.hasError) {
|
|
30
|
-
this.setState({ hasError: false, error: null });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
render() {
|
|
35
|
-
const { t } = this.props;
|
|
36
|
-
if (this.state.hasError) {
|
|
37
|
-
return (
|
|
38
|
-
<Box padding={6} style={{ textAlign: "center" }}>
|
|
39
|
-
<Typography variant="beta" textColor="danger600">
|
|
40
|
-
{t ? t("error.tabError", "Something went wrong loading this tab.") : "Something went wrong loading this tab."}
|
|
41
|
-
</Typography>
|
|
42
|
-
<Typography variant="pi" textColor="neutral600" style={{ marginTop: "8px", display: "block" }}>
|
|
43
|
-
{t ? t("error.tabErrorHint", "Try switching to another tab or reload the page.") : "Try switching to another tab or reload the page."}
|
|
44
|
-
</Typography>
|
|
45
|
-
</Box>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
return this.props.children;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const AppTabs = ({
|
|
53
|
-
activeTab,
|
|
54
|
-
setActiveTab,
|
|
55
|
-
onNavigateToConfig,
|
|
56
|
-
settings,
|
|
57
|
-
paymentActions
|
|
58
|
-
}) => {
|
|
59
|
-
const { t } = usePluginTranslations();
|
|
60
|
-
return (
|
|
61
|
-
<Tabs.Root
|
|
62
|
-
value={`tab-${activeTab}`}
|
|
63
|
-
variant="regular"
|
|
64
|
-
onValueChange={(value) =>
|
|
65
|
-
setActiveTab(parseInt(value.replace("tab-", "")))
|
|
66
|
-
}
|
|
67
|
-
>
|
|
68
|
-
<Tabs.List style={{ width: "100%" }}>
|
|
69
|
-
<Tabs.Trigger value="tab-1">{t("tabs.history", "Transaction History")}</Tabs.Trigger>
|
|
70
|
-
<Tabs.Trigger value="tab-2">{t("tabs.configuration", "Configuration")}</Tabs.Trigger>
|
|
71
|
-
<Tabs.Trigger value="tab-3">{t("tabs.paymentActions", "Payment Actions")}</Tabs.Trigger>
|
|
72
|
-
<Tabs.Trigger value="tab-4">{t("tabs.documentation", "Documentation")}</Tabs.Trigger>
|
|
73
|
-
</Tabs.List>
|
|
74
|
-
<Tabs.Content value="tab-1">
|
|
75
|
-
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
76
|
-
<HistoryPanel />
|
|
77
|
-
</TabErrorBoundary>
|
|
78
|
-
</Tabs.Content>
|
|
79
|
-
<Tabs.Content value="tab-2">
|
|
80
|
-
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
81
|
-
<ConfigurationPanel
|
|
82
|
-
settings={settings}
|
|
83
|
-
onNavigateToConfig={onNavigateToConfig}
|
|
84
|
-
/>
|
|
85
|
-
</TabErrorBoundary>
|
|
86
|
-
</Tabs.Content>
|
|
87
|
-
<Tabs.Content value="tab-3">
|
|
88
|
-
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
89
|
-
<PaymentActionsPanel
|
|
90
|
-
onNavigateToConfig={onNavigateToConfig}
|
|
91
|
-
settings={settings}
|
|
92
|
-
paymentActions={paymentActions}
|
|
93
|
-
/>
|
|
94
|
-
</TabErrorBoundary>
|
|
95
|
-
</Tabs.Content>
|
|
96
|
-
<Tabs.Content value="tab-4">
|
|
97
|
-
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
98
|
-
<DocsPanel settings={settings} paymentActions={paymentActions} />
|
|
99
|
-
</TabErrorBoundary>
|
|
100
|
-
</Tabs.Content>
|
|
101
|
-
</Tabs.Root>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default AppTabs;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Box, Typography, Tabs } from "@strapi/design-system";
|
|
3
|
+
import ConfigurationPanel from "./configuration/ConfigurationPanel";
|
|
4
|
+
import HistoryPanel from "./transaction-history/HistoryPanel";
|
|
5
|
+
import PaymentActionsPanel from "./payment-actions/PaymentActionsPanel";
|
|
6
|
+
import DocsPanel from "./DocsPanel";
|
|
7
|
+
import { usePluginTranslations } from "../../hooks/usePluginTranslations";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Error boundary to prevent a single tab's error from crashing the entire plugin.
|
|
11
|
+
* Automatically resets when the user switches tabs.
|
|
12
|
+
*/
|
|
13
|
+
class TabErrorBoundary extends React.Component {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.state = { hasError: false, error: null };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getDerivedStateFromError(error) {
|
|
20
|
+
return { hasError: true, error };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
componentDidCatch(error, errorInfo) {
|
|
24
|
+
console.error("Payone Tab Error:", error, errorInfo);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
// Auto-reset when the user switches to a different tab
|
|
29
|
+
if (prevProps.activeTab !== this.props.activeTab && this.state.hasError) {
|
|
30
|
+
this.setState({ hasError: false, error: null });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render() {
|
|
35
|
+
const { t } = this.props;
|
|
36
|
+
if (this.state.hasError) {
|
|
37
|
+
return (
|
|
38
|
+
<Box padding={6} style={{ textAlign: "center" }}>
|
|
39
|
+
<Typography variant="beta" textColor="danger600">
|
|
40
|
+
{t ? t("error.tabError", "Something went wrong loading this tab.") : "Something went wrong loading this tab."}
|
|
41
|
+
</Typography>
|
|
42
|
+
<Typography variant="pi" textColor="neutral600" style={{ marginTop: "8px", display: "block" }}>
|
|
43
|
+
{t ? t("error.tabErrorHint", "Try switching to another tab or reload the page.") : "Try switching to another tab or reload the page."}
|
|
44
|
+
</Typography>
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return this.props.children;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const AppTabs = ({
|
|
53
|
+
activeTab,
|
|
54
|
+
setActiveTab,
|
|
55
|
+
onNavigateToConfig,
|
|
56
|
+
settings,
|
|
57
|
+
paymentActions
|
|
58
|
+
}) => {
|
|
59
|
+
const { t } = usePluginTranslations();
|
|
60
|
+
return (
|
|
61
|
+
<Tabs.Root
|
|
62
|
+
value={`tab-${activeTab}`}
|
|
63
|
+
variant="regular"
|
|
64
|
+
onValueChange={(value) =>
|
|
65
|
+
setActiveTab(parseInt(value.replace("tab-", "")))
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<Tabs.List style={{ width: "100%" }}>
|
|
69
|
+
<Tabs.Trigger value="tab-1">{t("tabs.history", "Transaction History")}</Tabs.Trigger>
|
|
70
|
+
<Tabs.Trigger value="tab-2">{t("tabs.configuration", "Configuration")}</Tabs.Trigger>
|
|
71
|
+
<Tabs.Trigger value="tab-3">{t("tabs.paymentActions", "Payment Actions")}</Tabs.Trigger>
|
|
72
|
+
<Tabs.Trigger value="tab-4">{t("tabs.documentation", "Documentation")}</Tabs.Trigger>
|
|
73
|
+
</Tabs.List>
|
|
74
|
+
<Tabs.Content value="tab-1">
|
|
75
|
+
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
76
|
+
<HistoryPanel />
|
|
77
|
+
</TabErrorBoundary>
|
|
78
|
+
</Tabs.Content>
|
|
79
|
+
<Tabs.Content value="tab-2">
|
|
80
|
+
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
81
|
+
<ConfigurationPanel
|
|
82
|
+
settings={settings}
|
|
83
|
+
onNavigateToConfig={onNavigateToConfig}
|
|
84
|
+
/>
|
|
85
|
+
</TabErrorBoundary>
|
|
86
|
+
</Tabs.Content>
|
|
87
|
+
<Tabs.Content value="tab-3">
|
|
88
|
+
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
89
|
+
<PaymentActionsPanel
|
|
90
|
+
onNavigateToConfig={onNavigateToConfig}
|
|
91
|
+
settings={settings}
|
|
92
|
+
paymentActions={paymentActions}
|
|
93
|
+
/>
|
|
94
|
+
</TabErrorBoundary>
|
|
95
|
+
</Tabs.Content>
|
|
96
|
+
<Tabs.Content value="tab-4">
|
|
97
|
+
<TabErrorBoundary activeTab={activeTab} t={t}>
|
|
98
|
+
<DocsPanel settings={settings} paymentActions={paymentActions} />
|
|
99
|
+
</TabErrorBoundary>
|
|
100
|
+
</Tabs.Content>
|
|
101
|
+
</Tabs.Root>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default AppTabs;
|