diff --git a/src/modules/Core/App.tsx b/src/modules/Core/App.tsx index 1763db4..2867d36 100644 --- a/src/modules/Core/App.tsx +++ b/src/modules/Core/App.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { FunctionComponent } from 'react'; import { connect } from 'react-redux'; import Page from '@atlaskit/page'; @@ -8,26 +8,24 @@ import Sidebar from './Component/Layout/Sidebar'; import Loader from './Component/Loader'; import Toast from './Component/Layout/Toast'; -class App extends Component { - render() { - return ( - <> - { this.props.showLoader ? : ('') } -
- } - > - { this.props.children } - +const App: FunctionComponent = (props) => { + return ( + <> + {props.showLoader ? : ''} +
+ } + > + {props.children} + - -
- - ); - } -} + +
+ + ); +}; const mapStateToProps = (state: any): any => { const { isAuthenticated } = state.auth; diff --git a/src/modules/Core/Component/Form/ButtonBack.tsx b/src/modules/Core/Component/Form/ButtonBack.tsx index dad7b76..f9dd798 100644 --- a/src/modules/Core/Component/Form/ButtonBack.tsx +++ b/src/modules/Core/Component/Form/ButtonBack.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { FunctionComponent } from 'react'; import styled from 'styled-components'; import { Link } from 'react-router-dom'; import Button from '@atlaskit/button'; @@ -16,27 +16,23 @@ const StyledButtonWrapper = styled.div` font-size: 14px; `; -const ButtonWrapper = ({ children }: { - children: React.ReactNode; -}) => ( - - {children} - +const ButtonWrapper = ({ children }: { children: React.ReactNode }) => ( + {children} ); -class ButtonBack extends Component { - render() { - return ( - -

{this.props.titleBefore}

- - - - - -
- ); - } -} +const ButtonBack: FunctionComponent = (props) => { + return ( + +

{props.titleBefore}

+ + + + + +
+ ); +}; export default connect(null, null)(ButtonBack); diff --git a/src/modules/Core/Component/Form/Footer.tsx b/src/modules/Core/Component/Form/Footer.tsx index 73f9907..83e9432 100644 --- a/src/modules/Core/Component/Form/Footer.tsx +++ b/src/modules/Core/Component/Form/Footer.tsx @@ -1,19 +1,17 @@ -import React, { Component } from 'react'; +import React, { FunctionComponent } from 'react'; import { connect } from 'react-redux'; import { FormFooter as AFormFooter } from '@atlaskit/form'; import Button from '@atlaskit/button'; import CheckIcon from '@atlaskit/icon/glyph/check'; -class FormFooter extends Component { - render() { - return ( - - - - ); - } -} +const FormFooter: FunctionComponent = () => { + return ( + + + + ); +}; export default connect()(FormFooter); diff --git a/src/modules/Core/Component/Layout/Sidebar/SearchResults.tsx b/src/modules/Core/Component/Layout/Sidebar/SearchResults.tsx index 921a39c..93d4074 100644 --- a/src/modules/Core/Component/Layout/Sidebar/SearchResults.tsx +++ b/src/modules/Core/Component/Layout/Sidebar/SearchResults.tsx @@ -1,42 +1,34 @@ import PropTypes from 'prop-types'; -import React, { Component } from 'react'; +import React, { FunctionComponent } from 'react'; import { Link } from 'react-router-dom'; -export default class SearchResults extends Component { - static propTypes = { - matchingResults: PropTypes.arrayOf(PropTypes.object), - onResultClicked: PropTypes.func, - }; +const SearchResults: FunctionComponent = (props) => { + if (!props.matchingResults.length) { + return

Nothing found, keep on searching!

; + } + return ( +
    + {props.matchingResults.map((result: any) => ( +
  • + + {result.name} + + {result.description} +
  • + ))} +
+ ); +}; - render() { - if (!this.props.matchingResults.length) { - return ( -

Nothing found, keep on searching!

- ); - } +SearchResults.propTypes = { + matchingResults: PropTypes.arrayOf(PropTypes.object), + onResultClicked: PropTypes.func, +}; - return ( -
    - { - this.props.matchingResults.map((result: any) => ( -
  • - - {result.name} - - {result.description} -
  • - )) - } -
- ); - } -} +export default SearchResults; diff --git a/src/modules/Core/Component/Layout/Sidebar/index.tsx b/src/modules/Core/Component/Layout/Sidebar/index.tsx index 7b6d9ff..95eb450 100644 --- a/src/modules/Core/Component/Layout/Sidebar/index.tsx +++ b/src/modules/Core/Component/Layout/Sidebar/index.tsx @@ -1,55 +1,49 @@ -import React, { Component } from 'react'; +import React, { FunctionComponent, useState } from 'react'; -import { - LayoutManager, - NavigationProvider, - ThemeProvider, - dark, -} from '@atlaskit/navigation-next'; +import { LayoutManager, NavigationProvider, ThemeProvider, dark } from '@atlaskit/navigation-next'; import GlobalSidebar from 'modules/Core/Component/Layout/Sidebar/GlobalSidebar'; import ContainerNavigation from 'modules/Core/Component/Layout/Sidebar/ContainerNavigation'; import Notification from 'modules/Core/Component/Notification'; +import PropTypes from 'prop-types'; -class Sidebar extends Component { - static defaultProps = { - navLinks: [], +const Sidebar: FunctionComponent = (props) => { + const [state, setOffset] = useState({ offset: 0 }); + /* + TODO: Could not see where the current setOffset was being used so left this in here in case i missed something + setOffset = (value: any) => { + state = { + ...state, + offset: value, + }; }; +*/ + return ( + + ({ + ...theme, + mode: dark, + })} + > + } + topOffset={offset} + > +
{props.children}
+
+ +
+
+ ); +}; - constructor(props: any) { - super(props); - this.state = { offset: 0 }; - this.setOffset = this.setOffset.bind(this); - } - - setOffset(value: any) { - this.setState({ - ...this.state, - offset: value, - }); - } +Sidebar.propTypes = { + navLinks: PropTypes.array, +}; - render() { - return ( - - ({ - ...theme, mode: dark - })}> - - } - topOffset={this.state.offset} - > -
- {this.props.children} -
-
- -
-
- ); - } -} +Sidebar.defaultProps = { + navLinks: [], +}; export default Sidebar; diff --git a/src/modules/Core/Component/Layout/Toast.tsx b/src/modules/Core/Component/Layout/Toast.tsx index bb4fd4b..499a275 100644 --- a/src/modules/Core/Component/Layout/Toast.tsx +++ b/src/modules/Core/Component/Layout/Toast.tsx @@ -1,11 +1,9 @@ -import React, { PureComponent } from 'react'; +import React, { FunctionComponent } from 'react'; import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; -class Toast extends PureComponent { - render() { - return ; - } -} +const Toast: FunctionComponent = () => { + return ; +}; export default Toast; diff --git a/src/modules/Core/Component/Loader.tsx b/src/modules/Core/Component/Loader.tsx index 3e44785..1e26f77 100644 --- a/src/modules/Core/Component/Loader.tsx +++ b/src/modules/Core/Component/Loader.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { useState, FunctionComponent } from 'react'; import { css } from '@emotion/core'; import GridLoader from 'react-spinners/GridLoader'; @@ -11,28 +11,16 @@ const override = css` margin: 0px auto; `; -class Loader extends Component { - constructor(props: any) { - super(props); - this.state = { - loading: true, - }; - } +const Loader: FunctionComponent = () => { + const [loading] = useState(true); - render() { - return ( - <> -
- -
- - ); - } -} + return ( + <> +
+ +
+ + ); +}; export default Loader; diff --git a/src/modules/Core/Component/Modal/RemoveModal.tsx b/src/modules/Core/Component/Modal/RemoveModal.tsx index 7311ec4..a7d3cf7 100644 --- a/src/modules/Core/Component/Modal/RemoveModal.tsx +++ b/src/modules/Core/Component/Modal/RemoveModal.tsx @@ -1,37 +1,36 @@ -import React, { Component } from 'react'; +import React, { FunctionComponent } from 'react'; import Modal, { ModalTransition } from '@atlaskit/modal-dialog'; import { connect } from 'react-redux'; interface State { isOpen: string | null; + hide: () => void; } -class RemoveModal extends Component { - render() { - const actions = [ - { text: 'Remove', onClick: this.props.onRemove }, - { text: 'Cancel', onClick: this.props.hide }, - ]; +const RemoveModal: FunctionComponent = (props) => { + const actions = [ + { text: 'Remove', onClick: props.onRemove }, + { text: 'Cancel', onClick: props.hide }, + ]; - return ( - this.props.isOpen ? -
- - - Are you sure you want to remove this item ? - - -
- : '' - ); - } -} + return props.isOpen ? ( +
+ + + Are you sure you want to remove this item ? + + +
+ ) : ( + '' + ); +}; export default connect()(RemoveModal);