How to use the connected-react-router.routerActions.replace function in connected-react-router

To help you get started, we’ve selected a few connected-react-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / components / Application.tsx View on Github external
notificationsLoading: boolean;
    loggedIn: boolean;
    isMounted: false;
    user: {data: any, status: any};
}

const Loader = Loadable({
    ...loadableDefaults,
    loader: () => import('./common/PageLoading'),
});

const UserIsAuthenticated = connectedReduxRedirect({
    authenticatedSelector: (state: State) => !!state.user.data,
    authenticatingSelector: (state: State) => state.user.status.isLoading ,
    AuthenticatingComponent: Loader,
    redirectAction: routerActions.replace,
    wrapperDisplayName: 'UserIsAuthenticated',
    redirectPath: '/login',
});

const UserIsNotAuthenticated = connectedReduxRedirect({
    redirectAction: routerActions.replace,
    wrapperDisplayName: 'UserIsNotAuthenticated',
    authenticatedSelector: (state: State) => {
        const checked = !state.user.data && state.user.status.isLoading === false;
        return checked;
    },
    redirectPath: (state, ownProps: RouteComponentProps<{}, {}>) => {
        const {redirect, next} = queryString.parse(ownProps.location.search);
        return (redirect || next) || '/dashboard';
    },
    allowRedirectBack: false,
github Kamahl19 / react-starter / src / features / auth / guards / LoginGuard.ts View on Github external
const LoginGuard = (Component: ComponentType) =>
  connectedReduxRedirect({
    allowRedirectBack: false,
    authenticatedSelector: state => !selectIsLoggedIn(state),
    authenticatingSelector: selectIsAuthenticating,
    redirectAction: routerActions.replace,
    redirectPath: (_, props) => locationHelper.getRedirectQueryParam(props) || rootPath,
    wrapperDisplayName: 'LoginGuard',
  })(Component);
github Kamahl19 / react-starter / src / features / auth / guards / IsLoggedIn.ts View on Github external
const IsLoggedIn = (Component: ComponentType) =>
  connectedReduxRedirect({
    authenticatedSelector: selectIsLoggedIn,
    authenticatingSelector: selectIsAuthenticating,
    redirectAction: routerActions.replace,
    redirectPath: AUTH_ROUTER_PATHS.login,
    wrapperDisplayName: 'IsLoggedIn',
  })(Component);
github Kamahl19 / react-starter / src / features / auth / guards / LogoutGuard.ts View on Github external
const LogoutGuard = (Component: ComponentType) =>
  connectedReduxRedirect({
    allowRedirectBack: false,
    authenticatedSelector: selectIsLoggedIn,
    authenticatingSelector: selectIsAuthenticating,
    redirectAction: routerActions.replace,
    redirectPath: AUTH_ROUTER_PATHS.login,
    wrapperDisplayName: 'LogoutGuard',
  })(Component);
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / components / Application.tsx View on Github external
const Loader = Loadable({
    ...loadableDefaults,
    loader: () => import('./common/PageLoading'),
});

const UserIsAuthenticated = connectedReduxRedirect({
    authenticatedSelector: (state: State) => !!state.user.data,
    authenticatingSelector: (state: State) => state.user.status.isLoading ,
    AuthenticatingComponent: Loader,
    redirectAction: routerActions.replace,
    wrapperDisplayName: 'UserIsAuthenticated',
    redirectPath: '/login',
});

const UserIsNotAuthenticated = connectedReduxRedirect({
    redirectAction: routerActions.replace,
    wrapperDisplayName: 'UserIsNotAuthenticated',
    authenticatedSelector: (state: State) => {
        const checked = !state.user.data && state.user.status.isLoading === false;
        return checked;
    },
    redirectPath: (state, ownProps: RouteComponentProps<{}, {}>) => {
        const {redirect, next} = queryString.parse(ownProps.location.search);
        return (redirect || next) || '/dashboard';
    },
    allowRedirectBack: false,
});

const UserCanViewErrorPage = connectedReduxRedirect({
    redirectAction: routerActions.replace,
    wrapperDisplayName: 'UserIsNotAuthenticated',
    authenticatedSelector: (state: State) => {
github Kamahl19 / react-starter / src / features / auth / guards / IsAnonymous.ts View on Github external
const IsAnonymous = (Component: ComponentType) =>
  connectedReduxRedirect({
    allowRedirectBack: false,
    authenticatedSelector: state => !selectIsLoggedIn(state),
    authenticatingSelector: selectIsAuthenticating,
    redirectAction: routerActions.replace,
    redirectPath: rootPath,
    wrapperDisplayName: 'IsAnonymous',
  })(Component);