Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add ai subscription landing page #6657

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand Down Expand Up @@ -42,7 +43,7 @@ export const AISubscribe = ({ ...btnProps }: AISubscribeProps) => {
idempotencyKey,
plan: SubscriptionPlan.AI,
coupon: null,
successCallbackLink: null,
successCallbackLink: getAffineCloudBaseUrl() + '/ai-upgrade-success',
});
popupWindow(session);
setOpenedExternalWindow(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions packages/frontend/core/src/pages/ai-upgrade-success.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AIUpgradeSuccess } from '../components/affine/subscription-landing';

export const Component = () => {
return <AIUpgradeSuccess />;
};
50 changes: 2 additions & 48 deletions packages/frontend/core/src/pages/upgrade-success.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
import { AuthPageContainer } from '@affine/component/auth-components';
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>
);
};
import { CloudUpgradeSuccess } from '../components/affine/subscription-landing';

export const Component = () => {
return <UpgradeSuccess />;
return <CloudUpgradeSuccess />;
};
4 changes: 4 additions & 0 deletions packages/frontend/core/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export const topLevelRoutes = [
path: '/upgrade-success',
lazy: () => import('./pages/upgrade-success'),
},
{
path: '/ai-upgrade-success',
lazy: () => import('./pages/ai-upgrade-success'),
},
{
path: '/desktop-signin',
lazy: () => import('./pages/desktop-signin'),
Expand Down
9 changes: 7 additions & 2 deletions packages/frontend/electron/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ import type { PropsWithChildren, ReactElement } from 'react';
import { lazy, Suspense } from 'react';
import { RouterProvider } from 'react-router-dom';

const desktopWhiteList = [
'/desktop-signin',
'/open-app/signin-redirect',
'/upgrade-success',
'/ai-upgrade-success',
];
if (
!environment.isDesktop &&
environment.isDebug &&
!location.pathname.includes('/desktop-signin') &&
!location.pathname.includes('/open-app/signin-redirect')
desktopWhiteList.every(path => !location.pathname.startsWith(path))
) {
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');
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

Inconsistent keys

com.affine.payment.ai.usage.change-button-label, com.affine.ai-onboarding.general.try-for-free

Check notice on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

New keys

Get in touch! Join our communities., It takes up little space on your device., It takes up more space on your device., com.affine.auth.open.affine.download-app, com.affine.auth.open.affine.prompt, com.affine.auth.open.affine.try-again, com.affine.auth.reset.password.message, com.affine.auth.reset.password.page.success, com.affine.auth.sent.change.email.hint, com.affine.auth.sent.reset.password.success.message, com.affine.auth.sent.set.password.hint, com.affine.auth.sent.set.password.success.message, com.affine.auth.set.password.save, com.affine.auth.sign.up.sent.email.subtitle, com.affine.auth.sign.up.success.title, com.affine.editCollection.rules.tips.highlight, com.affine.page-properties.add-property.menu.create, com.affine.page-properties.add-property.menu.header, com.affine.pageMode.all, com.affine.pageMode.edgeless, com.affine.pageMode.page, com.affine.setting.account.delete.message, com.affine.settings.appearance.border-style-description, com.affine.settings.appearance.start-week-description, com.affine.settings.email.action, com.affine.settings.password.action.change, com.affine.settings.password.action.set, com.affine.settings.password.message, com.affine.settings.profile.message, com.affine.settings.profile.placeholder, com.affine.settings.workspace.experimental-features, com.affine.settings.workspace.experimental-features.get-started, com.affine.settings.workspace.experimental-features.header.plugins, com.affine.settings.workspace.experimental-features.prompt-disclaimer, com.affine.settings.workspace.experimental-features.prompt-header, com.affine.settings.workspace.experimental-features.prompt-warning, com.affine.settings.workspace.experimental-features.prompt-warning-title, com.affine.settings.workspace.preferences, com.affine.settings.workspace.properties, com.affine.settings.workspace.properties.add_property, com.affine.settings.workspace.properties.all, com.affine.settings.workspace.properties.delete-property, com.affine.settings.workspace.properties.doc, com.affine.settings.workspace.properties.doc_others, com.affine.settings.workspace.properties.edit-property, com.affine.settings.workspace.properties.header.subtitle, com.affine.settings.workspace.properties.header.title, com.affine.settings.workspace.properties.in-use, com.affine.settings.workspace.properties.set-as-required, com.affine.settings.workspace.properties.unused, com.affine.settings.workspace.storage.tip, com.affine.storage.maximum-tips.pro, com.affine.workspace.cloud.description

Check warning on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

Inconsistent keys

com.affine.payment.ai.usage.change-button-label, com.affine.ai-onboarding.general.try-for-free

Check notice on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

New keys

Get in touch! Join our communities., It takes up little space on your device., It takes up more space on your device., com.affine.auth.open.affine.download-app, com.affine.auth.open.affine.prompt, com.affine.auth.open.affine.try-again, com.affine.auth.reset.password.message, com.affine.auth.reset.password.page.success, com.affine.auth.sent.change.email.hint, com.affine.auth.sent.reset.password.success.message, com.affine.auth.sent.set.password.hint, com.affine.auth.sent.set.password.success.message, com.affine.auth.set.password.save, com.affine.auth.sign.up.sent.email.subtitle, com.affine.auth.sign.up.success.title, com.affine.editCollection.rules.tips.highlight, com.affine.page-properties.add-property.menu.create, com.affine.page-properties.add-property.menu.header, com.affine.pageMode.all, com.affine.pageMode.edgeless, com.affine.pageMode.page, com.affine.payment.ai-upgrade-success-page.title, com.affine.payment.ai-upgrade-success-page.text, com.affine.setting.account.delete.message, com.affine.settings.appearance.border-style-description, com.affine.settings.appearance.start-week-description, com.affine.settings.email.action, com.affine.settings.password.action.change, com.affine.settings.password.action.set, com.affine.settings.password.message, com.affine.settings.profile.message, com.affine.settings.profile.placeholder, com.affine.settings.workspace.experimental-features, com.affine.settings.workspace.experimental-features.get-started, com.affine.settings.workspace.experimental-features.header.plugins, com.affine.settings.workspace.experimental-features.prompt-disclaimer, com.affine.settings.workspace.experimental-features.prompt-header, com.affine.settings.workspace.experimental-features.prompt-warning, com.affine.settings.workspace.experimental-features.prompt-warning-title, com.affine.settings.workspace.preferences, com.affine.settings.workspace.properties, com.affine.settings.workspace.properties.add_property, com.affine.settings.workspace.properties.all, com.affine.settings.workspace.properties.delete-property, com.affine.settings.workspace.properties.doc, com.affine.settings.workspace.properties.doc_others, com.affine.settings.workspace.properties.edit-property, com.affine.settings.workspace.properties.header.subtitle, com.affine.settings.workspace.properties.header.title, com.affine.settings.workspace.properties.in-use, com.affine.settings.workspace.properties.set-as-required, com.affine.settings.workspace.properties.unused, com.affine.settings.workspace.storage.tip, com.affine.storage.maximum-tips.pro, com.affine.workspace.cloud.description
"404 - Page Not Found": "404 - Page Not Found",
"404.back": "Back to My Content",
"404.hint": "Sorry, you do not have access or this content does not exist...",
Expand Down Expand Up @@ -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.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.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.disable": "Disable",
"com.affine.publicLinkDisableModal.description": "Disabling this public link will prevent anyone with the link from accessing this doc.",
Expand Down
Loading