@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.d.mts CHANGED
@@ -230,9 +230,8 @@ declare class AuthService implements IAuthService {
230
230
  interface LoginCallbackPageProps {
231
231
  authService: IAuthService;
232
232
  navigateTo?: string;
233
- onLoginFailed?: () => void;
234
233
  }
235
- declare function LoginCallbackPage({ authService, navigateTo, onLoginFailed }: LoginCallbackPageProps): react_jsx_runtime.JSX.Element;
234
+ declare function LoginCallbackPage({ authService, navigateTo }: LoginCallbackPageProps): react_jsx_runtime.JSX.Element;
236
235
 
237
236
  interface ProtectedRouteProps {
238
237
  children: ReactElement;
package/dist/index.d.ts CHANGED
@@ -230,9 +230,8 @@ declare class AuthService implements IAuthService {
230
230
  interface LoginCallbackPageProps {
231
231
  authService: IAuthService;
232
232
  navigateTo?: string;
233
- onLoginFailed?: () => void;
234
233
  }
235
- declare function LoginCallbackPage({ authService, navigateTo, onLoginFailed }: LoginCallbackPageProps): react_jsx_runtime.JSX.Element;
234
+ declare function LoginCallbackPage({ authService, navigateTo }: LoginCallbackPageProps): react_jsx_runtime.JSX.Element;
236
235
 
237
236
  interface ProtectedRouteProps {
238
237
  children: ReactElement;
package/dist/index.js CHANGED
@@ -694,25 +694,27 @@ function extractErrorMessage(error) {
694
694
  }
695
695
  return "An unexpected error occurred";
696
696
  }
697
- function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
697
+ function LoginCallbackPage({ authService, navigateTo = "/" }) {
698
698
  const [searchParams] = reactRouterDom.useSearchParams();
699
699
  const navigate = reactRouterDom.useNavigate();
700
700
  const { theme } = useTheme();
701
+ const [error, setError] = react.useState(null);
701
702
  react.useEffect(() => {
702
703
  const loginToken = searchParams.get("login_token");
703
704
  if (!loginToken) {
704
705
  console.error("Login callback failed: Missing login_token in query parameters");
705
- onLoginFailed?.();
706
+ setError("Login failed: missing login token.");
706
707
  return;
707
708
  }
708
709
  authService.signInWithLoginToken({ loginToken, includePermissions: true }).then(() => {
709
710
  navigate(navigateTo, { replace: true });
710
711
  }).catch((err) => {
711
- console.error("Login callback failed:", extractErrorMessage(err));
712
- onLoginFailed?.();
712
+ const message = extractErrorMessage(err);
713
+ console.error("Login callback failed:", message);
714
+ setError(message);
713
715
  });
714
716
  }, []);
715
- return /* @__PURE__ */ jsxRuntime.jsxs(
717
+ return /* @__PURE__ */ jsxRuntime.jsx(
716
718
  material.Box,
717
719
  {
718
720
  sx: {
@@ -724,10 +726,25 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
724
726
  background: `linear-gradient(135deg, ${theme.colors.primary} 0%, ${theme.colors.primaryActive} 100%)`,
725
727
  gap: 2
726
728
  },
727
- children: [
729
+ children: error ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
730
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { color: theme.colors.surface, fontWeight: 500 }, children: error }),
731
+ /* @__PURE__ */ jsxRuntime.jsx(
732
+ material.Button,
733
+ {
734
+ variant: "contained",
735
+ onClick: () => navigate(navigateTo, { replace: true }),
736
+ sx: {
737
+ backgroundColor: theme.colors.surface,
738
+ color: theme.colors.primary,
739
+ "&:hover": { backgroundColor: theme.colors.surface, opacity: 0.9 }
740
+ },
741
+ children: "Retry"
742
+ }
743
+ )
744
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
728
745
  /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { sx: { color: theme.colors.surface } }),
729
746
  /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", sx: { color: theme.colors.surface, opacity: 0.85 }, children: "Signing you in\u2026" })
730
- ]
747
+ ] })
731
748
  }
732
749
  );
733
750
  }