import { useParams, useNavigate } from 'react-router'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { adminRemnawaveApi, SquadWithLocalInfo } from '../api/adminRemnawave'; import { AdminBackButton } from '../components/admin'; import { ServerIcon, UsersIcon, CheckIcon, XIcon } from '../components/icons'; import Twemoji from 'react-twemoji'; // Country flags helper const getCountryFlag = (code: string | null | undefined): string => { if (!code) return '🌍'; const codeMap: Record = { RU: '🇷🇺', US: '🇺🇸', DE: '🇩🇪', NL: '🇳🇱', GB: '🇬🇧', UK: '🇬🇧', FR: '🇫🇷', FI: '🇫🇮', SE: '🇸🇪', NO: '🇳🇴', PL: '🇵🇱', TR: '🇹🇷', JP: '🇯🇵', SG: '🇸🇬', HK: '🇭🇰', KR: '🇰🇷', AU: '🇦🇺', CA: '🇨🇦', CH: '🇨🇭', AT: '🇦🇹', IT: '🇮🇹', ES: '🇪🇸', BR: '🇧🇷', IN: '🇮🇳', AE: '🇦🇪', IL: '🇮🇱', KZ: '🇰🇿', UA: '🇺🇦', CZ: '🇨🇿', RO: '🇷🇴', LV: '🇱🇻', LT: '🇱🇹', EE: '🇪🇪', BG: '🇧🇬', HU: '🇭🇺', MD: '🇲🇩', }; return codeMap[code.toUpperCase()] || code; }; export default function AdminRemnawaveSquadDetail() { const { t } = useTranslation(); const { uuid } = useParams<{ uuid: string }>(); const navigate = useNavigate(); // Fetch all squads and find the one we need const { data: squadsData, isLoading, error, } = useQuery({ queryKey: ['admin-remnawave-squads'], queryFn: adminRemnawaveApi.getSquads, }); const squad: SquadWithLocalInfo | undefined = squadsData?.items?.find( (s: SquadWithLocalInfo) => s.uuid === uuid, ); if (isLoading) { return (
); } if (error || !squad) { return (

{t('admin.remnawave.squads.detail', 'Squad Details')}

{t('admin.remnawave.squads.loadError', 'Failed to load squad')}

); } return (
{/* Header */}
{getCountryFlag(squad.country_code)}

{squad.display_name || squad.name}

{squad.name}

{squad.is_synced ? ( {t('admin.remnawave.squads.synced', 'Synced')} ) : ( {t('admin.remnawave.squads.notSynced', 'Not synced')} )}
{/* Main Info */}

{t('admin.remnawave.squads.info', 'Information')}

UUID

{squad.uuid}

{t('admin.remnawave.squads.originalName', 'Original Name')}

{squad.name}

{t('admin.remnawave.squads.countryCode', 'Country')}

{getCountryFlag(squad.country_code)} {squad.country_code || '—'}

{/* Stats */}

{t('admin.remnawave.squads.statsTitle', 'Statistics')}

{t('admin.remnawave.squads.members', 'Members')}

{squad.members_count}

{t('admin.remnawave.squads.inbounds', 'Inbounds')}

{squad.inbounds_count}

{squad.is_synced && ( <>
{t('admin.remnawave.squads.users', 'Users')}

{squad.current_users ?? 0} {' '} / {squad.max_users ?? '∞'}

{t('admin.remnawave.squads.price', 'Price')}

{((squad.price_kopeks ?? 0) / 100).toFixed(0)} ₽

)}
{/* Local Settings (if synced) */} {squad.is_synced && (

{t('admin.remnawave.squads.localSettings', 'Local Settings')}

{squad.is_available ? : }

{t('admin.remnawave.squads.available', 'Available')}

{squad.is_available ? t('common.yes', 'Yes') : t('common.no', 'No')}

{squad.is_trial_eligible ? : }

{t('admin.remnawave.squads.trialEligible', 'Trial Eligible')}

{squad.is_trial_eligible ? t('common.yes', 'Yes') : t('common.no', 'No')}

)} {/* Inbounds */} {squad.inbounds.length > 0 && (

{t('admin.remnawave.squads.inboundsList', 'Inbounds')}

{squad.inbounds.map((inbound: Record, idx) => (
{String(inbound.tag || inbound.uuid || `Inbound ${idx + 1}`)} {typeof inbound.type === 'string' && ( {inbound.type} )}
))}
)} {/* Footer */}
); }