diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/billing/payment-method.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/billing/payment-method.tsx index ba6ab9c9e6..61d2799138 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/billing/payment-method.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/billing/payment-method.tsx @@ -1,3 +1,4 @@ +import { notify } from '@affine/component'; import { SettingRow } from '@affine/component/setting-components'; import { Button, @@ -7,6 +8,7 @@ import { import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { SubscriptionService } from '@affine/core/modules/cloud'; import { UrlService } from '@affine/core/modules/url'; +import { UserFriendlyError } from '@affine/error'; import { createCustomerPortalMutation } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; @@ -92,8 +94,11 @@ export const PaymentMethodUpdater = ({ const update = useAsyncCallback(async () => { await trigger(null, { onSuccess: data => { - urlService.openPopupWindow(data.createCustomerPortal); + urlService.openExternal(data.createCustomerPortal); }, + }).catch(e => { + const userFriendlyError = UserFriendlyError.fromAny(e); + notify.error(userFriendlyError); }); }, [trigger, urlService]); diff --git a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/checkout-slot.tsx b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/checkout-slot.tsx index 252cf517ee..9ab30793e5 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/checkout-slot.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/general-setting/plans/checkout-slot.tsx @@ -65,7 +65,7 @@ export const CheckoutSlot = ({ idempotencyKey, ...checkoutOptions, }); - urlService.openPopupWindow(session); + urlService.openExternal(session); setOpenedExternalWindow(true); setIdempotencyKey(nanoid()); onCheckoutSuccess?.(); diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/payment-method.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/payment-method.tsx index 1df6f3f987..c61b74e5d8 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/payment-method.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/billing/payment-method.tsx @@ -1,8 +1,9 @@ -import { Button } from '@affine/component'; +import { Button, notify } from '@affine/component'; import { SettingRow } from '@affine/component/setting-components'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { useMutation } from '@affine/core/components/hooks/use-mutation'; import { UrlService } from '@affine/core/modules/url'; +import { UserFriendlyError } from '@affine/error'; import { createCustomerPortalMutation } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; import { useService } from '@toeverything/infra'; @@ -19,8 +20,11 @@ export const PaymentMethodUpdater = () => { const update = useAsyncCallback(async () => { await trigger(null, { onSuccess: data => { - urlService.openPopupWindow(data.createCustomerPortal); + urlService.openExternal(data.createCustomerPortal); }, + }).catch(e => { + const userFriendlyError = UserFriendlyError.fromAny(e); + notify.error(userFriendlyError); }); }, [trigger, urlService]); diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/license/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/license/index.tsx index d72fb70aac..1b86ba0abf 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/license/index.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/license/index.tsx @@ -1,4 +1,4 @@ -import { Button } from '@affine/component'; +import { Button, notify } from '@affine/component'; import { SettingHeader, SettingRow, @@ -13,6 +13,7 @@ import { import { WorkspacePermissionService } from '@affine/core/modules/permissions'; import { UrlService } from '@affine/core/modules/url'; import { WorkspaceService } from '@affine/core/modules/workspace'; +import { UserFriendlyError } from '@affine/error'; import { createSelfhostCustomerPortalMutation, SubscriptionPlan, @@ -111,12 +112,13 @@ const PaymentMethodUpdater = () => { }, { onSuccess: data => { - urlService.openPopupWindow( - data.createSelfhostWorkspaceCustomerPortal - ); + urlService.openExternal(data.createSelfhostWorkspaceCustomerPortal); }, } - ); + ).catch(e => { + const userFriendlyError = UserFriendlyError.fromAny(e); + notify.error(userFriendlyError); + }); }, [trigger, urlService, workspace.id]); if (!isTeam) { diff --git a/packages/frontend/core/src/desktop/pages/ai-upgrade-success/index.tsx b/packages/frontend/core/src/desktop/pages/ai-upgrade-success/index.tsx index 81ca31fbc9..dca1b8b859 100644 --- a/packages/frontend/core/src/desktop/pages/ai-upgrade-success/index.tsx +++ b/packages/frontend/core/src/desktop/pages/ai-upgrade-success/index.tsx @@ -16,15 +16,14 @@ export const Component = () => { const t = useI18n(); const [params] = useSearchParams(); - const { jumpToOpenInApp } = useNavigateHelper(); + const { jumpToIndex, jumpToOpenInApp } = useNavigateHelper(); const openAFFiNE = useCallback(() => { if (params.get('client')) { return jumpToOpenInApp('bring-to-front'); } else { - // close popup window - return window.close(); + jumpToIndex(); } - }, [jumpToOpenInApp, params]); + }, [jumpToIndex, jumpToOpenInApp, params]); const subtitle = (