Files
canina/frontend/admin-panel/src/App.tsx
T
devops ddbf1ca026
Deploy Canina / deploy (push) Successful in 4m1s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s
test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation.
- Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings.
- Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors.
- Fixed unmount lifecycle guards, promise error handling, and component edge cases.
2026-10-13 16:01:00 +00:00

68 lines
2.1 KiB
TypeScript

import axios from 'axios';
import { Suspense,useEffect } from 'react';
import { Toaster } from 'react-hot-toast';
import { RouterProvider } from 'react-router-dom';
import { router } from './routes/adminRoutes';
import { BASE_DOMAIN } from './services/api';
import { useAdminAuthStore } from './store/adminAuthStore';
function SuspenseFallback() {
return (
<div className="min-h-screen flex items-center justify-center bg-gray-50 font-vazir" dir="rtl">
<div className="flex flex-col items-center gap-3">
<div className="w-10 h-10 border-4 border-purple-600 border-t-transparent rounded-full animate-spin"></div>
<span className="text-sm font-bold text-gray-500">در حال بارگذاری ماژول ادمین...</span>
</div>
</div>
);
}
function App() {
const isAuthenticated = useAdminAuthStore((state) => state.isAuthenticated);
const setAuth = useAdminAuthStore((state) => state.setAuth);
// Proactive token refresh every 10 minutes to prevent 15-min JWT session loss during form edits (A1)
useEffect(() => {
if (!isAuthenticated) return;
const refreshSession = async () => {
try {
const res = await axios.post(
`${BASE_DOMAIN}/api/auth/refresh`,
{},
{ withCredentials: true }
);
if (res.data?.success && res.data.data?.accessToken) {
setAuth(res.data.data.accessToken, res.data.data.user);
}
} catch {
// Silently catch; let api interceptor handle on next actual request if needed
}
};
// Refresh every 10 minutes (600,000 ms)
const interval = setInterval(refreshSession, 10 * 60 * 1000);
return () => clearInterval(interval);
}, [isAuthenticated, setAuth]);
return (
<>
<Toaster
position="top-center"
toastOptions={{
className: 'font-vazir text-sm font-bold',
style: {
direction: 'rtl',
fontFamily: 'Vazirmatn, system-ui, sans-serif'
}
}}
/>
<Suspense fallback={<SuspenseFallback />}>
<RouterProvider router={router} />
</Suspense>
</>
);
}
export default App;