@@ -2,21 +2,15 @@ import DeleteIcon from "@mui/icons-material/Delete";
22import { Box , Typography , Paper , Button } from "@mui/material" ;
33import { Stack } from "@mui/material" ;
44import { Tooltip } from "@mui/material" ;
5- import { useLocale , useStore } from "react-admin" ;
5+ import { useLocale , useStore , useTranslate } from "react-admin" ;
66
77import { useAppContext } from "../../Context" ;
88import dataProvider , { ServerNotificationsResponse } from "../../synapse/dataProvider" ;
99import { getTimeSince } from "../../utils/date" ;
1010
11- const DisplayTime = ( { date, locale } : { date : string ; locale : string } ) => {
12- const dateFromDateString = new Date ( date . replace ( " " , "T" ) + "Z" ) ;
13- return (
14- < Tooltip title = { dateFromDateString . toLocaleString ( locale ) } > { < span > { getTimeSince ( date ) + " ago" } </ span > } </ Tooltip >
15- ) ;
16- } ;
17-
1811const ServerNotificationsPage = ( ) => {
1912 const locale = useLocale ( ) ;
13+ const translate = useTranslate ( ) ;
2014 const { etkeccAdmin } = useAppContext ( ) ;
2115 const [ serverNotifications , setServerNotifications ] = useStore < ServerNotificationsResponse > ( "serverNotifications" , {
2216 notifications : [ ] ,
@@ -29,7 +23,7 @@ const ServerNotificationsPage = () => {
2923 < Stack spacing = { 3 } mt = { 3 } >
3024 < Stack spacing = { 1 } direction = "row" alignItems = "center" >
3125 < Box sx = { { display : "flex" , alignItems : "center" , justifyContent : "space-between" , width : "100%" , gap : 1 } } >
32- < Typography variant = "h4" > Server Notifications </ Typography >
26+ < Typography variant = "h4" > { translate ( "etkecc.notifications.title" ) } </ Typography >
3327 < Button
3428 variant = "text"
3529 color = "error"
@@ -41,26 +35,32 @@ const ServerNotificationsPage = () => {
4135 } ) ;
4236 } }
4337 >
44- < DeleteIcon fontSize = "small" sx = { { mr : 1 } } /> Clear
38+ < DeleteIcon fontSize = "small" sx = { { mr : 1 } } /> { translate ( "etkecc.notifications.clear_all" ) }
4539 </ Button >
4640 </ Box >
4741 </ Stack >
4842
4943 { notifications . length === 0 ? (
5044 < Paper sx = { { p : 2 } } >
51- < Typography > No new notifications.</ Typography >
45+ < Typography > { translate ( "etkecc. notifications.no_notifications" ) } </ Typography >
5246 </ Paper >
5347 ) : (
54- notifications . map ( ( notification , index ) => (
55- < Paper key = { notification . event_id ? notification . event_id : index } sx = { { p : 2 } } >
56- < Stack spacing = { 1 } >
57- < Typography variant = "subtitle1" fontWeight = "bold" color = "text.secondary" >
58- < DisplayTime date = { notification . sent_at } locale = { locale } />
59- </ Typography >
60- < Typography dangerouslySetInnerHTML = { { __html : notification . output } } />
61- </ Stack >
62- </ Paper >
63- ) )
48+ notifications . map ( ( notification , index ) => {
49+ const { timeI18Nkey, timeI18Nparams } = getTimeSince ( notification . sent_at ) ;
50+ const tooltipTitle = new Date ( notification . sent_at . replace ( " " , "T" ) + "Z" ) . toLocaleString ( locale ) ;
51+ return (
52+ < Paper key = { notification . event_id ? notification . event_id : index } sx = { { p : 2 } } >
53+ < Stack spacing = { 1 } >
54+ < Typography variant = "subtitle1" fontWeight = "bold" color = "text.secondary" >
55+ < Tooltip title = { tooltipTitle } >
56+ < span > { translate ( timeI18Nkey , timeI18Nparams ) + " " + translate ( "etkecc.notifications.ago" ) } </ span >
57+ </ Tooltip >
58+ </ Typography >
59+ < Typography dangerouslySetInnerHTML = { { __html : notification . output } } />
60+ </ Stack >
61+ </ Paper >
62+ ) ;
63+ } )
6464 ) }
6565 </ Stack >
6666 ) ;
0 commit comments