|
|
@@ -3,10 +3,11 @@ import { useCallback } from 'react';
|
|
|
import { Trans, useTranslation } from 'react-i18next';
|
|
|
|
|
|
import LoginForm from '@/components/LoginForm';
|
|
|
+import { message } from '@/config/request/antdAppInstance';
|
|
|
import { PayUrlShowType } from '@/defines';
|
|
|
import { useAppUrls } from '@/hooks/useAppUrls';
|
|
|
import { dialogModel } from '@/models/dialogModel';
|
|
|
-import { fetchPayOrderCreate } from '@/services/config';
|
|
|
+import { fetchGetUserConfig, fetchPayOrderCreate } from '@/services/config';
|
|
|
import { getToken } from '@/utils/authUtils';
|
|
|
import { currentUnixTimestamp } from '@/utils/timeUtils';
|
|
|
|
|
|
@@ -37,11 +38,7 @@ function useLoginDialog() {
|
|
|
i18nKey="pages.pricing.payFlow.loginPrompt"
|
|
|
components={{
|
|
|
linkText: (() => {
|
|
|
- const Wrap = ({
|
|
|
- children,
|
|
|
- }: {
|
|
|
- children?: React.ReactNode;
|
|
|
- }) =>
|
|
|
+ const Wrap = ({ children }: { children?: React.ReactNode }) =>
|
|
|
deeplinkUrl ? (
|
|
|
<a
|
|
|
href={deeplinkUrl}
|
|
|
@@ -57,11 +54,7 @@ function useLoginDialog() {
|
|
|
return <Wrap />;
|
|
|
})(),
|
|
|
downloadLink: (() => {
|
|
|
- const Wrap = ({
|
|
|
- children,
|
|
|
- }: {
|
|
|
- children?: React.ReactNode;
|
|
|
- }) =>
|
|
|
+ const Wrap = ({ children }: { children?: React.ReactNode }) =>
|
|
|
downloadUrlByPlatform ? (
|
|
|
<a
|
|
|
href={downloadUrlByPlatform}
|
|
|
@@ -92,6 +85,12 @@ function useQrPayDialog() {
|
|
|
const { t } = useTranslation();
|
|
|
const { openDialog, closeDialog } = dialogModel.useModel();
|
|
|
|
|
|
+ const onPaymentSuccess = useCallback(() => {
|
|
|
+ return fetchGetUserConfig({}).then(() => {
|
|
|
+ message.success(t('pages.pricing.payFlow.planPurchaseSuccess'));
|
|
|
+ });
|
|
|
+ }, [t]);
|
|
|
+
|
|
|
return useCallback(
|
|
|
(order: PayOrder) => {
|
|
|
const qrDialogId = openDialog({
|
|
|
@@ -101,16 +100,14 @@ function useQrPayDialog() {
|
|
|
orderId={order.orderId}
|
|
|
payUrl={order.payUrl}
|
|
|
onClose={() => closeDialog(qrDialogId)}
|
|
|
+ onPaymentSuccess={onPaymentSuccess}
|
|
|
/>
|
|
|
),
|
|
|
buttons: [
|
|
|
{
|
|
|
label: t('pages.pricing.payFlow.closeWaiting'),
|
|
|
variant: 'secondary' as const,
|
|
|
- onClick: (
|
|
|
- _e: React.MouseEvent<HTMLButtonElement>,
|
|
|
- dialogId: string
|
|
|
- ) => {
|
|
|
+ onClick: (_e: React.MouseEvent<HTMLButtonElement>, dialogId: string) => {
|
|
|
closeDialog(dialogId);
|
|
|
},
|
|
|
},
|
|
|
@@ -119,7 +116,7 @@ function useQrPayDialog() {
|
|
|
closeable: true,
|
|
|
});
|
|
|
},
|
|
|
- [t, openDialog, closeDialog],
|
|
|
+ [t, openDialog, closeDialog, onPaymentSuccess]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -127,6 +124,12 @@ function useJumpToPayDialog() {
|
|
|
const { t } = useTranslation();
|
|
|
const { openDialog, closeDialog } = dialogModel.useModel();
|
|
|
|
|
|
+ const onPaymentSuccess = useCallback(() => {
|
|
|
+ return fetchGetUserConfig({}).then(() => {
|
|
|
+ message.success(t('pages.pricing.payFlow.planPurchaseSuccess'));
|
|
|
+ });
|
|
|
+ }, [t]);
|
|
|
+
|
|
|
return useCallback(
|
|
|
(order: PayOrder) => {
|
|
|
openDialog({
|
|
|
@@ -140,10 +143,7 @@ function useJumpToPayDialog() {
|
|
|
{
|
|
|
label: t('pages.pricing.payFlow.goToPayButton'),
|
|
|
variant: 'primary' as const,
|
|
|
- onClick: (
|
|
|
- _e: React.MouseEvent<HTMLButtonElement>,
|
|
|
- dialogId: string
|
|
|
- ) => {
|
|
|
+ onClick: (_e: React.MouseEvent<HTMLButtonElement>, dialogId: string) => {
|
|
|
window.open(order.payUrl, '_blank');
|
|
|
closeDialog(dialogId);
|
|
|
const waitId = openDialog({
|
|
|
@@ -152,6 +152,7 @@ function useJumpToPayDialog() {
|
|
|
<PayWaitingContent
|
|
|
orderId={order.orderId}
|
|
|
onClose={() => closeDialog(waitId)}
|
|
|
+ onPaymentSuccess={onPaymentSuccess}
|
|
|
/>
|
|
|
),
|
|
|
buttons: [
|
|
|
@@ -175,7 +176,7 @@ function useJumpToPayDialog() {
|
|
|
closeable: true,
|
|
|
});
|
|
|
},
|
|
|
- [t, openDialog, closeDialog],
|
|
|
+ [t, openDialog, closeDialog, onPaymentSuccess]
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -215,7 +216,7 @@ export function useAction(): UseActionReturn {
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
- [openLoginDialog, openQrPayDialog, openJumpToPayDialog],
|
|
|
+ [openLoginDialog, openQrPayDialog, openJumpToPayDialog]
|
|
|
);
|
|
|
|
|
|
return {
|