Improve backend connectivity check with early returns and Remove unrelated super admin check to focus on backend reachability

This commit is contained in:
mohadeseh safari committed 2025-04-27 12:57:38 -04:00
1 parent eec11f303c
commit 720f60cbb7
1 file changed
+10 -25
+10 -25
View File
@@ -59,36 +59,21 @@ const Login = () => {
const isReachable = await networkService.checkBackendReachability(); const isReachable = await networkService.checkBackendReachability();
setBackendReachable(isReachable); setBackendReachable(isReachable);
if (isReachable) { // Early return if backend is not reachable
// Only check if super admin exists if not already attempting to log in if (isReachable === false) {
// This allows users to log in even if system thinks no super admin exists // Show toast only on retry attempts
if (window.location.pathname === "/" || window.location.pathname === "") {
networkService
.doesSuperAdminExist()
.then((response) => {
if (response.data.data === false) {
// Add a toast notification instead of forcing redirect
createToast({
body: t("noSuperAdminMessage"),
type: "info"
});
}
})
.catch((error) => {
logger.error(error);
});
}
// Only show reconnection toast if this was a retry attempt
if (isRetry) { if (isRetry) {
createToast({ createToast({
body: t("backendReconnected"), body: t("backendStillUnreachable"),
}); });
} }
} else if (isRetry) { return;
// Only show still unreachable toast if this was a retry attempt }
// Show reconnection toast if this was a retry attempt and backend is now reachable
if (isRetry) {
createToast({ createToast({
body: t("backendStillUnreachable"), body: t("backendReconnected"),
}); });
} }
} catch (error) { } catch (error) {