@@ -2,11 +2,9 @@ import { Box, Typography, Link } from '@mui/material'
2
2
import { Trans , useTranslation } from 'react-i18next'
3
3
4
4
import toskaColor from '../../assets/toscalogo_color.svg'
5
- import { useQuery } from '@tanstack/react-query'
6
- import { maxBy } from 'lodash'
7
- import { Release } from '../../../shared/types'
8
- import { formatDistanceToNow } from 'date-fns'
5
+ import { formatDistanceToNow , formatDuration , interval } from 'date-fns'
9
6
import { locales } from '../../locales/locales'
7
+ import useCurrentUser from '../../hooks/useCurrentUser'
10
8
11
9
const supportEmail = '[email protected] '
12
10
@@ -21,16 +19,11 @@ const styles = {
21
19
22
20
const Footer = ( ) => {
23
21
const { t, i18n } = useTranslation ( )
22
+ const { user } = useCurrentUser ( )
24
23
25
- const { data : changelog } = useQuery < Release [ ] > ( {
26
- queryKey : [ '/changelog' ] ,
27
- select : ( data ) => {
28
- const last = maxBy ( data , ( d ) => Date . parse ( d . time ) )
29
- return last ? [ last ] : [ ]
30
- } ,
31
- } )
32
-
33
- const publishedAgo = formatDistanceToNow ( changelog ?. [ 0 ] ?. time ?? new Date ( ) . getTime ( ) , { addSuffix : true , locale : locales [ i18n . language ] } )
24
+ const uptime = formatDistanceToNow ( user ?. lastRestart ?? Date . now ( ) , { locale : locales [ i18n . language ] } )
25
+ const serverVersion = user ?. serverVersion
26
+ const clientVersion = import . meta. env . VITE_VERSION as string | undefined
34
27
35
28
return (
36
29
< Box
@@ -50,8 +43,13 @@ const Footer = () => {
50
43
} }
51
44
/>
52
45
</ Typography >
53
- < Box display = "flex" gap = "1rem" >
54
- < Typography variant = "caption" > { t ( 'footer:version' , { version : changelog ?. [ 0 ] ?. version , publishedAgo } ) } </ Typography >
46
+ < Box display = "flex" gap = "1rem" mt = "1rem" >
47
+ < Box display = "flex" flexDirection = "column" >
48
+ < Typography variant = "caption" > { t ( 'footer:server' , { version : serverVersion } ) } </ Typography >
49
+ < Typography variant = "caption" > { t ( 'footer:client' , { version : clientVersion } ) } </ Typography >
50
+ { user ?. isAdmin && < Typography variant = "caption" > { t ( 'footer:uptime' , { uptime } ) } </ Typography > }
51
+ { serverVersion !== clientVersion && < Typography variant = "caption" > { t ( 'footer:mismatch' ) } </ Typography > }
52
+ </ Box >
55
53
< Link href = "https://toska.dev" target = "_blank" rel = "noopener" underline = "hover" >
56
54
< img src = { toskaColor } alt = "Toska" width = "40" />
57
55
</ Link >
0 commit comments