@stokr/components-library 3.0.35 → 3.0.36

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.
@@ -8,11 +8,12 @@ import { identify, reset } from "../analytics/index.js";
8
8
  import { withRouter } from "../utils/withRouter.js";
9
9
  import { Text } from "../components/Text/Text.styles.js";
10
10
  import { Auth, DEFAULT_TOKEN_EXPIRY_MS } from "./Auth.js";
11
+ import { Button } from "../components/Button/Button.styles.js";
11
12
  import { hasLoggedInSession } from "../utils/user-identity.js";
13
+ import { SuccessModal as SuccessModalComponent } from "../components/Modal/SuccessModal/SuccessModal.js";
12
14
  import { getConfig, getPlatformURL } from "../runtime-config.js";
13
- import { ConfirmModal as ConfirmModalComponent } from "../components/ConfirmModal/ConfirmModal.js";
14
- import { getFirebaseAuth, isValidFirebaseConfig } from "../firebase-config.js";
15
15
  import avatarPlaceholder from "../static/images/avatar-placeholder.png.js";
16
+ import { getFirebaseAuth, isValidFirebaseConfig } from "../firebase-config.js";
16
17
  import { isAlreadyOnOnboardingFlow } from "../utils/app-urls.js";
17
18
  import { multiFactor, TotpMultiFactorGenerator, signOut, getMultiFactorResolver, PhoneMultiFactorGenerator } from "firebase/auth";
18
19
  import { navigateToHref } from "../routing/navigate-app.js";
@@ -788,7 +789,7 @@ class AuthProviderClass extends Component {
788
789
  }
789
790
  };
790
791
  render() {
791
- const { children } = this.props;
792
+ const { children, redirectToLogin = true } = this.props;
792
793
  return /* @__PURE__ */ jsxs(
793
794
  AuthContext.Provider,
794
795
  {
@@ -835,16 +836,26 @@ class AuthProviderClass extends Component {
835
836
  children: [
836
837
  children,
837
838
  (this.state.loggedOutDueToInactivity || this.state.loggedOutDueToCookieExpiry || this.state.sessionExpiryPendingReason) && !this.props.hideInactivityModal && /* @__PURE__ */ jsx(
838
- ConfirmModalComponent,
839
+ SuccessModalComponent,
839
840
  {
840
841
  isOpen: true,
841
- maxWidth: "600px",
842
- confirmText: "OK",
843
- onCancel: this.dismissSessionExpiryModal,
844
- onConfirm: this.dismissSessionExpiryModal,
845
- showRedBar: true,
842
+ onClose: this.dismissSessionExpiryModal,
843
+ variant: "progress",
846
844
  title: "Session expired",
847
- content: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx("p", { style: { fontSize: 16 }, children: this.state.sessionExpiryPendingReason === "inactivity" || this.state.loggedOutDueToInactivity ? "You have been logged out due to inactivity." : "Your session has expired. Please log in again." }) })
845
+ content: /* @__PURE__ */ jsxs(Text, { children: [
846
+ /* @__PURE__ */ jsx("p", { style: { fontSize: 16 }, children: this.state.sessionExpiryPendingReason === "inactivity" || this.state.loggedOutDueToInactivity ? "You have been logged out due to inactivity." : "Your session has expired. Please log in again." }),
847
+ /* @__PURE__ */ jsx(
848
+ Button,
849
+ {
850
+ onClick: () => {
851
+ this.dismissSessionExpiryModal();
852
+ if (redirectToLogin) navigateToHref(this.props.navigate, getPlatformURL() + "/login");
853
+ },
854
+ children: "Log in"
855
+ }
856
+ )
857
+ ] }),
858
+ maxWidth: "600px"
848
859
  }
849
860
  )
850
861
  ]
@@ -886,7 +897,9 @@ AuthProviderClass.propTypes = {
886
897
  /** When true, the inactivity modal is not shown after auto-logout. Default false. */
887
898
  hideInactivityModal: PropTypes.bool,
888
899
  /** Override access token cookie lifetime in ms (e.g. for Storybook). Production uses 1 hour. */
889
- accessTokenExpiryMs: PropTypes.number
900
+ accessTokenExpiryMs: PropTypes.number,
901
+ /** When true, the user will be redirected to the login page after the session expires. Default false. */
902
+ redirectToLogin: PropTypes.bool
890
903
  };
891
904
  function resolveFirebaseConfigForGuard(props) {
892
905
  if (props.config?.firebase != null) return props.config.firebase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.35",
3
+ "version": "3.0.36",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",