Fix type errors

This commit is contained in:
Connor Yoh 2025-11-18 16:03:36 +00:00
parent a17edaedea
commit 94a8c31f92
3 changed files with 12 additions and 23 deletions

View File

@ -5,8 +5,7 @@ import { usePlans } from '@app/hooks/usePlans';
import licenseService, { PlanTierGroup, LicenseInfo } from '@app/services/licenseService';
import { useCheckout } from '@app/contexts/CheckoutContext';
import AvailablePlansSection from '@app/components/shared/config/configSections/plan/AvailablePlansSection';
import ActivePlanSection from '@app/components/shared/config/configSections/plan//ActivePlanSection';
import StaticPlanSection from '@app/components/shared/config/configSections/plan//StaticPlanSection';
import StaticPlanSection from '@app/components/shared/config/configSections/plan/StaticPlanSection';
import { useAppConfig } from '@app/contexts/AppConfigContext';
import { alert } from '@app/components/toast';
import LocalIcon from '@app/components/shared/LocalIcon';
@ -98,6 +97,11 @@ const AdminPlanSection: React.FC = () => {
const handleUpgradeClick = useCallback(
(planGroup: PlanTierGroup) => {
// Only allow upgrades for server and enterprise tiers
if (planGroup.tier === 'free') {
return;
}
// Use checkout context to open checkout modal
openCheckout(planGroup.tier, {
currency,
@ -121,7 +125,7 @@ const AdminPlanSection: React.FC = () => {
// Show static version if Stripe is not configured or there's an error
if (useStaticVersion) {
return <StaticPlanSection currentLicenseInfo={currentLicenseInfo} />;
return <StaticPlanSection currentLicenseInfo={currentLicenseInfo ?? undefined} />;
}
// Early returns after all hooks are called
@ -135,7 +139,7 @@ const AdminPlanSection: React.FC = () => {
if (error) {
// Fallback to static version on error
return <StaticPlanSection currentLicenseInfo={currentLicenseInfo} />;
return <StaticPlanSection currentLicenseInfo={currentLicenseInfo ?? undefined} />;
}
if (!plans || plans.length === 0) {

View File

@ -7,6 +7,7 @@ import { useRestartServer } from '@app/components/shared/config/useRestartServer
import { useAdminSettings } from '@app/hooks/useAdminSettings';
import PendingBadge from '@app/components/shared/config/PendingBadge';
import { alert } from '@app/components/toast';
import { LicenseInfo } from '@app/services/licenseService';
interface PremiumSettingsData {
key?: string;
@ -14,11 +15,7 @@ interface PremiumSettingsData {
}
interface StaticPlanSectionProps {
currentLicenseInfo?: {
planName: string;
maxUsers: number;
grandfathered: boolean;
};
currentLicenseInfo?: LicenseInfo;
}
const StaticPlanSection: React.FC<StaticPlanSectionProps> = ({ currentLicenseInfo }) => {
@ -122,7 +119,7 @@ const StaticPlanSection: React.FC<StaticPlanSectionProps> = ({ currentLicenseInf
const getCurrentPlan = () => {
if (!currentLicenseInfo) return staticPlans[0];
if (currentLicenseInfo.planName === 'Enterprise') return staticPlans[2];
if (currentLicenseInfo.licenseType === 'ENTERPRISE') return staticPlans[2];
if (currentLicenseInfo.maxUsers > 5) return staticPlans[1];
return staticPlans[0];
};
@ -160,8 +157,6 @@ const StaticPlanSection: React.FC<StaticPlanSectionProps> = ({ currentLicenseInf
{currentLicenseInfo && (
<Text size="sm" c="dimmed">
{t('plan.static.maxUsers', 'Max Users')}: {currentLicenseInfo.maxUsers}
{currentLicenseInfo.grandfathered &&
` (${t('workspace.people.license.grandfathered', 'Grandfathered')})`}
</Text>
)}
</Stack>

View File

@ -284,8 +284,7 @@ const licenseService = {
const allPlans = [freePlan, ...validPlans];
return {
plans: allPlans,
currentSubscription: null // Will be implemented later
plans: allPlans
};
} catch (error) {
console.error('Error fetching plans:', error);
@ -293,15 +292,6 @@ const licenseService = {
}
},
/**
* Get current subscription details
* TODO: Implement with Supabase edge function when available
*/
async getCurrentSubscription(): Promise<SubscriptionInfo | null> {
// Placeholder - will be implemented later
return null;
},
/**
* Group plans by tier for display (Free, Server, Enterprise)
*/