refactor: use proper config for routes

This commit is contained in:
Your Name
2026-04-11 19:51:00 +05:30
parent 9953b27385
commit 73a9787daf
3 changed files with 2 additions and 7 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export function ProtectedRoute({ children }: { children: React.ReactNode }) {
if (!isAuthenticated) { if (!isAuthenticated) {
// Save the intended location to redirect back after login // Save the intended location to redirect back after login
return <Navigate to="/login" state={{ from: location }} replace />; return <Navigate to={ROUTES.LOGIN} state={{ from: location }} replace />;
} }
return <>{children}</>; return <>{children}</>;
+1 -5
View File
@@ -36,17 +36,13 @@ export default function Login() {
setIsLoading(true); setIsLoading(true);
setApiError(null); setApiError(null);
try { try {
// 1. Authenticate
const { data: authData } = await publicApi.post(endpoints.LOGIN, data); const { data: authData } = await publicApi.post(endpoints.LOGIN, data);
// 2. Fetch User Profile with the fresh token
// We pass the header explicitly to avoid any race conditions with interceptors
const { data: userData } = await api.get(endpoints.ME, { const { data: userData } = await api.get(endpoints.ME, {
headers: { Authorization: `Bearer ${authData.access}` }, headers: { Authorization: `Bearer ${authData.access}` },
}); });
// 3. Update store using the hook method login(authData.access, userData);
await login(authData.access, userData);
navigate(ROUTES.DRAWER); navigate(ROUTES.DRAWER);
} catch (err) { } catch (err) {
-1
View File
@@ -33,7 +33,6 @@ export default function VerifyEmail() {
type="button" type="button"
className="text-xs italic opacity-40 cursor-pointer underline" className="text-xs italic opacity-40 cursor-pointer underline"
onClick={() => window.close()} onClick={() => window.close()}
onKeyDown={(e) => e.key === "Enter" && window.close()}
> >
You can close this window now. You can close this window now.
</button> </button>