From 4db49edca66b8a82146abd31fab4e668ca160190 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 19 Nov 2024 20:02:36 -0600 Subject: [PATCH] Show state, add mgmt url --- src/screens/Settings/Settings.tsx | 6 ++ src/screens/Subscriptions/index.tsx | 65 +++++++++++++++---- src/state/purchases/subscriptions/types.ts | 9 +++ .../useManageSubscription/index.ts | 17 +++++ .../useManageSubscription/index.web.ts | 30 +++++++++ .../subscriptions/useSubscriptionsState.ts | 28 ++++++++ 6 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 src/state/purchases/subscriptions/useManageSubscription/index.ts create mode 100644 src/state/purchases/subscriptions/useManageSubscription/index.web.ts create mode 100644 src/state/purchases/subscriptions/useSubscriptionsState.ts diff --git a/src/screens/Settings/Settings.tsx b/src/screens/Settings/Settings.tsx index 126a1bc88e..f2e24523d9 100644 --- a/src/screens/Settings/Settings.tsx +++ b/src/screens/Settings/Settings.tsx @@ -162,6 +162,12 @@ export function SettingsScreen({}: Props) { Moderation + + + + Subscriptions + + diff --git a/src/screens/Subscriptions/index.tsx b/src/screens/Subscriptions/index.tsx index 95442f2c5f..557ca88593 100644 --- a/src/screens/Subscriptions/index.tsx +++ b/src/screens/Subscriptions/index.tsx @@ -1,20 +1,24 @@ import React from 'react' import {View} from 'react-native' +import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {NativeStackScreenProps} from '@react-navigation/native-stack' import {CommonNavigatorParams} from '#/lib/routes/types' -import {useEntitlements} from '#/state/purchases/subscriptions/useEntitlements' +import {useSubscriptionsState} from '#/state/purchases/subscriptions/useSubscriptionsState' +import {useManageSubscription} from '#/state/purchases/subscriptions/useManageSubscription' +import {Subscription} from '#/state/purchases/subscriptions/types' import {CenteredView} from '#/view/com/util/Views' -import {atoms as a} from '#/alf' +import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' import {BlueskyPlus} from '#/components/dialogs/BlueskyPlus' -import {Logotype} from '#/components/icons/BlueskyPlus' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import * as Layout from '#/components/Layout' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' +import {useCurrencyFormatter} from '#/lib/currency' +import {InlineLinkText, createStaticClick} from '#/components/Link' export type ScreenProps = NativeStackScreenProps< CommonNavigatorParams, @@ -23,26 +27,23 @@ export type ScreenProps = NativeStackScreenProps< export function Subscriptions(_props: ScreenProps) { const {_} = useLingui() - const {data: entitlements, isLoading: isEntitlementsLoading} = - useEntitlements() - const isSubscribed = entitlements?.some(e => e.id === 'core') + const {data: state, isLoading: isStateLoading} = + useSubscriptionsState() + const isSubscribed = state?.entitlements?.some(e => e.id === 'core') const control = useDialogControl() return ( + + - - - - {isEntitlementsLoading ? ( + {isStateLoading ? ( ) : ( <> {isSubscribed ? ( - - You're subscribed! - + ) : ( <>