import { useState } from 'react'; import { useUser } from '@/react/hooks/useUser'; import { UploadLicenseDialog } from './UploadLicenseDialog'; import { LoadingDialog } from './LoadingDialog'; import { NonAdminUpgradeDialog } from './NonAdminUpgradeDialog'; import { GetLicenseDialog } from './GetLicenseDialog'; type Step = 'uploadLicense' | 'loading' | 'getLicense'; export function UpgradeDialog({ onDismiss }: { onDismiss: () => void }) { const { isAdmin } = useUser(); const [currentStep, setCurrentStep] = useState('uploadLicense'); const [isGetLicenseSubmitted, setIsGetLicenseSubmitted] = useState(false); const component = getDialog(); return component; function getDialog() { if (!isAdmin) { return ; } switch (currentStep) { case 'getLicense': return ( { setCurrentStep('uploadLicense'); setIsGetLicenseSubmitted(isSubmitted); }} onDismiss={onDismiss} /> ); case 'uploadLicense': return ( setCurrentStep('loading')} onDismiss={onDismiss} goToGetLicense={() => setCurrentStep('getLicense')} isGetLicenseSubmitted={isGetLicenseSubmitted} /> ); case 'loading': return ; default: throw new Error('step type not found'); } } }