import { useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react' import { Button } from '@/components/ui/button' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' import { Section, InfoRow } from '@/components/viewPageComponents' import { useBranchById, useDeleteBranch } from '@/features/branches/hooks/useBranches' export function BranchViewPage() { const { id } = useParams<{ id: string }>() const navigate = useNavigate() const { t, i18n } = useTranslation() const numericId = Number(id) const lang = (i18n.language?.slice(0, 2) ?? 'tk') as 'tk' | 'ru' | 'en' const { data, isLoading } = useBranchById(numericId) const deleteMutation = useDeleteBranch() const [deleteOpen, setDeleteOpen] = useState(false) return (

{isLoading ? '...' : `${t('branches.view.title', 'Şahamça giňişleýin')}: ${data?.name[lang] ?? ''}`}

{isLoading ? (
{Array.from({ length: 6 }).map((_, i) => (
))}
) : data ? ( <>
{t('branches.fields.name', 'Ady')}
{(['tk', 'ru', 'en'] as const).map((l) => ( {l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'} ))}
{data.name[lang]}
{t('branches.fields.isActive', 'Işjeň')} {data.isActive ? ( ) : ( )}
{t('branches.fields.address', 'Salgy')}
{(['tk', 'ru', 'en'] as const).map((l) => ( {l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'} ))}
{data.address[lang]}
) : (

{t('common.noData', 'Maglumat ýok')}

)} {t('common.confirmDelete', 'Öçürmegi tassyklaň')} {t('branches.deleteConfirm', 'Bu şahamçany öçürmek isleýärsiňizmi?')} {t('common.cancel', 'Ýatyr')} deleteMutation.mutate(numericId, { onSuccess: () => navigate('/settings/location/branches'), }) } > {deleteMutation.isPending ? t('common.deleting', 'Öçürilýär...') : t('common.delete', 'Öçürmek')}
) } export default BranchViewPage