feat(core): add ai subscription landing page (#6657)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Button, type ButtonProps } from '@affine/component';
|
import { Button, type ButtonProps } from '@affine/component';
|
||||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||||
import { SubscriptionService } from '@affine/core/modules/cloud';
|
import { SubscriptionService } from '@affine/core/modules/cloud';
|
||||||
|
import { getAffineCloudBaseUrl } from '@affine/core/modules/cloud/services/fetch';
|
||||||
import { popupWindow } from '@affine/core/utils';
|
import { popupWindow } from '@affine/core/utils';
|
||||||
import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';
|
import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
@@ -42,7 +43,7 @@ export const AISubscribe = ({ ...btnProps }: AISubscribeProps) => {
|
|||||||
idempotencyKey,
|
idempotencyKey,
|
||||||
plan: SubscriptionPlan.AI,
|
plan: SubscriptionPlan.AI,
|
||||||
coupon: null,
|
coupon: null,
|
||||||
successCallbackLink: null,
|
successCallbackLink: getAffineCloudBaseUrl() + '/ai-upgrade-success',
|
||||||
});
|
});
|
||||||
popupWindow(session);
|
popupWindow(session);
|
||||||
setOpenedExternalWindow(true);
|
setOpenedExternalWindow(true);
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { AuthPageContainer } from '@affine/component/auth-components';
|
||||||
|
import { Button } from '@affine/component/ui/button';
|
||||||
|
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 * as styles from './styles.css';
|
||||||
|
|
||||||
|
const UpgradeSuccessLayout = ({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
}: {
|
||||||
|
title?: ReactNode;
|
||||||
|
description?: ReactNode;
|
||||||
|
}) => {
|
||||||
|
const t = useAFFiNEI18N();
|
||||||
|
|
||||||
|
const { jumpToIndex } = useNavigateHelper();
|
||||||
|
const openAffine = useCallback(() => {
|
||||||
|
jumpToIndex();
|
||||||
|
}, [jumpToIndex]);
|
||||||
|
|
||||||
|
const subtitle = (
|
||||||
|
<div className={styles.leftContentText}>
|
||||||
|
{description}
|
||||||
|
<div>
|
||||||
|
<Trans
|
||||||
|
i18nKey={'com.affine.payment.upgrade-success-page.support'}
|
||||||
|
components={{
|
||||||
|
1: (
|
||||||
|
<a
|
||||||
|
href="mailto:support@toeverything.info"
|
||||||
|
className={styles.mail}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AuthPageContainer title={title} subtitle={subtitle}>
|
||||||
|
<Button type="primary" size="extraLarge" onClick={openAffine}>
|
||||||
|
{t['com.affine.other-page.nav.open-affine']()}
|
||||||
|
</Button>
|
||||||
|
</AuthPageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudUpgradeSuccess = () => {
|
||||||
|
const t = useAFFiNEI18N();
|
||||||
|
return (
|
||||||
|
<UpgradeSuccessLayout
|
||||||
|
title={t['com.affine.payment.upgrade-success-page.title']()}
|
||||||
|
description={t['com.affine.payment.upgrade-success-page.text']()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AIUpgradeSuccess = () => {
|
||||||
|
const t = useAFFiNEI18N();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UpgradeSuccessLayout
|
||||||
|
title={t['com.affine.payment.ai-upgrade-success-page.title']()}
|
||||||
|
description={t['com.affine.payment.ai-upgrade-success-page.text']()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
5
packages/frontend/core/src/pages/ai-upgrade-success.tsx
Normal file
5
packages/frontend/core/src/pages/ai-upgrade-success.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { AIUpgradeSuccess } from '../components/affine/subscription-landing';
|
||||||
|
|
||||||
|
export const Component = () => {
|
||||||
|
return <AIUpgradeSuccess />;
|
||||||
|
};
|
||||||
@@ -1,51 +1,5 @@
|
|||||||
import { AuthPageContainer } from '@affine/component/auth-components';
|
import { CloudUpgradeSuccess } from '../components/affine/subscription-landing';
|
||||||
import { Button } from '@affine/component/ui/button';
|
|
||||||
import { Trans } from '@affine/i18n';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
|
|
||||||
import { useNavigateHelper } from '../hooks/use-navigate-helper';
|
|
||||||
import * as styles from './upgrade-success.css';
|
|
||||||
|
|
||||||
export const UpgradeSuccess = () => {
|
|
||||||
const t = useAFFiNEI18N();
|
|
||||||
|
|
||||||
const { jumpToIndex } = useNavigateHelper();
|
|
||||||
const openAffine = useCallback(() => {
|
|
||||||
jumpToIndex();
|
|
||||||
}, [jumpToIndex]);
|
|
||||||
|
|
||||||
const subtitle = (
|
|
||||||
<div className={styles.leftContentText}>
|
|
||||||
{t['com.affine.payment.upgrade-success-page.text']()}
|
|
||||||
<div>
|
|
||||||
<Trans
|
|
||||||
i18nKey={'com.affine.payment.upgrade-success-page.support'}
|
|
||||||
components={{
|
|
||||||
1: (
|
|
||||||
<a
|
|
||||||
href="mailto:support@toeverything.info"
|
|
||||||
className={styles.mail}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AuthPageContainer
|
|
||||||
title={t['com.affine.payment.upgrade-success-page.title']()}
|
|
||||||
subtitle={subtitle}
|
|
||||||
>
|
|
||||||
<Button type="primary" size="extraLarge" onClick={openAffine}>
|
|
||||||
{t['com.affine.other-page.nav.open-affine']()}
|
|
||||||
</Button>
|
|
||||||
</AuthPageContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Component = () => {
|
export const Component = () => {
|
||||||
return <UpgradeSuccess />;
|
return <CloudUpgradeSuccess />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ export const topLevelRoutes = [
|
|||||||
path: '/upgrade-success',
|
path: '/upgrade-success',
|
||||||
lazy: () => import('./pages/upgrade-success'),
|
lazy: () => import('./pages/upgrade-success'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/ai-upgrade-success',
|
||||||
|
lazy: () => import('./pages/ai-upgrade-success'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/desktop-signin',
|
path: '/desktop-signin',
|
||||||
lazy: () => import('./pages/desktop-signin'),
|
lazy: () => import('./pages/desktop-signin'),
|
||||||
|
|||||||
@@ -29,11 +29,16 @@ import type { PropsWithChildren, ReactElement } from 'react';
|
|||||||
import { lazy, Suspense } from 'react';
|
import { lazy, Suspense } from 'react';
|
||||||
import { RouterProvider } from 'react-router-dom';
|
import { RouterProvider } from 'react-router-dom';
|
||||||
|
|
||||||
|
const desktopWhiteList = [
|
||||||
|
'/desktop-signin',
|
||||||
|
'/open-app/signin-redirect',
|
||||||
|
'/upgrade-success',
|
||||||
|
'/ai-upgrade-success',
|
||||||
|
];
|
||||||
if (
|
if (
|
||||||
!environment.isDesktop &&
|
!environment.isDesktop &&
|
||||||
environment.isDebug &&
|
environment.isDebug &&
|
||||||
!location.pathname.includes('/desktop-signin') &&
|
desktopWhiteList.every(path => !location.pathname.startsWith(path))
|
||||||
!location.pathname.includes('/open-app/signin-redirect')
|
|
||||||
) {
|
) {
|
||||||
document.body.innerHTML = `<h1 style="color:red;font-size:5rem;text-align:center;">Don't run electron entry in browser.</h1>`;
|
document.body.innerHTML = `<h1 style="color:red;font-size:5rem;text-align:center;">Don't run electron entry in browser.</h1>`;
|
||||||
throw new Error('Wrong distribution');
|
throw new Error('Wrong distribution');
|
||||||
|
|||||||
@@ -1022,6 +1022,8 @@
|
|||||||
"com.affine.payment.upgrade-success-page.support": "If you have any questions, please contact our <1> customer support</1>.",
|
"com.affine.payment.upgrade-success-page.support": "If you have any questions, please contact our <1> customer support</1>.",
|
||||||
"com.affine.payment.upgrade-success-page.text": "Congratulations! Your AFFiNE account has been successfully upgraded to a Pro account.",
|
"com.affine.payment.upgrade-success-page.text": "Congratulations! Your AFFiNE account has been successfully upgraded to a Pro account.",
|
||||||
"com.affine.payment.upgrade-success-page.title": "Upgrade Successful!",
|
"com.affine.payment.upgrade-success-page.title": "Upgrade Successful!",
|
||||||
|
"com.affine.payment.ai-upgrade-success-page.title": "Purchase Successful!",
|
||||||
|
"com.affine.payment.ai-upgrade-success-page.text": "Congratulations on your successful purchase of AFFiNE AI! You're now empowered to refine your content, generate images, and craft comprehensive mindmaps directly within AFFiNE AI, dramatically enhancing your productivity.",
|
||||||
"com.affine.publicLinkDisableModal.button.cancel": "Cancel",
|
"com.affine.publicLinkDisableModal.button.cancel": "Cancel",
|
||||||
"com.affine.publicLinkDisableModal.button.disable": "Disable",
|
"com.affine.publicLinkDisableModal.button.disable": "Disable",
|
||||||
"com.affine.publicLinkDisableModal.description": "Disabling this public link will prevent anyone with the link from accessing this doc.",
|
"com.affine.publicLinkDisableModal.description": "Disabling this public link will prevent anyone with the link from accessing this doc.",
|
||||||
|
|||||||
Reference in New Issue
Block a user