11import { useState , useRef } from 'react'
2- import { CircularProgress , Divider , List , ListItemText , Toolbar } from '@mui/material'
2+ import { CircularProgress , Divider , List , ListItemText , Toolbar , Tooltip } from '@mui/material'
33import { EventScreenMenuItems } from '../EventScreenMenuItems'
44import { LoadingButton } from '@mui/lab'
55import { Event } from '../../../types'
66import { useNotification } from '../../../hooks/notificationHook'
77import { updateWebsiteTriggerWebhooksAction } from '../../actions/updateWebsiteTriggerWebhooksAction'
88import { EventSelector } from '../../../components/EventSelector'
99import confetti from 'canvas-confetti'
10+ import { DateTime } from 'luxon'
1011
1112export type EventDrawerContentProps = {
1213 event : Event
@@ -17,6 +18,11 @@ export const EventDrawerContent = ({ event }: EventDrawerContentProps) => {
1718 const { createNotification } = useNotification ( )
1819 const buttonRef = useRef < HTMLButtonElement > ( null )
1920
21+ const getRelativeTime = ( ) => {
22+ if ( ! event . updatedAt ) return 'Never updated'
23+ return `Last updated ${ DateTime . fromJSDate ( event . updatedAt ) . toRelative ( ) } `
24+ }
25+
2026 return (
2127 < >
2228 < Toolbar
@@ -31,44 +37,47 @@ export const EventDrawerContent = ({ event }: EventDrawerContentProps) => {
3137 < Divider />
3238 < List component = "nav" >
3339 < EventScreenMenuItems />
34- < LoadingButton
35- ref = { buttonRef }
36- variant = "contained"
37- loading = { loading }
38- disabled = { loading }
39- onClick = { async ( ) => {
40- setLoading ( true )
41- await updateWebsiteTriggerWebhooksAction ( event , createNotification )
42- setLoading ( false )
40+ < Tooltip title = { getRelativeTime ( ) } arrow placement = "top" >
41+ < LoadingButton
42+ ref = { buttonRef }
43+ variant = "contained"
44+ loading = { loading }
45+ disabled = { loading }
46+ onClick = { async ( ) => {
47+ setLoading ( true )
48+ await updateWebsiteTriggerWebhooksAction ( event , createNotification )
49+ setLoading ( false )
4350
44- // Trigger confetti effect from button position
45- if ( buttonRef . current ) {
46- const rect = buttonRef . current . getBoundingClientRect ( )
47- const x = rect . left + rect . width / 2
48- const y = rect . top + rect . height / 2
51+ // Trigger confetti effect from button position
52+ if ( buttonRef . current ) {
53+ const rect = buttonRef . current . getBoundingClientRect ( )
54+ const x = rect . left + rect . width / 2
55+ const y = rect . top + rect . height / 2
4956
50- confetti ( {
51- origin : {
52- x : x / window . innerWidth ,
53- y : y / window . innerHeight ,
54- } ,
55- spread : 70 ,
56- startVelocity : 30 ,
57- particleCount : 100 ,
58- angle : 20 ,
59- gravity : - 0.4 ,
60- zIndex : 2000 ,
61- drift : 0.5 ,
62- } )
63- }
64- } }
65- sx = { {
66- margin : 1 ,
67- whiteSpace : 'break-spaces' ,
68- } }
69- loadingIndicator = { < CircularProgress color = "secondary" size = { 16 } /> } >
70- < ListItemText primary = { 'Update website' } />
71- </ LoadingButton >
57+ confetti ( {
58+ origin : {
59+ x : x / window . innerWidth ,
60+ y : y / window . innerHeight ,
61+ } ,
62+ spread : 70 ,
63+ startVelocity : 30 ,
64+ particleCount : 100 ,
65+ angle : 20 ,
66+ gravity : - 0.4 ,
67+ zIndex : 2000 ,
68+ drift : 0.5 ,
69+ } )
70+ }
71+ } }
72+ sx = { {
73+ margin : 1 ,
74+ whiteSpace : 'break-spaces' ,
75+ width : 'calc(100% - 16px)' ,
76+ } }
77+ loadingIndicator = { < CircularProgress color = "secondary" size = { 16 } /> } >
78+ < ListItemText primary = { 'Update website' } />
79+ </ LoadingButton >
80+ </ Tooltip >
7281 </ List >
7382 </ >
7483 )
0 commit comments