import React, { useState, useEffect } from 'react';
import {
  Box,
  Button,
  Container,
  Heading,
  HStack,
  VStack,
  Table,
  Thead,
  Tbody,
  Tr,
  Th,
  Td,
  Badge,
  IconButton,
  useDisclosure,
  Modal,
  ModalOverlay,
  ModalContent,
  ModalHeader,
  ModalFooter,
  ModalBody,
  ModalCloseButton,
  FormControl,
  FormLabel,
  Input,
  Textarea,
  Select,
  Switch,
  useToast,
  Spinner,
  Text,
  Alert,
  AlertIcon,
  Tabs,
  TabList,
  TabPanels,
  Tab,
  TabPanel,
  NumberInput,
  NumberInputField,
  NumberInputStepper,
  NumberIncrementStepper,
  NumberDecrementStepper,
  Menu,
  MenuButton,
  MenuList,
  MenuItem,
  Stat,
  StatLabel,
  StatNumber,
  StatHelpText,
  SimpleGrid,
  Card,
  CardBody,
  Image,
  AspectRatio,
} from '@chakra-ui/react';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { AddIcon, EditIcon, DeleteIcon, ChevronDownIcon, ViewIcon, CheckIcon, CloseIcon } from '@chakra-ui/icons';
import AdminLayout from '../../layouts/AdminLayout';
import {
  getAdminPolls,
  createPoll,
  updatePoll,
  deletePoll,
  getPollStats,
  Poll,
  CreatePollRequest,
  UpdatePollRequest,
  PollStats,
} from '../../services/polls';
import { getCachedYouTube, YouTubeVideo } from '../../services/youtube';

const PollsAdminPage: React.FC = () => {
  const toast = useToast();
  const queryClient = useQueryClient();
  const { isOpen, onOpen, onClose } = useDisclosure();
  const { isOpen: isStatsOpen, onOpen: onStatsOpen, onClose: onStatsClose } = useDisclosure();
  
  const [statusFilter, setStatusFilter] = useState<string>('');
  const [editingPoll, setEditingPoll] = useState<Poll | null>(null);
  const [selectedPollStats, setSelectedPollStats] = useState<PollStats | null>(null);
  
  // Video selector state
  const [clubVideos, setClubVideos] = useState<YouTubeVideo[]>([]);
  const [loadingVideos, setLoadingVideos] = useState(false);
  
  // Form state
  const [formData, setFormData] = useState<CreatePollRequest>({
    title: '',
    description: '',
    type: 'single',
    status: 'draft',
    allow_multiple: false,
    max_choices: 1,
    show_results: 'after_vote',
    require_auth: false,
    allow_guest_vote: true,
    featured: false,
    options: [
      { text: '', display_order: 0 },
      { text: '', display_order: 1 },
    ],
  });

  // Fetch polls
  const { data: polls, isLoading } = useQuery({
    queryKey: ['admin-polls', statusFilter],
    queryFn: () => getAdminPolls(statusFilter ? { status: statusFilter } : undefined),
  });

  // Create mutation
  const createMutation = useMutation({
    mutationFn: createPoll,
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['admin-polls'] });
      toast({
        title: 'Anketa vytvořena',
        status: 'success',
        duration: 3000,
      });
      onClose();
      resetForm();
    },
    onError: (error: any) => {
      toast({
        title: 'Chyba',
        description: error.response?.data?.error || 'Nepodařilo se vytvořit anketu',
        status: 'error',
        duration: 5000,
      });
    },
  });

  // Update mutation
  const updateMutation = useMutation({
    mutationFn: ({ id, data }: { id: number; data: UpdatePollRequest }) =>
      updatePoll(id, data),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['admin-polls'] });
      toast({
        title: 'Anketa aktualizována',
        status: 'success',
        duration: 3000,
      });
      onClose();
      resetForm();
    },
    onError: (error: any) => {
      toast({
        title: 'Chyba',
        description: error.response?.data?.error || 'Nepodařilo se aktualizovat anketu',
        status: 'error',
        duration: 5000,
      });
    },
  });

  // Delete mutation
  const deleteMutation = useMutation({
    mutationFn: deletePoll,
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['admin-polls'] });
      toast({
        title: 'Anketa smazána',
        status: 'success',
        duration: 3000,
      });
    },
    onError: (error: any) => {
      toast({
        title: 'Chyba',
        description: error.response?.data?.error || 'Nepodařilo se smazat anketu',
        status: 'error',
        duration: 5000,
      });
    },
  });

  // Stats query
  const { data: statsData, isLoading: isLoadingStats } = useQuery({
    queryKey: ['poll-stats', selectedPollStats?.poll?.id],
    queryFn: () => getPollStats(selectedPollStats!.poll.id),
    enabled: !!selectedPollStats?.poll?.id,
  });

  const resetForm = () => {
    setFormData({
      title: '',
      description: '',
      type: 'single',
      status: 'draft',
      allow_multiple: false,
      max_choices: 1,
      show_results: 'after_vote',
      require_auth: false,
      allow_guest_vote: true,
      featured: false,
      options: [
        { text: '', display_order: 0 },
        { text: '', display_order: 1 },
      ],
    });
    setEditingPoll(null);
  };

  const handleOpenCreate = () => {
    resetForm();
    onOpen();
  };

  const handleOpenEdit = (poll: Poll) => {
    setEditingPoll(poll);
    setFormData({
      title: poll.title,
      description: poll.description,
      type: poll.type,
      status: poll.status,
      start_date: poll.start_date,
      end_date: poll.end_date,
      allow_multiple: poll.allow_multiple,
      max_choices: poll.max_choices,
      show_results: poll.show_results,
      require_auth: poll.require_auth,
      allow_guest_vote: poll.allow_guest_vote,
      featured: poll.featured,
      category_id: poll.category_id,
      related_match_id: poll.related_match_id,
      related_article_id: poll.related_article_id,
      related_event_id: poll.related_event_id,
      related_video_url: poll.related_video_url,
      image_url: poll.image_url,
      options: poll.options.map(opt => ({
        text: opt.text,
        description: opt.description,
        image_url: opt.image_url,
        display_order: opt.display_order,
        player_id: opt.player_id,
      })),
    });
    onOpen();
  };

  const handleSave = () => {
    // Validate that all options have text
    const invalidOptions = formData.options.filter(opt => !opt.text || opt.text.trim() === '');
    if (invalidOptions.length > 0) {
      toast({
        title: 'Chyba',
        description: 'Všechny možnosti musí mít vyplněný text',
        status: 'error',
        duration: 3000,
      });
      return;
    }

    if (editingPoll) {
      updateMutation.mutate({ id: editingPoll.id, data: formData });
    } else {
      createMutation.mutate(formData);
    }
  };

  const handleDelete = (id: number) => {
    if (window.confirm('Opravdu chcete smazat tuto anketu?')) {
      deleteMutation.mutate(id);
    }
  };

  const handleViewStats = async (poll: Poll) => {
    try {
      const stats = await getPollStats(poll.id);
      setSelectedPollStats(stats);
      onStatsOpen();
    } catch (error: any) {
      toast({
        title: 'Chyba',
        description: 'Nepodařilo se načíst statistiky',
        status: 'error',
        duration: 3000,
      });
    }
  };

  const addOption = () => {
    setFormData({
      ...formData,
      options: [
        ...formData.options,
        { text: '', display_order: formData.options.length },
      ],
    });
  };

  const removeOption = (index: number) => {
    if (formData.options.length > 2) {
      setFormData({
        ...formData,
        options: formData.options.filter((_, i) => i !== index),
      });
    }
  };

  const updateOption = (index: number, field: string, value: any) => {
    const newOptions = [...formData.options];
    newOptions[index] = { ...newOptions[index], [field]: value };
    setFormData({ ...formData, options: newOptions });
  };

  // Load club videos when modal opens
  useEffect(() => {
    if (isOpen && clubVideos.length === 0) {
      setLoadingVideos(true);
      getCachedYouTube()
        .then((data) => {
          if (data?.videos) {
            setClubVideos(data.videos);
          }
        })
        .catch(() => {
          toast({
            title: 'Chyba',
            description: 'Nepodařilo se načíst videa',
            status: 'error',
            duration: 3000,
          });
        })
        .finally(() => {
          setLoadingVideos(false);
        });
    }
  }, [isOpen, clubVideos.length, toast]);

  const getStatusBadge = (status: string) => {
    const colorMap: Record<string, string> = {
      draft: 'gray',
      active: 'green',
      closed: 'orange',
      archived: 'red',
    };
    return <Badge colorScheme={colorMap[status] || 'gray'}>{status}</Badge>;
  };

  if (isLoading) {
    return (
      <AdminLayout>
        <Container maxW="7xl" py={8}>
          <VStack spacing={4}>
            <Spinner size="xl" />
            <Text>Načítání anket...</Text>
          </VStack>
        </Container>
      </AdminLayout>
    );
  }

  return (
    <AdminLayout>
      <Container maxW="7xl" py={8}>
        <VStack spacing={6} align="stretch">
          <HStack justify="space-between">
            <Heading size="lg">Správa anket</Heading>
            <Button leftIcon={<AddIcon />} colorScheme="blue" onClick={handleOpenCreate}>
              Nová anketa
            </Button>
          </HStack>

          <Alert status="info">
            <AlertIcon />
            <Box>
              <Text fontWeight="bold">Ankety a hlasování</Text>
              <Text fontSize="sm">
                Vytvořte interaktivní ankety pro fanoušky - Hráč zápasu, předpověď výsledku, designové ankety a další.
              </Text>
            </Box>
          </Alert>

          <HStack>
            <Select
              value={statusFilter}
              onChange={(e) => setStatusFilter(e.target.value)}
              maxW="200px"
            >
              <option value="">Všechny stavy</option>
              <option value="draft">Koncepty</option>
              <option value="active">Aktivní</option>
              <option value="closed">Uzavřené</option>
              <option value="archived">Archivované</option>
            </Select>
          </HStack>

          <Box overflowX="auto">
            <Table variant="simple">
              <Thead>
                <Tr>
                  <Th>Název</Th>
                  <Th>Typ</Th>
                  <Th>Stav</Th>
                  <Th>Počet hlasů</Th>
                  <Th>Vytvořeno</Th>
                  <Th>Akce</Th>
                </Tr>
              </Thead>
              <Tbody>
                {polls?.map((poll) => (
                  <Tr key={poll.id}>
                    <Td>
                      <VStack align="start" spacing={0}>
                        <Text fontWeight="bold">{poll.title}</Text>
                        {poll.featured && <Badge colorScheme="purple">Zvýrazněná</Badge>}
                      </VStack>
                    </Td>
                    <Td>{poll.type}</Td>
                    <Td>{getStatusBadge(poll.status)}</Td>
                    <Td>{poll.total_votes}</Td>
                    <Td>{new Date(poll.created_at).toLocaleDateString('cs-CZ')}</Td>
                    <Td>
                      <HStack spacing={2}>
                        <IconButton
                          aria-label="Statistiky"
                          icon={<ViewIcon />}
                          size="sm"
                          onClick={() => handleViewStats(poll)}
                        />
                        <IconButton
                          aria-label="Upravit"
                          icon={<EditIcon />}
                          size="sm"
                          onClick={() => handleOpenEdit(poll)}
                        />
                        <IconButton
                          aria-label="Smazat"
                          icon={<DeleteIcon />}
                          size="sm"
                          colorScheme="red"
                          onClick={() => handleDelete(poll.id)}
                        />
                      </HStack>
                    </Td>
                  </Tr>
                ))}
              </Tbody>
            </Table>
          </Box>

          {polls?.length === 0 && (
            <Alert status="info">
              <AlertIcon />
              Zatím nemáte žádné ankety. Vytvořte první anketu pomocí tlačítka výše.
            </Alert>
          )}
        </VStack>

        {/* Create/Edit Modal */}
        <Modal isOpen={isOpen} onClose={onClose} size="4xl">
          <ModalOverlay />
          <ModalContent>
            <ModalHeader>
              {editingPoll ? 'Upravit anketu' : 'Nová anketa'}
            </ModalHeader>
            <ModalCloseButton />
            <ModalBody>
              <Tabs>
                <TabList>
                  <Tab>Základní</Tab>
                  <Tab>Možnosti</Tab>
                  <Tab>Nastavení</Tab>
                </TabList>

                <TabPanels>
                  {/* Basic Info Tab */}
                  <TabPanel>
                    <VStack spacing={4}>
                      <FormControl isRequired>
                        <FormLabel>Název ankety</FormLabel>
                        <Input
                          value={formData.title}
                          onChange={(e) =>
                            setFormData({ ...formData, title: e.target.value })
                          }
                          placeholder="Např. Hráč zápasu"
                        />
                      </FormControl>

                      <FormControl>
                        <FormLabel>Popis</FormLabel>
                        <Textarea
                          value={formData.description}
                          onChange={(e) =>
                            setFormData({ ...formData, description: e.target.value })
                          }
                          placeholder="Volitelný popis ankety"
                        />
                      </FormControl>

                      <SimpleGrid columns={2} spacing={4} w="full">
                        <FormControl>
                          <FormLabel>Typ</FormLabel>
                          <Select
                            value={formData.type}
                            onChange={(e) =>
                              setFormData({ ...formData, type: e.target.value as any })
                            }
                          >
                            <option value="single">Jedna volba</option>
                            <option value="multiple">Více voleb</option>
                            <option value="rating">Hodnocení</option>
                          </Select>
                        </FormControl>

                        <FormControl>
                          <FormLabel>Stav</FormLabel>
                          <Select
                            value={formData.status}
                            onChange={(e) =>
                              setFormData({ ...formData, status: e.target.value as any })
                            }
                          >
                            <option value="draft">Koncept</option>
                            <option value="active">Aktivní</option>
                            <option value="closed">Uzavřená</option>
                            <option value="archived">Archivovaná</option>
                          </Select>
                        </FormControl>
                      </SimpleGrid>

                      <SimpleGrid columns={2} spacing={4} w="full">
                        <FormControl>
                          <FormLabel>Datum zahájení</FormLabel>
                          <Input
                            type="datetime-local"
                            value={formData.start_date || ''}
                            onChange={(e) =>
                              setFormData({ ...formData, start_date: e.target.value })
                            }
                          />
                        </FormControl>

                        <FormControl>
                          <FormLabel>Datum ukončení</FormLabel>
                          <Input
                            type="datetime-local"
                            value={formData.end_date || ''}
                            onChange={(e) =>
                              setFormData({ ...formData, end_date: e.target.value })
                            }
                          />
                        </FormControl>
                      </SimpleGrid>

                      <FormControl>
                        <FormLabel>Video z klubového kanálu (volitelné)</FormLabel>
                        <Text fontSize="sm" color="gray.500" mb={2}>
                          Připojte anketu k videu z vašeho YouTube kanálu
                        </Text>
                        {loadingVideos ? (
                          <HStack>
                            <Spinner size="sm" />
                            <Text fontSize="sm">Načítání videí...</Text>
                          </HStack>
                        ) : clubVideos.length === 0 ? (
                          <Alert status="info" size="sm">
                            <AlertIcon />
                            <Text fontSize="sm">Žádná videa nenalezena. Přidejte videa v Nastavení → Videa.</Text>
                          </Alert>
                        ) : (
                          <VStack spacing={3} align="stretch">
                            <Select
                              value={formData.related_video_url || ''}
                              onChange={(e) =>
                                setFormData({ ...formData, related_video_url: e.target.value })
                              }
                              placeholder="Vyberte video (nebo nechte prázdné)"
                            >
                              {clubVideos.map((video) => (
                                <option 
                                  key={video.video_id} 
                                  value={`https://www.youtube.com/watch?v=${video.video_id}`}
                                >
                                  {video.title} {video.published_text ? `(${video.published_text})` : ''}
                                </option>
                              ))}
                            </Select>
                            {formData.related_video_url && (
                              <Box borderWidth="1px" borderRadius="md" p={2}>
                                <Text fontSize="sm" fontWeight="semibold" mb={2}>Náhled vybraného videa:</Text>
                                {(() => {
                                  const selectedVideo = clubVideos.find(
                                    v => `https://www.youtube.com/watch?v=${v.video_id}` === formData.related_video_url
                                  );
                                  if (selectedVideo) {
                                    return (
                                      <HStack spacing={3}>
                                        <Image 
                                          src={selectedVideo.thumbnail_url} 
                                          alt={selectedVideo.title}
                                          boxSize="120px"
                                          objectFit="cover"
                                          borderRadius="md"
                                        />
                                        <VStack align="start" spacing={1}>
                                          <Text fontSize="sm" fontWeight="medium">{selectedVideo.title}</Text>
                                          {selectedVideo.published_text && (
                                            <Badge size="sm">{selectedVideo.published_text}</Badge>
                                          )}
                                        </VStack>
                                      </HStack>
                                    );
                                  }
                                  return null;
                                })()}
                              </Box>
                            )}
                          </VStack>
                        )}
                        <Text fontSize="xs" color="gray.500" mt={2}>
                          Poznámka: Propojení s články a aktivitami se nastavuje přímo v editoru článku/aktivity.
                        </Text>
                      </FormControl>
                    </VStack>
                  </TabPanel>

                  {/* Options Tab */}
                  <TabPanel>
                    <VStack spacing={4} align="stretch">
                      {formData.options.map((option, index) => (
                        <Card key={index}>
                          <CardBody>
                            <HStack align="start">
                              <VStack flex={1} spacing={3}>
                                <FormControl isRequired>
                                  <FormLabel>Možnost {index + 1}</FormLabel>
                                  <Input
                                    value={option.text}
                                    onChange={(e) =>
                                      updateOption(index, 'text', e.target.value)
                                    }
                                    placeholder="Text možnosti"
                                  />
                                </FormControl>
                                <FormControl>
                                  <FormLabel>Popis (volitelné)</FormLabel>
                                  <Input
                                    value={option.description || ''}
                                    onChange={(e) =>
                                      updateOption(index, 'description', e.target.value)
                                    }
                                    placeholder="Doplňující informace"
                                  />
                                </FormControl>
                              </VStack>
                              {formData.options.length > 2 && (
                                <IconButton
                                  aria-label="Odstranit možnost"
                                  icon={<DeleteIcon />}
                                  colorScheme="red"
                                  variant="ghost"
                                  onClick={() => removeOption(index)}
                                />
                              )}
                            </HStack>
                          </CardBody>
                        </Card>
                      ))}

                      <Button
                        leftIcon={<AddIcon />}
                        onClick={addOption}
                        variant="outline"
                        colorScheme="blue"
                      >
                        Přidat možnost
                      </Button>
                    </VStack>
                  </TabPanel>

                  {/* Settings Tab */}
                  <TabPanel>
                    <VStack spacing={4}>
                      <FormControl display="flex" alignItems="center">
                        <FormLabel mb="0">Povolit více voleb</FormLabel>
                        <Switch
                          isChecked={formData.allow_multiple}
                          onChange={(e) =>
                            setFormData({ ...formData, allow_multiple: e.target.checked })
                          }
                        />
                      </FormControl>

                      {formData.allow_multiple && (
                        <FormControl>
                          <FormLabel>Max. počet voleb</FormLabel>
                          <NumberInput
                            value={formData.max_choices}
                            min={1}
                            max={formData.options.length}
                            onChange={(_, num) =>
                              setFormData({ ...formData, max_choices: num })
                            }
                          >
                            <NumberInputField />
                            <NumberInputStepper>
                              <NumberIncrementStepper />
                              <NumberDecrementStepper />
                            </NumberInputStepper>
                          </NumberInput>
                        </FormControl>
                      )}

                      <FormControl>
                        <FormLabel>Zobrazení výsledků</FormLabel>
                        <Select
                          value={formData.show_results}
                          onChange={(e) =>
                            setFormData({ ...formData, show_results: e.target.value as any })
                          }
                        >
                          <option value="always">Vždy</option>
                          <option value="after_vote">Po hlasování</option>
                          <option value="after_end">Po ukončení</option>
                          <option value="never">Nikdy (pouze admin)</option>
                        </Select>
                      </FormControl>

                      <FormControl display="flex" alignItems="center">
                        <FormLabel mb="0">Vyžadovat přihlášení</FormLabel>
                        <Switch
                          isChecked={formData.require_auth}
                          onChange={(e) =>
                            setFormData({ ...formData, require_auth: e.target.checked })
                          }
                        />
                      </FormControl>

                      <FormControl display="flex" alignItems="center">
                        <FormLabel mb="0">Povolit hlasování hostů</FormLabel>
                        <Switch
                          isChecked={formData.allow_guest_vote}
                          onChange={(e) =>
                            setFormData({ ...formData, allow_guest_vote: e.target.checked })
                          }
                        />
                      </FormControl>

                      <FormControl display="flex" alignItems="center">
                        <FormLabel mb="0">Zvýraznit na hlavní stránce</FormLabel>
                        <Switch
                          isChecked={formData.featured}
                          onChange={(e) =>
                            setFormData({ ...formData, featured: e.target.checked })
                          }
                        />
                      </FormControl>
                    </VStack>
                  </TabPanel>
                </TabPanels>
              </Tabs>
            </ModalBody>

            <ModalFooter>
              <Button variant="ghost" mr={3} onClick={onClose}>
                Zrušit
              </Button>
              <Button
                colorScheme="blue"
                onClick={handleSave}
                isLoading={createMutation.isPending || updateMutation.isPending}
              >
                {editingPoll ? 'Uložit' : 'Vytvořit'}
              </Button>
            </ModalFooter>
          </ModalContent>
        </Modal>

        {/* Stats Modal */}
        <Modal isOpen={isStatsOpen} onClose={onStatsClose} size="4xl">
          <ModalOverlay />
          <ModalContent>
            <ModalHeader>Statistiky ankety</ModalHeader>
            <ModalCloseButton />
            <ModalBody>
              {isLoadingStats ? (
                <VStack py={8}>
                  <Spinner size="xl" />
                  <Text>Načítání statistik...</Text>
                </VStack>
              ) : statsData ? (
                <VStack spacing={6} align="stretch">
                  <SimpleGrid columns={3} spacing={4}>
                    <Stat>
                      <StatLabel>Celkem hlasů</StatLabel>
                      <StatNumber>{statsData.poll.total_votes}</StatNumber>
                    </Stat>
                    <Stat>
                      <StatLabel>Přihlášení uživatelé</StatLabel>
                      <StatNumber>{statsData.authenticated_votes}</StatNumber>
                      <StatHelpText>
                        {statsData.poll.total_votes > 0
                          ? `${Math.round((statsData.authenticated_votes / statsData.poll.total_votes) * 100)}%`
                          : '0%'}
                      </StatHelpText>
                    </Stat>
                    <Stat>
                      <StatLabel>Hosté</StatLabel>
                      <StatNumber>{statsData.guest_votes}</StatNumber>
                      <StatHelpText>
                        {statsData.poll.total_votes > 0
                          ? `${Math.round((statsData.guest_votes / statsData.poll.total_votes) * 100)}%`
                          : '0%'}
                      </StatHelpText>
                    </Stat>
                  </SimpleGrid>

                  <Box>
                    <Heading size="sm" mb={4}>
                      Výsledky
                    </Heading>
                    <VStack spacing={2} align="stretch">
                      {statsData.poll.options.map((option) => {
                        const percentage =
                          statsData.poll.total_votes > 0
                            ? (option.vote_count / statsData.poll.total_votes) * 100
                            : 0;
                        return (
                          <Box key={option.id}>
                            <HStack justify="space-between" mb={1}>
                              <Text fontWeight="medium">{option.text}</Text>
                              <Text fontSize="sm" color="gray.500">
                                {option.vote_count} hlasů ({percentage.toFixed(1)}%)
                              </Text>
                            </HStack>
                            <Box
                              w="full"
                              h="8px"
                              bg="gray.200"
                              borderRadius="full"
                              overflow="hidden"
                            >
                              <Box
                                h="full"
                                bg="blue.500"
                                w={`${percentage}%`}
                                transition="width 0.3s"
                              />
                            </Box>
                          </Box>
                        );
                      })}
                    </VStack>
                  </Box>

                  {statsData.votes_by_day.length > 0 && (
                    <Box>
                      <Heading size="sm" mb={4}>
                        Hlasy podle dnů
                      </Heading>
                      <VStack spacing={2} align="stretch">
                        {statsData.votes_by_day.map((day) => (
                          <HStack key={day.date} justify="space-between">
                            <Text>{new Date(day.date).toLocaleDateString('cs-CZ')}</Text>
                            <Badge>{day.count} hlasů</Badge>
                          </HStack>
                        ))}
                      </VStack>
                    </Box>
                  )}
                </VStack>
              ) : null}
            </ModalBody>

            <ModalFooter>
              <Button onClick={onStatsClose}>Zavřít</Button>
            </ModalFooter>
          </ModalContent>
        </Modal>
      </Container>
    </AdminLayout>
  );
};

export default PollsAdminPage;
