fix(core): add visit workspace button to team upgrade success page (#9186)
close AF-1978
This commit is contained in:
@@ -81,6 +81,9 @@ export const InviteTeamMemberModal = ({
|
|||||||
onOpenChange={setOpen}
|
onOpenChange={setOpen}
|
||||||
title={t['com.affine.payment.member.team.invite.title']()}
|
title={t['com.affine.payment.member.team.invite.title']()}
|
||||||
cancelText={t['com.affine.inviteModal.button.cancel']()}
|
cancelText={t['com.affine.inviteModal.button.cancel']()}
|
||||||
|
cancelButtonOptions={{
|
||||||
|
variant: 'secondary',
|
||||||
|
}}
|
||||||
contentOptions={{
|
contentOptions={{
|
||||||
['data-testid' as string]: 'invite-modal',
|
['data-testid' as string]: 'invite-modal',
|
||||||
style: {
|
style: {
|
||||||
|
|||||||
@@ -150,13 +150,13 @@ export const LinkInvite = ({
|
|||||||
/>
|
/>
|
||||||
{invitationLink ? (
|
{invitationLink ? (
|
||||||
<>
|
<>
|
||||||
<Button onClick={onCopy}>
|
<Button onClick={onCopy} variant="secondary">
|
||||||
{t['com.affine.payment.member.team.invite.copy']()}
|
{t['com.affine.payment.member.team.invite.copy']()}
|
||||||
</Button>
|
</Button>
|
||||||
<IconButton icon={<CloseIcon />} onClick={onReset} />
|
<IconButton icon={<CloseIcon />} onClick={onReset} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Button onClick={onGenerate}>
|
<Button onClick={onGenerate} variant="secondary">
|
||||||
{t['com.affine.payment.member.team.invite.generate']()}
|
{t['com.affine.payment.member.team.invite.generate']()}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ export const getDowngradeQuestionnaireLink = (info: TypeFormInfo) =>
|
|||||||
export const generateSubscriptionCallbackLink = (
|
export const generateSubscriptionCallbackLink = (
|
||||||
account: AuthAccountInfo | null,
|
account: AuthAccountInfo | null,
|
||||||
plan: SubscriptionPlan,
|
plan: SubscriptionPlan,
|
||||||
recurring: SubscriptionRecurring
|
recurring: SubscriptionRecurring,
|
||||||
|
workspaceId?: string
|
||||||
) => {
|
) => {
|
||||||
if (account === null) {
|
if (account === null) {
|
||||||
throw new Error('Account is required');
|
throw new Error('Account is required');
|
||||||
@@ -69,7 +70,22 @@ export const generateSubscriptionCallbackLink = (
|
|||||||
account.id,
|
account.id,
|
||||||
account.email,
|
account.email,
|
||||||
account.info?.name ?? '',
|
account.info?.name ?? '',
|
||||||
|
workspaceId ?? '',
|
||||||
].join(separator);
|
].join(separator);
|
||||||
|
|
||||||
return `${baseUrl}?info=${encodeURIComponent(query)}`;
|
return `${baseUrl}?info=${encodeURIComponent(query)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getSubscriptionInfo = (searchParams: URLSearchParams) => {
|
||||||
|
const decodedInfo = decodeURIComponent(searchParams.get('info') || '');
|
||||||
|
const [plan, recurring, accountId, email, name, workspaceId] =
|
||||||
|
decodedInfo.split(separator);
|
||||||
|
return {
|
||||||
|
plan: plan as SubscriptionPlan,
|
||||||
|
recurring: recurring as SubscriptionRecurring,
|
||||||
|
accountId,
|
||||||
|
email,
|
||||||
|
name: name.replaceAll(recoverSeparator, separator),
|
||||||
|
workspaceId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ export const Upgrade = ({
|
|||||||
className,
|
className,
|
||||||
recurring,
|
recurring,
|
||||||
plan,
|
plan,
|
||||||
|
workspaceId,
|
||||||
children,
|
children,
|
||||||
checkoutInput,
|
checkoutInput,
|
||||||
onCheckoutSuccess,
|
onCheckoutSuccess,
|
||||||
@@ -280,6 +281,7 @@ export const Upgrade = ({
|
|||||||
}: ButtonProps & {
|
}: ButtonProps & {
|
||||||
recurring: SubscriptionRecurring;
|
recurring: SubscriptionRecurring;
|
||||||
plan: SubscriptionPlan;
|
plan: SubscriptionPlan;
|
||||||
|
workspaceId?: string;
|
||||||
checkoutInput?: Partial<CreateCheckoutSessionInput>;
|
checkoutInput?: Partial<CreateCheckoutSessionInput>;
|
||||||
onBeforeCheckout?: () => void;
|
onBeforeCheckout?: () => void;
|
||||||
onCheckoutSuccess?: () => void;
|
onCheckoutSuccess?: () => void;
|
||||||
@@ -304,11 +306,18 @@ export const Upgrade = ({
|
|||||||
successCallbackLink: generateSubscriptionCallbackLink(
|
successCallbackLink: generateSubscriptionCallbackLink(
|
||||||
authService.session.account$.value,
|
authService.session.account$.value,
|
||||||
plan,
|
plan,
|
||||||
recurring
|
recurring,
|
||||||
|
workspaceId
|
||||||
),
|
),
|
||||||
...checkoutInput,
|
...checkoutInput,
|
||||||
}),
|
}),
|
||||||
[authService.session.account$.value, checkoutInput, plan, recurring]
|
[
|
||||||
|
authService.session.account$.value,
|
||||||
|
checkoutInput,
|
||||||
|
plan,
|
||||||
|
recurring,
|
||||||
|
workspaceId,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -288,7 +288,11 @@ const ImportCSV = ({ onImport }: { onImport: (file: File) => void }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Upload accept="text/csv" fileChange={onImport}>
|
<Upload accept="text/csv" fileChange={onImport}>
|
||||||
<Button className={styles.importButton} prefix={<ExportIcon />}>
|
<Button
|
||||||
|
className={styles.importButton}
|
||||||
|
prefix={<ExportIcon />}
|
||||||
|
variant="secondary"
|
||||||
|
>
|
||||||
{t['com.affine.payment.member.team.invite.import-csv']()}
|
{t['com.affine.payment.member.team.invite.import-csv']()}
|
||||||
</Button>
|
</Button>
|
||||||
</Upload>
|
</Upload>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Button } from '@affine/component';
|
import { Button } from '@affine/component';
|
||||||
import { AuthPageContainer } from '@affine/component/auth-components';
|
import { AuthPageContainer } from '@affine/component/auth-components';
|
||||||
|
import { getSubscriptionInfo } from '@affine/core/components/hooks/affine/use-subscription-notify';
|
||||||
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
||||||
import { Trans, useI18n } from '@affine/i18n';
|
import { Trans, useI18n } from '@affine/i18n';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
@@ -15,15 +16,26 @@ import * as styles from './styles.css';
|
|||||||
export const Component = () => {
|
export const Component = () => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
|
const subscriptionInfo = getSubscriptionInfo(params);
|
||||||
|
|
||||||
const { jumpToIndex, jumpToOpenInApp } = useNavigateHelper();
|
const { jumpToPage, jumpToOpenInApp, jumpToIndex } = useNavigateHelper();
|
||||||
const openAffine = useCallback(() => {
|
const openWorkspace = useCallback(() => {
|
||||||
if (params.get('schema')) {
|
if (params.get('schema')) {
|
||||||
jumpToOpenInApp('bring-to-front');
|
jumpToOpenInApp('bring-to-front');
|
||||||
} else {
|
} else {
|
||||||
|
if (subscriptionInfo.workspaceId) {
|
||||||
|
jumpToPage(subscriptionInfo.workspaceId, 'all');
|
||||||
|
return;
|
||||||
|
}
|
||||||
jumpToIndex();
|
jumpToIndex();
|
||||||
}
|
}
|
||||||
}, [jumpToIndex, jumpToOpenInApp, params]);
|
}, [
|
||||||
|
jumpToIndex,
|
||||||
|
jumpToOpenInApp,
|
||||||
|
jumpToPage,
|
||||||
|
params,
|
||||||
|
subscriptionInfo.workspaceId,
|
||||||
|
]);
|
||||||
|
|
||||||
const subtitle = (
|
const subtitle = (
|
||||||
<div className={styles.leftContentText}>
|
<div className={styles.leftContentText}>
|
||||||
@@ -49,8 +61,8 @@ export const Component = () => {
|
|||||||
title={t['com.affine.payment.upgrade-success-page.title']()}
|
title={t['com.affine.payment.upgrade-success-page.title']()}
|
||||||
subtitle={subtitle}
|
subtitle={subtitle}
|
||||||
>
|
>
|
||||||
<Button variant="primary" size="extraLarge" onClick={openAffine}>
|
<Button variant="primary" size="extraLarge" onClick={openWorkspace}>
|
||||||
{t['com.affine.other-page.nav.open-affine']()}
|
{t['Visit Workspace']()}
|
||||||
</Button>
|
</Button>
|
||||||
</AuthPageContainer>
|
</AuthPageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ const UpgradeDialog = ({
|
|||||||
className={styles.upgradeButtonInDialog}
|
className={styles.upgradeButtonInDialog}
|
||||||
recurring={currentRecurring}
|
recurring={currentRecurring}
|
||||||
plan={SubscriptionPlan.Team}
|
plan={SubscriptionPlan.Team}
|
||||||
|
workspaceId={workspaceId}
|
||||||
onCheckoutSuccess={onClose}
|
onCheckoutSuccess={onClose}
|
||||||
checkoutInput={{
|
checkoutInput={{
|
||||||
args: {
|
args: {
|
||||||
|
|||||||
Reference in New Issue
Block a user