* chore: code split sagas and reducers index file * fix: update imports * chore: remove acl reducers file on ce * fix: code split reducers properly * chore: remove unnecessary import * chore: split root sagas file
36 lines
1.1 KiB
TypeScript
Executable File
36 lines
1.1 KiB
TypeScript
Executable File
import React from "react";
|
|
import { AppState } from "@appsmith/reducers";
|
|
import { getCurrentUser, getUserAuthError } from "selectors/usersSelectors";
|
|
import { connect } from "react-redux";
|
|
import { ANONYMOUS_USERNAME, User } from "constants/userConstants";
|
|
import { Redirect } from "react-router";
|
|
import { APPLICATIONS_URL, AUTH_LOGIN_URL, BASE_URL } from "constants/routes";
|
|
import PageLoadingBar from "pages/common/PageLoadingBar";
|
|
import ServerUnavailable from "pages/common/ServerUnavailable";
|
|
|
|
type Props = {
|
|
user?: User;
|
|
authError: string;
|
|
};
|
|
|
|
function LandingScreen(props: Props) {
|
|
if (props.user && window.location.pathname === BASE_URL) {
|
|
if (props.user.email === ANONYMOUS_USERNAME) {
|
|
return <Redirect to={AUTH_LOGIN_URL} />;
|
|
} else {
|
|
return <Redirect to={APPLICATIONS_URL} />;
|
|
}
|
|
}
|
|
if (props.authError && props.authError.length) {
|
|
return <ServerUnavailable />;
|
|
}
|
|
return <PageLoadingBar />;
|
|
}
|
|
|
|
const mapStateToProps = (state: AppState) => ({
|
|
user: getCurrentUser(state),
|
|
authError: getUserAuthError(state),
|
|
});
|
|
|
|
export default connect(mapStateToProps)(LandingScreen);
|