@sudobility/building_blocks 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5214,6 +5214,22 @@ function LoginPage({
5214
5214
  const [password, setPassword] = useState("");
5215
5215
  const [error, setError] = useState(null);
5216
5216
  const [isLoading, setIsLoading] = useState(false);
5217
+ const [isGoogleSignInPending, setIsGoogleSignInPending] = useState(false);
5218
+ const googleSignInStartTime = useRef(null);
5219
+ useEffect(() => {
5220
+ const handleFocus = () => {
5221
+ if (isGoogleSignInPending && googleSignInStartTime.current) {
5222
+ const elapsed = Date.now() - googleSignInStartTime.current;
5223
+ if (elapsed > 2e3) {
5224
+ setIsLoading(false);
5225
+ setIsGoogleSignInPending(false);
5226
+ googleSignInStartTime.current = null;
5227
+ }
5228
+ }
5229
+ };
5230
+ window.addEventListener("focus", handleFocus);
5231
+ return () => window.removeEventListener("focus", handleFocus);
5232
+ }, [isGoogleSignInPending]);
5217
5233
  const handleAuthError = (err) => {
5218
5234
  const firebaseError = err;
5219
5235
  const code = firebaseError.code || "unknown";
@@ -5246,6 +5262,8 @@ function LoginPage({
5246
5262
  const handleGoogleSignIn = async () => {
5247
5263
  setError(null);
5248
5264
  setIsLoading(true);
5265
+ setIsGoogleSignInPending(true);
5266
+ googleSignInStartTime.current = Date.now();
5249
5267
  try {
5250
5268
  if (!auth) throw new Error("Firebase not configured");
5251
5269
  const provider = new GoogleAuthProvider();
@@ -5255,6 +5273,8 @@ function LoginPage({
5255
5273
  handleAuthError(err);
5256
5274
  } finally {
5257
5275
  setIsLoading(false);
5276
+ setIsGoogleSignInPending(false);
5277
+ googleSignInStartTime.current = null;
5258
5278
  }
5259
5279
  };
5260
5280
  const text = defaultText;