2022-05-26 20:07:54 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
import { createStyles, Footer as FooterComponent } from '@mantine/core';
|
2022-05-26 19:14:19 +02:00
|
|
|
import { showNotification } from '@mantine/notifications';
|
2022-05-18 22:09:13 +02:00
|
|
|
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
|
2022-04-25 00:11:32 +02:00
|
|
|
|
|
|
|
|
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) {
|
2022-05-18 22:09:13 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
// Fetch Data here when component first mounted
|
|
|
|
|
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
|
|
|
|
res.json().then((data) => {
|
|
|
|
|
if (data.tag_name !== CURRENT_VERSION) {
|
2022-05-26 20:07:22 +02:00
|
|
|
showNotification({
|
|
|
|
|
color: 'yellow',
|
|
|
|
|
autoClose: false,
|
|
|
|
|
title: 'New version available',
|
|
|
|
|
message: `Version ${data.tag_name} is available, update now! 😡`,
|
|
|
|
|
});
|
2022-05-18 22:09:13 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
2022-05-17 01:01:26 +02:00
|
|
|
return (
|
|
|
|
|
<FooterComponent
|
|
|
|
|
height="auto"
|
2022-05-18 22:09:13 +02:00
|
|
|
style={{
|
|
|
|
|
background: 'none',
|
|
|
|
|
border: 'none',
|
|
|
|
|
clear: 'both',
|
|
|
|
|
}}
|
2022-05-26 20:07:22 +02:00
|
|
|
children={undefined}
|
|
|
|
|
/>
|
2022-04-25 00:11:32 +02:00
|
|
|
);
|
|
|
|
|
}
|