mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 20:41:50 +08:00
fix(core): cannot view pricing page if not logged in (#8907)
Due to lifetime plan card show `Upgrade` button that require accout, should show `Login` instead
This commit is contained in:
+9
-3
@@ -1,10 +1,10 @@
|
|||||||
import { Button } from '@affine/component';
|
import { Button } from '@affine/component';
|
||||||
import { SubscriptionService } from '@affine/core/modules/cloud';
|
import { AuthService, SubscriptionService } from '@affine/core/modules/cloud';
|
||||||
import { SubscriptionRecurring } from '@affine/graphql';
|
import { SubscriptionRecurring } from '@affine/graphql';
|
||||||
import { Trans, useI18n } from '@affine/i18n';
|
import { Trans, useI18n } from '@affine/i18n';
|
||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
|
|
||||||
import { Upgrade } from '../plan-card';
|
import { SignUpAction, Upgrade } from '../plan-card';
|
||||||
import { BelieverCard } from './believer-card';
|
import { BelieverCard } from './believer-card';
|
||||||
import { BelieverBenefits } from './benefits';
|
import { BelieverBenefits } from './benefits';
|
||||||
import * as styles from './style.css';
|
import * as styles from './style.css';
|
||||||
@@ -12,6 +12,8 @@ import * as styles from './style.css';
|
|||||||
export const LifetimePlan = () => {
|
export const LifetimePlan = () => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const subscriptionService = useService(SubscriptionService);
|
const subscriptionService = useService(SubscriptionService);
|
||||||
|
const loggedIn =
|
||||||
|
useLiveData(useService(AuthService).session.status$) === 'authenticated';
|
||||||
|
|
||||||
const readableLifetimePrice = useLiveData(
|
const readableLifetimePrice = useLiveData(
|
||||||
subscriptionService.prices.readableLifetimePrice$
|
subscriptionService.prices.readableLifetimePrice$
|
||||||
@@ -32,7 +34,11 @@ export const LifetimePlan = () => {
|
|||||||
|
|
||||||
<div className={styles.price}>{readableLifetimePrice}</div>
|
<div className={styles.price}>{readableLifetimePrice}</div>
|
||||||
|
|
||||||
{isBeliever ? (
|
{!loggedIn ? (
|
||||||
|
<SignUpAction className={styles.purchase}>
|
||||||
|
{t['com.affine.payment.sign-up-free']()}
|
||||||
|
</SignUpAction>
|
||||||
|
) : isBeliever ? (
|
||||||
<Button className={styles.purchase} size="default" disabled>
|
<Button className={styles.purchase} size="default" disabled>
|
||||||
{t['com.affine.payment.lifetime.purchased']()}
|
{t['com.affine.payment.lifetime.purchased']()}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+5
-2
@@ -383,7 +383,10 @@ const ChangeRecurring = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const SignUpAction = ({ children }: PropsWithChildren) => {
|
export const SignUpAction = ({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
}: PropsWithChildren<{ className?: string }>) => {
|
||||||
const setOpen = useSetAtom(authAtom);
|
const setOpen = useSetAtom(authAtom);
|
||||||
|
|
||||||
const onClickSignIn = useCallback(() => {
|
const onClickSignIn = useCallback(() => {
|
||||||
@@ -396,7 +399,7 @@ const SignUpAction = ({ children }: PropsWithChildren) => {
|
|||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={onClickSignIn}
|
onClick={onClickSignIn}
|
||||||
className={styles.planAction}
|
className={clsx(styles.planAction, className)}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user