Skip to content

Commit

Permalink
Refactor RasAppCore component to use TypeScript and update props
Browse files Browse the repository at this point in the history
  • Loading branch information
wduckitt committed May 2, 2024
1 parent cd1828d commit 7484203
Showing 1 changed file with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,46 @@ import ReactVisCssBaseline from './ReactVisCssBaseline';
import AutomationStudioContext from './AutomationStudioContext';
import { io } from 'socket.io-client';
import RasCssBaseline from './RasCssBaseline';
import PropTypes from 'prop-types';
import { GoogleOAuthProvider } from '@react-oauth/google';
import axios from 'axios';
/**
* Props for the RasAppCore component.
*/
interface RasAppCoreProps {
/**
* The default theme for the component.
*/
defaultTheme: string;

/**
* An object containing different themes.
*/
themes: { [key: string]: any };

/**
* The timeout for the login process (optional).
*/
loginTimeout?: number;

/**
* The children components to be rendered.
*/
children: React.ReactNode;
}

/**
* Represents the state of the RasAppCore component.
*/
interface RasAppCoreState {
theme: any;
system: any;
redirectToLoginPage: boolean;
Authenticated: boolean;
AuthenticationFailed: boolean;
}

class RasAppCore extends Component<RasAppCoreProps, RasAppCoreState> {

class RasAppCore extends Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -308,7 +343,7 @@ class RasAppCore extends Component {

componentDidMount() {
window.addEventListener('storage', this.handleLocalStorageChange)
setTimeout(this.clearLoggingIn, this.props.loginTimeout)
setTimeout(this.clearLoggingIn, this.props.loginTimeout?this.props.loginTimeout:10000)
this.getInitialRefreshToken();
let socket = this.state.system.socket;
socket.on('redirectToLogIn', this.handleRedirectToLogIn);
Expand Down Expand Up @@ -345,13 +380,7 @@ class RasAppCore extends Component {
}
}

RasAppCore.propTypes = {
/** login Timeout */
loginTimeout: PropTypes.number,
}

RasAppCore.defaultProps = {
loginTimeout: 10000
}


export default RasAppCore

0 comments on commit 7484203

Please sign in to comment.