From be84fef70c9e2c5ae435a7124e12d55bae33c385 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 19 Sep 2025 13:16:12 -0400 Subject: [PATCH] this works - still seems the subscription state is broken --- .../src/lib/panes/BillingSettingsPane.tsx | 1 - .../credits/src/lib/state/credits-state.ts | 2 +- .../src/lib/subscription-state.ts | 26 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/frontend/libs/components/settings-modal/src/lib/panes/BillingSettingsPane.tsx b/frontend/libs/components/settings-modal/src/lib/panes/BillingSettingsPane.tsx index 3c509e65b1..4272e53040 100644 --- a/frontend/libs/components/settings-modal/src/lib/panes/BillingSettingsPane.tsx +++ b/frontend/libs/components/settings-modal/src/lib/panes/BillingSettingsPane.tsx @@ -26,7 +26,6 @@ export const BillingSettingsPane = (args: BillingSettingsPaneProps) => { const creditsStore = useCreditsState(); const sumTotalCredits = creditsStore.totalCredits; - //const sumTotalCredits = 100; //const subscriptionStore = useSubscriptionState(); diff --git a/frontend/libs/state/credits/src/lib/state/credits-state.ts b/frontend/libs/state/credits/src/lib/state/credits-state.ts index 67ca3a8948..a6b5e352a7 100644 --- a/frontend/libs/state/credits/src/lib/state/credits-state.ts +++ b/frontend/libs/state/credits/src/lib/state/credits-state.ts @@ -18,7 +18,7 @@ export interface CreditsState { fetchFromServer: () => Promise } -export const useCreditsState = create()((set) => ({ +export const useCreditsState = create((set) => ({ freeCredits: 0, monthlyCredits: 0, bankedCredits: 0, diff --git a/frontend/libs/state/subscription/src/lib/subscription-state.ts b/frontend/libs/state/subscription/src/lib/subscription-state.ts index 375d09283b..97739f74f3 100644 --- a/frontend/libs/state/subscription/src/lib/subscription-state.ts +++ b/frontend/libs/state/subscription/src/lib/subscription-state.ts @@ -4,17 +4,6 @@ import { ArtcraftGetSubscription } from "@storyteller/tauri-api"; export interface SubscriptionState { /// If the user doesn't have a subscription, this will be undefined. subscriptionInfo?: SubscriptionInfo, - - // Returns true if the user has a paid plan. - // (We do not store "free" as a plan.) - hasPaidPlan: () => boolean; - - // Returns true if the user can cancel their plan. - // (The user can't cancel an already set to cancel/expire plan again) - canCancelPlan: () => boolean; - - // Call to fetch credits from the server - fetchFromServer: () => Promise } interface SubscriptionInfo { @@ -35,7 +24,20 @@ interface SubscriptionInfo { subscriptionEndAt?: Date, } -export const useSubscriptionState = create()((set, get) => ({ +export type SubscriptionActions = { + // Returns true if the user has a paid plan. + // (We do not store "free" as a plan.) + hasPaidPlan: () => boolean; + + // Returns true if the user can cancel their plan. + // (The user can't cancel an already set to cancel/expire plan again) + canCancelPlan: () => boolean; + + // Call to fetch credits from the server + fetchFromServer: () => Promise +}; + +export const useSubscriptionState = create((set, get) => ({ subscriptionInfo: undefined, // Returns true if the user has a paid plan.