managarten/apps-archived/memoro/apps/mobile/features/migration/hooks/useCurrentSubscription.ts
Till-JS 61d181fbc2 chore: archive inactive projects to apps-archived/
Move inactive projects out of active workspace:
- bauntown (community website)
- maerchenzauber (AI story generation)
- memoro (voice memo app)
- news (news aggregation)
- nutriphi (nutrition tracking)
- reader (reading app)
- uload (URL shortener)
- wisekeep (AI wisdom extraction)

Update CLAUDE.md documentation:
- Add presi to active projects
- Document archived projects section
- Update workspace configuration

Archived apps can be re-activated by moving back to apps/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:03:59 +01:00

55 lines
1.7 KiB
TypeScript

import { useState, useEffect } from 'react';
import { Platform } from 'react-native';
import { getCustomerInfo } from '~/features/subscription/subscriptionService';
export const useCurrentSubscription = () => {
const [subscriptionInfo, setSubscriptionInfo] = useState<string>('Free User');
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const fetchSubscription = async () => {
try {
if (Platform.OS === 'web') {
setSubscriptionInfo('Web User');
return;
}
const customerInfo = await getCustomerInfo();
// Check for active entitlements
if (customerInfo?.entitlements?.active) {
const activeEntitlements = Object.keys(customerInfo.entitlements.active);
if (activeEntitlements.length > 0) {
// Get the first active entitlement
const entitlement = customerInfo.entitlements.active[activeEntitlements[0]];
const productId = entitlement.productIdentifier;
// Map product IDs to friendly names
if (productId.includes('pro')) {
setSubscriptionInfo('Pro');
} else if (productId.includes('premium')) {
setSubscriptionInfo('Premium');
} else if (productId.includes('team')) {
setSubscriptionInfo('Team');
} else if (productId.includes('enterprise')) {
setSubscriptionInfo('Enterprise');
} else {
setSubscriptionInfo('Active Subscription');
}
} else {
setSubscriptionInfo('Free User');
}
}
} catch (error) {
console.log('Error fetching subscription:', error);
setSubscriptionInfo('Free User');
} finally {
setIsLoading(false);
}
};
fetchSubscription();
}, []);
return { subscriptionInfo, isLoading };
};