chore: update time in real-time in dashboard and profile sidebar (#3489)
* chore: update dashboard and profile time in realtime * chore: remove seconds * fix: cycle and module sidebar datepicker
This commit is contained in:
parent
b3393f5c48
commit
3c9679dff9
7 changed files with 280 additions and 201 deletions
17
web/hooks/use-current-time.tsx
Normal file
17
web/hooks/use-current-time.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
export const useCurrentTime = () => {
|
||||
const [currentTime, setCurrentTime] = useState(new Date());
|
||||
// update the current time every second
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
setCurrentTime(new Date());
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
currentTime,
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue