import { useState } from 'react';
import { Box, Flex } from '@chakra-ui/core';
import { FiCode } from '@meronex/icons/fi';
import { GoLinkExternal } from '@meronex/icons/go';
import stringFormat from 'string-format';
import { useConfig, useColorValue } from '~/context';
import { FooterButton } from './FooterButton';
import { FooterContent } from './FooterContent';
export const Footer = () => {
const config = useConfig();
const [helpVisible, showHelp] = useState(false);
const [termsVisible, showTerms] = useState(false);
const [creditVisible, showCredit] = useState(false);
const footerBg = useColorValue('blackAlpha.50', 'whiteAlpha.100');
const footerColor = useColorValue('black', 'white');
const contentBorder = useColorValue('blackAlpha.100', 'whiteAlpha.200');
const handleCollapse = (i: TFooterItems) => {
if (i === 'help') {
showTerms(false);
showCredit(false);
showHelp(!helpVisible);
} else if (i === 'credit') {
showTerms(false);
showHelp(false);
showCredit(!creditVisible);
} else if (i === 'terms') {
showHelp(false);
showCredit(false);
showTerms(!termsVisible);
}
};
const extUrl = config.web.external_link.url.includes('{primary_asn}')
? stringFormat(config.web.external_link.url, { primary_asn: config.primary_asn })
: config.web.external_link.url || '/';
return (
<>
{config.web.help_menu.enable && (
)}
{config.web.terms.enable && (
)}
{config.web.credit.enable && (
)}
{config.web.terms.enable && (
handleCollapse('terms')}
aria-label={config.web.terms.title}>
{config.web.terms.title}
)}
{config.web.help_menu.enable && (
handleCollapse('help')}
aria-label={config.web.help_menu.title}>
{config.web.help_menu.title}
)}
{config.web.credit.enable && (
handleCollapse('credit')}
aria-label="Powered by hyperglass">
)}
{config.web.external_link.enable && (
}
size="xs">
{config.web.external_link.title}
)}
>
);
};