add back build time

This commit is contained in:
smanylov
2026-02-12 11:16:58 +07:00
parent 953f2f22a9
commit be1f310595
3 changed files with 57 additions and 8 deletions
+20 -2
View File
@@ -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');
}
}
+15 -1
View File
@@ -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;
}
}
}),
]);
}
+22 -5
View File
@@ -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>
);