diff --git a/src/components/subscription/DeviceManager.tsx b/src/components/subscription/DeviceManager.tsx new file mode 100644 index 0000000..7b896ca --- /dev/null +++ b/src/components/subscription/DeviceManager.tsx @@ -0,0 +1,490 @@ +import { useState, useEffect, useCallback } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { subscriptionApi } from '@/api/subscription'; +import { useCurrency } from '@/hooks/useCurrency'; +import { useHaptic } from '@/platform'; +import InsufficientBalancePrompt from '@/components/InsufficientBalancePrompt'; +import { getGlassColors } from '@/utils/glassTheme'; +import { getErrorMessage } from '@/utils/subscriptionHelpers'; + +// ─── Types ─── + +interface DeviceManagerProps { + subscription: { + device_limit: number; + is_active: boolean; + is_trial: boolean; + }; + balanceKopeks: number; + isDark: boolean; + accentColor: string; + onClose: () => void; +} + +// ─── DotStepSelector ─── + +interface DotStepSelectorProps { + min: number; + max: number; + current: number; + selected: number; + connectedCount: number; + onChange: (value: number) => void; + accentColor: string; + isDark: boolean; +} + +function DotStepSelector({ + min, + max, + current, + selected, + connectedCount, + onChange, + accentColor, + isDark, +}: DotStepSelectorProps) { + const total = max - min + 1; + + if (total <= 0) return null; + + // For large ranges (>15), show a compact slider-like view + if (total > 15) { + return ( +