diff options
| author | MaheshtheDev <[email protected]> | 2025-11-10 20:47:00 +0000 |
|---|---|---|
| committer | MaheshtheDev <[email protected]> | 2025-11-10 20:47:00 +0000 |
| commit | 2ed7ba8808334d593dde684f4ac3235aeedfb2cd (patch) | |
| tree | ea4863a7b442006477c868580180356dbe6f9a4f /packages | |
| parent | Fix excessive icon refetch made by importing bookmarks (#496) (diff) | |
| download | supermemory-2ed7ba8808334d593dde684f4ac3235aeedfb2cd.tar.xz supermemory-2ed7ba8808334d593dde684f4ac3235aeedfb2cd.zip | |
fix: past due pending users improvements (#572)11-10-fix_past_due_pending_users_improvements
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/lib/queries.ts | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/packages/lib/queries.ts b/packages/lib/queries.ts index 23084d33..254b3bc9 100644 --- a/packages/lib/queries.ts +++ b/packages/lib/queries.ts @@ -14,10 +14,11 @@ export const fetchSubscriptionStatus = ( ) => useQuery({ queryFn: async () => { - const allPlans = [ - "consumer_pro", - ] - const statusMap: Record<string, boolean | null> = {} + const allPlans = ["consumer_pro"] + const statusMap: Record< + string, + { allowed: boolean; status: string | null } + > = {} await Promise.all( allPlans.map(async (plan) => { @@ -25,10 +26,20 @@ export const fetchSubscriptionStatus = ( const res = autumn.check({ productId: plan, }) - statusMap[plan] = res.data?.allowed ?? false + const allowed = res.data?.allowed ?? false + + const product = autumn.customer?.products?.find( + (p) => p.id === plan, + ) + const productStatus = product?.status ?? null + + statusMap[plan] = { + allowed, + status: productStatus, + } } catch (error) { console.error(`Error checking status for ${plan}:`, error) - statusMap[plan] = false + statusMap[plan] = { allowed: false, status: null } } }), ) @@ -42,7 +53,10 @@ export const fetchSubscriptionStatus = ( }) // Feature checks -export const fetchMemoriesFeature = (autumn: ReturnType<typeof useCustomer>, isEnabled: boolean) => +export const fetchMemoriesFeature = ( + autumn: ReturnType<typeof useCustomer>, + isEnabled: boolean, +) => useQuery({ queryFn: async () => { const res = autumn.check({ featureId: "memories" }) |