add back build time
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import { getSessionData, deleteSession } from '@/app/actions/session';
|
||||
import { testUserData, API_BASE_URL } from '@/app/actions/definitions';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export async function getUserData() {
|
||||
const userEmail = await getSessionData('email');
|
||||
@@ -99,4 +98,23 @@ export async function fetchTariffs() {
|
||||
} catch (error) {
|
||||
console.error('error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function getBuildData() {
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/check/api/build`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
return await response.json();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import { getUserData, getUserFilesInfo } from '@/app/actions/action';
|
||||
import { getUserData, getUserFilesInfo, getBuildData } from '@/app/actions/action';
|
||||
import { getUserFilesData } from '@/app/actions/fileEntity';
|
||||
import { fetchReferralUserStats } from '@/app/actions/referralsActions';
|
||||
|
||||
@@ -24,5 +24,19 @@ export async function prefetchLayoutQueries(queryClient: QueryClient) {
|
||||
queryKey: ['referralUserStats'],
|
||||
queryFn: () => fetchReferralUserStats()
|
||||
}),
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ['backendBuildDate'],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const response = await getBuildData();
|
||||
if (response.buildTimeBack) {
|
||||
return response.buildTimeBack;
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}),
|
||||
]);
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import { useClickOutside } from '@/app/hooks/useClickOutside';
|
||||
import { fetchReferralUserStats } from '@/app/actions/referralsActions';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { env } from 'process';
|
||||
import { getBuildData } from '@/app/actions/action';
|
||||
|
||||
export default function NavLinks() {
|
||||
const {
|
||||
@@ -56,7 +57,21 @@ export default function NavLinks() {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
retry: false // Не повторять запрос при ошибке
|
||||
retry: false
|
||||
});
|
||||
|
||||
const {
|
||||
data: backendBuildDate,
|
||||
} = useQuery({
|
||||
queryKey: ['backendBuildDate'],
|
||||
queryFn: () => getBuildData(),
|
||||
select: (data) => {
|
||||
if (data) {
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
|
||||
const pathname = usePathname().replace('/en/', '/').replace('/ru/', '/');
|
||||
@@ -160,14 +175,16 @@ export default function NavLinks() {
|
||||
</ul>
|
||||
|
||||
<div className="build-versions">
|
||||
{!frontendBuildDate && (
|
||||
{frontendBuildDate && (
|
||||
<div className="">
|
||||
front: {frontendBuildDate}
|
||||
</div>
|
||||
)}
|
||||
{/* <div>
|
||||
back:
|
||||
</div> */}
|
||||
{backendBuildDate && (
|
||||
<div className="">
|
||||
back: {backendBuildDate}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user