@gofreego/tsutils 0.1.22 → 0.1.23

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.mjs CHANGED
@@ -681,25 +681,27 @@ function extractErrorMessage(error) {
681
681
  }
682
682
  return "An unexpected error occurred";
683
683
  }
684
- function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
684
+ function LoginCallbackPage({ authService, navigateTo = "/" }) {
685
685
  const [searchParams] = useSearchParams();
686
686
  const navigate = useNavigate();
687
687
  const { theme } = useTheme();
688
+ const [error, setError] = useState(null);
688
689
  useEffect(() => {
689
690
  const loginToken = searchParams.get("login_token");
690
691
  if (!loginToken) {
691
692
  console.error("Login callback failed: Missing login_token in query parameters");
692
- onLoginFailed?.();
693
+ setError("Login failed: missing login token.");
693
694
  return;
694
695
  }
695
696
  authService.signInWithLoginToken({ loginToken, includePermissions: true }).then(() => {
696
697
  navigate(navigateTo, { replace: true });
697
698
  }).catch((err) => {
698
- console.error("Login callback failed:", extractErrorMessage(err));
699
- onLoginFailed?.();
699
+ const message = extractErrorMessage(err);
700
+ console.error("Login callback failed:", message);
701
+ setError(message);
700
702
  });
701
703
  }, []);
702
- return /* @__PURE__ */ jsxs(
704
+ return /* @__PURE__ */ jsx(
703
705
  Box,
704
706
  {
705
707
  sx: {
@@ -711,10 +713,25 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
711
713
  background: `linear-gradient(135deg, ${theme.colors.primary} 0%, ${theme.colors.primaryActive} 100%)`,
712
714
  gap: 2
713
715
  },
714
- children: [
716
+ children: error ? /* @__PURE__ */ jsxs(Fragment, { children: [
717
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { color: theme.colors.surface, fontWeight: 500 }, children: error }),
718
+ /* @__PURE__ */ jsx(
719
+ Button,
720
+ {
721
+ variant: "contained",
722
+ onClick: () => navigate(navigateTo, { replace: true }),
723
+ sx: {
724
+ backgroundColor: theme.colors.surface,
725
+ color: theme.colors.primary,
726
+ "&:hover": { backgroundColor: theme.colors.surface, opacity: 0.9 }
727
+ },
728
+ children: "Retry"
729
+ }
730
+ )
731
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
715
732
  /* @__PURE__ */ jsx(CircularProgress, { sx: { color: theme.colors.surface } }),
716
733
  /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { color: theme.colors.surface, opacity: 0.85 }, children: "Signing you in\u2026" })
717
- ]
734
+ ] })
718
735
  }
719
736
  );
720
737
  }