import { Fragment } from 'react' import { Dialog, Transition } from '@headlessui/react' import { IconX, IconCheck, IconInfoCircle } from '@tabler/icons-react' import { CuratedCategory, CategoryTier, CategoryResource } from '../../types/downloads' import { formatBytes } from '~/lib/util' import classNames from 'classnames' import DynamicIcon, { DynamicIconName } from './DynamicIcon' interface TierSelectionModalProps { isOpen: boolean onClose: () => void category: CuratedCategory | null selectedTierSlug?: string | null onSelectTier: (category: CuratedCategory, tier: CategoryTier) => void } const TierSelectionModal: React.FC = ({ isOpen, onClose, category, selectedTierSlug, onSelectTier, }) => { if (!category) return null // Get all resources for a tier (including inherited resources) const getAllResourcesForTier = (tier: CategoryTier): CategoryResource[] => { const resources = [...tier.resources] if (tier.includesTier) { const includedTier = category.tiers.find(t => t.slug === tier.includesTier) if (includedTier) { resources.unshift(...getAllResourcesForTier(includedTier)) } } return resources } const getTierTotalSize = (tier: CategoryTier): number => { return getAllResourcesForTier(tier).reduce((acc, r) => acc + r.size_mb * 1024 * 1024, 0) } return (
{/* Header */}
{category.name}

{category.description}

{/* Content */}

Select a tier based on your storage capacity and needs. Higher tiers include all content from lower tiers.

{category.tiers.map((tier, index) => { const allResources = getAllResourcesForTier(tier) const totalSize = getTierTotalSize(tier) const isSelected = selectedTierSlug === tier.slug return (
onSelectTier(category, tier)} className={classNames( 'border-2 rounded-lg p-5 cursor-pointer transition-all', isSelected ? 'border-desert-green bg-desert-green/5 shadow-md' : 'border-gray-200 hover:border-desert-green/50 hover:shadow-sm', tier.recommended && !isSelected && 'border-lime-500/50' )} >

{tier.name}

{tier.recommended && ( Recommended )} {tier.includesTier && ( (includes {category.tiers.find(t => t.slug === tier.includesTier)?.name}) )}

{tier.description}

{/* Resources preview */}

{allResources.length} resources included:

{allResources.map((resource, idx) => (
{resource.title} ({formatBytes(resource.size_mb * 1024 * 1024, 0)})
))}
{formatBytes(totalSize, 1)}
{isSelected && }
) })}
{/* Info note */}

You can change your selection at any time. Downloads will begin when you complete the setup wizard.

{/* Footer */}
) } export default TierSelectionModal