import { Accordion, AccordionButton, AccordionItem, AccordionPanel, Box, HStack, IconButton, Table, TableProps, Tbody, Td, Text, Th, Thead, Tooltip, Tr, useBreakpointValue, VStack, } from '@chakra-ui/react'; import classNames from 'classnames'; import { FC, Fragment, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { EmptySection, AccordionArrowIcon, EditIcon, Sort, handleSort, } from 'components/table'; import { useInbounds, fetchInboundHosts } from 'stores'; import { useQuery } from 'react-query'; type ExpandedIndex = number | number[]; type NodesTableProps = {} & TableProps; export const HostsTable: FC = (props) => { const { hostsFilters: filters, selectedInbound, onEditingHost, onCreatingHost, onHostsFilterChange, refetchHosts, } = useInbounds(); const { data: hosts } = useQuery('hosts', () => { if (selectedInbound !== null) { return fetchInboundHosts(selectedInbound.id); } }); useEffect(() => { refetchHosts() }, [selectedInbound]); const { t } = useTranslation(); const [selectedRow, setSelectedRow] = useState( undefined ); const useTable = useBreakpointValue({ base: false, md: true }); // TODO: Find a different mechancism to to detect ftiler // const isFiltered = users.length !== total; const toggleAccordion = (index: number) => { setSelectedRow(index === selectedRow ? undefined : index); }; return ( {/* Action buttons (certificate, core settings)*/} {!useTable && hosts?.map((host, i) => { return ( ); })}
{t('remark')} {t('hostsTable.address')} {t('hostsTable.port')}
{host.remark} {host.address}
{t('nodesTable.ipPort')} {host.port} { e.stopPropagation(); onEditingHost(true, host); }} >
{useTable && hosts?.map((host, i) => { return ( onEditingHost(true, host)} > ); })} {(hosts?.length === 0 || hosts === undefined) && ( )}
{t('remark')} {t('hostsTable.address')} {t('hostsTable.port')}
{host.remark}
{host.address} {host.port}
{/* TODO: * */}
); };