|
@@ -1,7 +1,6 @@
|
|
|
-import axios from 'axios';
|
|
|
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
-import { Configuration } from '../services';
|
|
|
+import { System } from '../services';
|
|
|
|
|
|
const TimeContext = React.createContext<{
|
|
|
offset: number;
|
|
@@ -14,14 +13,10 @@ export const TimeProvider = ({ children }: { children: any }) => {
|
|
|
|
|
|
useEffect(() => {
|
|
|
const estimateTimeOffset = async () => {
|
|
|
- axios.get<number>(`${Configuration.resourceServer}/system/timestamp`, {
|
|
|
- headers: {
|
|
|
- Authorization: `Bearer ${sessionStorage.getItem('token')}`,
|
|
|
- },
|
|
|
- }).then((response) => {
|
|
|
+ System.timestamp().then((timestamp) => {
|
|
|
// calculate the time offset (not accurate) between the server and the client to show "correct" times
|
|
|
const clientTimeUtc = new Date().getTime()
|
|
|
- const serverTimeUtc = response.data;
|
|
|
+ const serverTimeUtc = timestamp;
|
|
|
setOffset(serverTimeUtc - clientTimeUtc);
|
|
|
}).catch(() => {
|
|
|
setOffset(0);
|