import React, { useEffect, useState } from 'react'; import { createStyles, Anchor, Text, Group, ActionIcon, Footer as FooterComponent, Alert, useMantineTheme, } from '@mantine/core'; import { AlertCircle, BrandGithub } from 'tabler-icons-react'; import { CURRENT_VERSION, REPO_URL } from '../../../data/constants'; import { ModuleWrapper } from '../modules/moduleWrapper'; import { DownloadsModule } from '../modules'; const useStyles = createStyles((theme) => ({ footer: { borderTop: `1px solid ${ theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[2] }`, }, inner: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: `${theme.spacing.md}px ${theme.spacing.md}px`, [theme.fn.smallerThan('sm')]: { flexDirection: 'column', }, }, links: { [theme.fn.smallerThan('sm')]: { marginTop: theme.spacing.lg, marginBottom: theme.spacing.sm, }, }, })); interface FooterCenteredProps { links: { link: string; label: string }[]; } export function Footer({ links }: FooterCenteredProps) { const [update, setUpdate] = useState(false); const theme = useMantineTheme(); const { classes } = useStyles(); const items = links.map((link) => ( color="dimmed" key={link.label} href={link.link} sx={{ lineHeight: 1 }} onClick={(event) => event.preventDefault()} size="sm" > {link.label} )); const [latestVersion, setLatestVersion] = useState(CURRENT_VERSION); const [isOpen, setOpen] = useState(true); useEffect(() => { // Fetch Data here when component first mounted fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => { res.json().then((data) => { setLatestVersion(data.tag_name); if (data.tag_name !== CURRENT_VERSION) { setUpdate(true); } }); }); }, []); return ( setOpen(false)} icon={} title={`Updated version: ${latestVersion} is available. Current version: ${CURRENT_VERSION}`} withCloseButton radius="lg" hidden={CURRENT_VERSION === latestVersion || !isOpen} variant="outline" styles={{ root: { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white', }, closeButton: { marginLeft: '5px', }, }} children={undefined} /> component="a" href="https://github.com/ajnart/homarr" size="lg"> {CURRENT_VERSION} Made with ❤️ by @ ajnart ); }