'use client'; import * as React from 'react'; import { Plus, AlertTriangle, Wand2, Minus } from 'lucide-react'; import * as Alert from '@/components/ui/alert'; import * as Avatar from '@/components/ui/avatar'; import * as Badge from '@/components/ui/badge'; import * as Button from '@/components/ui/button'; import * as CompactButton from '@/components/ui/compact-button'; import * as Input from '@/components/ui/input'; import * as Label from '@/components/ui/label'; import * as Select from '@/components/ui/select'; import * as Slider from '@/components/ui/slider'; export function ResponsiveSlider() { const [storageUnits, setStorageUnits] = React.useState(1); const [sliderValue, setSliderValue] = React.useState(0); const [billingPeriod, setBillingPeriod] = React.useState('annually'); const [email, setEmail] = React.useState('james@alignui.com'); const [companyName, setCompanyName] = React.useState('APEX INC'); const prices = { enterprisePlan: 479.88, storageUnit: 287.9, monthlyRate: 39.99, annualUserPrice: 59.0, monthlyUserPrice: 69.0, }; const storageSteps = [ { value: 0, label: '0TB' }, { value: 16, label: '1TB' }, { value: 30, label: '5TB' }, { value: 46, label: '10TB' }, { value: 63, label: '25TB' }, { value: 80, label: '50TB' }, { value: 100, label: '100TB' }, ]; const snapToClosestStep = (val: number) => { let closest = storageSteps[0]?.value ?? 0; let minDiff = Math.abs(val - closest); for (let i = 1; i < storageSteps.length; i++) { const diff = Math.abs(val - (storageSteps[i]?.value ?? 0)); if (diff < minDiff) { minDiff = diff; closest = storageSteps[i]?.value ?? 0; } } return closest; }; const getActiveStep = (currentValue: number) => { const idx = storageSteps.findIndex((step) => step.value === currentValue); return idx >= 0 && idx < storageSteps.length ? idx : 0; }; const calculateStoragePrice = (sliderValue: number) => { const tbIndex = getActiveStep(sliderValue); const tbValue = storageSteps[tbIndex]?.label ?? '0TB'; const tbAmount = parseInt(tbValue.replace('TB', '')) || 0; return tbAmount * prices.monthlyRate; }; const calculateTotalPrice = () => { const storagePrice = calculateStoragePrice(sliderValue); const unitsPrice = prices.storageUnit * storageUnits; const baseUserPrice = billingPeriod === 'annually' ? prices.annualUserPrice : prices.monthlyUserPrice; const basePrice = baseUserPrice * 12; const subtotal = basePrice + unitsPrice + storagePrice; const discount = billingPeriod === 'annually' ? 0.85 : 1; const discountedSubtotal = subtotal * discount; return { subtotal: discountedSubtotal, total: discountedSubtotal * 1.18, storagePrice, unitsPrice, basePrice: basePrice * discount, }; }; const priceDetails = calculateTotalPrice(); return (

Upgrade to enterprise

View plans
Billing period {billingPeriod === 'annually' && ( %15 off )} Annually - $59.00 / user / month Monthly - $69.00 / user / month
Storage units

Storage capacity

setStorageUnits((prev) => Math.max(1, prev - 1)) } className='hover:bg-bg-weak-100 border-stroke-soft-200 bg-bg-weak-50 flex size-7 items-center justify-center rounded-none border-0' >
{storageUnits}
setStorageUnits((prev) => prev + 1)} className='hover:bg-bg-soft-50 border-stroke-soft-200 bg-bg-weak-50 flex size-7 items-center justify-center rounded-none border-0' >

Select storage units for your organization

Minimum storage requirement is 1TB for Enterprise plans
Storage plan

Enterprise storage

500GB included + 5TB /month

${prices.monthlyRate} / month
{ const snapped = snapToClosestStep(value[0] ?? 0); setSliderValue(snapped); }} >
{storageSteps.map((step, index) => ( {step.label} ))}
Company details
setEmail(e.target.value)} placeholder='Email' /> setCompanyName(e.target.value)} placeholder='Company name' />

Summary

1× Enterprise Plan 5TB ${priceDetails.basePrice.toFixed(2)}
{storageUnits}× Storage Unit(s) ${priceDetails.unitsPrice.toFixed(2)}
Storage Plan ( {storageSteps[getActiveStep(sliderValue)]?.label ?? '0TB'}) ${priceDetails.storagePrice.toFixed(2)}
Subtotal ${priceDetails.subtotal.toFixed(2)}
Total at renewal ${priceDetails.total.toFixed(2)}
Due now ${priceDetails.total.toFixed(2)}
Upgrade now
Plan activates upon payment.
); } export default function EnterprisePlanSlider() { return ; }