'use client'; import * as React from 'react'; import { Star } from 'lucide-react'; import * as Badge from '@/components/ui/badge'; import * as Button from '@/components/ui/button'; import * as Radio from '@/components/ui/radio'; import * as SegmentedControl from '@/components/ui/segmented-control'; const PLAN_LABELS = { MOST_POPULAR: 'Most Popular', CURRENT: 'Current', BUSINESS: 'Business', } as const; type PlanLabel = (typeof PLAN_LABELS)[keyof typeof PLAN_LABELS]; const plans: Record< 'monthly' | 'yearly', Record< StorageSize, { price: number; description: string; label: PlanLabel; } > > = { monthly: { '100gb': { price: 8, description: 'Basic file storage', label: PLAN_LABELS.CURRENT, }, '1tb': { price: 15, description: 'Advanced file storage', label: PLAN_LABELS.MOST_POPULAR, }, '5tb': { price: 30, description: 'Enterprise-grade storage', label: PLAN_LABELS.BUSINESS, }, }, yearly: { '100gb': { price: 48, description: 'Basic file storage', label: PLAN_LABELS.CURRENT, }, '1tb': { price: 80, description: 'Advanced file storage', label: PLAN_LABELS.MOST_POPULAR, }, '5tb': { price: 180, description: 'Enterprise-grade storage', label: PLAN_LABELS.BUSINESS, }, }, }; type StorageSize = '100gb' | '1tb' | '5tb'; const storageLabels: Record = { '100gb': '100GB Storage', '1tb': '1TB Storage', '5tb': '5TB Storage', }; const planBadgeConfig: Record< PlanLabel, { icon?: React.ComponentType; color?: 'blue' } | null > = { [PLAN_LABELS.MOST_POPULAR]: { icon: Star, color: 'blue' }, [PLAN_LABELS.CURRENT]: {}, [PLAN_LABELS.BUSINESS]: null, }; const PlanBadge = ({ label }: { label: PlanLabel }) => { if (label === PLAN_LABELS.BUSINESS) { return ({label}); } const config = planBadgeConfig[label]; return ( {config?.icon && } {label} ); }; export default function StoragePlanSelector() { const [billingType, setBillingType] = React.useState<'monthly' | 'yearly'>( 'yearly', ); const [selectedPlan, setSelectedPlan] = React.useState('1tb'); return (
{/* Left Section */}

Choose storage plan

setBillingType(value as 'monthly' | 'yearly') } > Monthly Yearly
setSelectedPlan(value as StorageSize)} className='flex w-full flex-col gap-3.5' > {Object.entries(plans[billingType]).map(([size, plan]) => (
setSelectedPlan(size as StorageSize)} className={`cursor-pointer rounded-2xl border px-6 py-3.5 transition-all duration-200 ease-in-out ${ selectedPlan === size ? 'bg-primary-lighter border-primary-base' : 'hover:bg-bg-soft-50 border-stroke-soft-200' }`} >
{storageLabels[size as StorageSize]} {plan.label && }
{plan.description}
${plans[billingType][size as StorageSize].price} per{' '} {billingType === 'monthly' ? 'month' : 'year'}
))}
{/* Right Section */}

Summary

Current plan $8 per month
New plan ${plans[billingType][selectedPlan].price} per {billingType}
Total ${plans[billingType][selectedPlan].price} per {billingType}
Cancel Change plan
); }