feat(core): open desktop directly in subscription landing page (#6661)

This commit is contained in:
CatsJuice
2024-04-22 14:21:58 +00:00
parent 71a5be5385
commit 6ec97b27c4
6 changed files with 50 additions and 7 deletions
@@ -1,7 +1,6 @@
import { Button, type ButtonProps } from '@affine/component';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { SubscriptionService } from '@affine/core/modules/cloud';
import { getAffineCloudBaseUrl } from '@affine/core/modules/cloud/services/fetch';
import { popupWindow } from '@affine/core/utils';
import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
@@ -43,7 +42,7 @@ export const AISubscribe = ({ ...btnProps }: AISubscribeProps) => {
idempotencyKey,
plan: SubscriptionPlan.AI,
coupon: null,
successCallbackLink: getAffineCloudBaseUrl() + '/ai-upgrade-success',
successCallbackLink: null,
});
popupWindow(session);
setOpenedExternalWindow(true);
@@ -4,6 +4,7 @@ import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
import { Trans } from '@affine/i18n';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { type ReactNode, useCallback } from 'react';
import { useSearchParams } from 'react-router-dom';
import * as styles from './styles.css';
@@ -15,11 +16,16 @@ const UpgradeSuccessLayout = ({
description?: ReactNode;
}) => {
const t = useAFFiNEI18N();
const [params] = useSearchParams();
const { jumpToIndex } = useNavigateHelper();
const { jumpToIndex, openInApp } = useNavigateHelper();
const openAffine = useCallback(() => {
jumpToIndex();
}, [jumpToIndex]);
if (params.get('schema')) {
openInApp(params.get('schema') ?? 'affine', 'bring-to-front');
} else {
jumpToIndex();
}
}, [jumpToIndex, openInApp, params]);
const subtitle = (
<div className={styles.leftContentText}>