|
@@ -1,14 +1,20 @@
|
|
|
-import React, { useState } from 'react';
|
|
|
+import React, { useEffect, useState } from 'react';
|
|
|
import axios from 'axios';
|
|
|
|
|
|
export const Overview: React.FC = () => {
|
|
|
const [msg, setMsg] = useState('LOADING');
|
|
|
|
|
|
- axios.get('http://localhost:3000/auth/user', {
|
|
|
- headers: {
|
|
|
- Authorization: `Bearer ${sessionStorage.getItem('token')}`,
|
|
|
- },
|
|
|
- }).then((data) => setMsg(data.data)).catch(() => setMsg('FAILED'));
|
|
|
+ useEffect(() => {
|
|
|
+ const interval = setInterval(() => {
|
|
|
+ axios.get('http://localhost:3000/system/timestamp', {
|
|
|
+ headers: {
|
|
|
+ Authorization: `Bearer ${sessionStorage.getItem('token')}`,
|
|
|
+ }
|
|
|
+ }).then((response) => setMsg(new Date(response.data).toISOString()));
|
|
|
+ }, 5000);
|
|
|
+
|
|
|
+ return () => clearInterval(interval);
|
|
|
+ }, []);
|
|
|
|
|
|
return <>OVERVIEW {msg}</>;
|
|
|
};
|