From 152011d11e032a7297de855724d74da83fa6f1cb Mon Sep 17 00:00:00 2001
From: lonkaars <loek@pipeframe.xyz>
Date: Sun, 25 Apr 2021 17:01:12 +0200
Subject: added version number from package.json and commit hash to footer

---
 components/footer.tsx | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

(limited to 'components/footer.tsx')

diff --git a/components/footer.tsx b/components/footer.tsx
index 8a1319e..575f7e9 100644
--- a/components/footer.tsx
+++ b/components/footer.tsx
@@ -1,5 +1,8 @@
-import { ReactNode } from 'react';
+import axios from 'axios';
+import { ReactNode, useEffect, useState } from 'react';
 import * as cookie from 'react-cookies';
+
+import { serverStatus } from '../api/api';
 import Logo from '../components/logo';
 
 import ExitToAppOutlinedIcon from '@material-ui/icons/ExitToAppOutlined';
@@ -25,11 +28,24 @@ function PageLink(props: {
 
 export function Footer() {
 	var loggedIn = !!cookie.load('token');
+	var [status, setStatus] = useState<serverStatus>();
+
+	useEffect(() => {
+		axios.request<serverStatus>({
+			url: '/api/status',
+		}).then(res => {
+			setStatus(res.data);
+		});
+	}, []);
 
 	return <div className='footer'>
-		<div className='header'>
+		<div className='header posrel'>
 			<Logo />
 			<h2>4 op een rij</h2>
+			<span className='versionString subtile posabs abscenterv'>
+				<span className='number'>v{status?.version.number}</span>
+				<span className='commit'>({status?.version.commit.substr(0, 8)})</span>
+			</span>
 		</div>
 		<div className='content'>
 			<div className='column'>
@@ -50,3 +66,6 @@ export function Footer() {
 		</div>
 	</div>;
 }
+
+Footer.getInitialProps = async () => {
+};
-- 
cgit v1.2.3

