2019-05-22 14:59:57 +00:00
|
|
|
import React, { Component, Fragment } from 'react';
|
2019-06-03 12:41:45 +00:00
|
|
|
import { withNamespaces } from 'react-i18next';
|
2019-05-22 14:59:57 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2019-06-03 12:41:45 +00:00
|
|
|
import ClientsTable from './ClientsTable';
|
|
|
|
import AutoClients from './AutoClients';
|
|
|
|
import PageTitle from '../../ui/PageTitle';
|
|
|
|
import Loading from '../../ui/Loading';
|
2019-05-22 14:59:57 +00:00
|
|
|
|
|
|
|
class Clients extends Component {
|
|
|
|
render() {
|
2019-06-03 12:41:45 +00:00
|
|
|
const { dashboard, clients, t } = this.props;
|
2019-05-22 14:59:57 +00:00
|
|
|
|
|
|
|
return (
|
2019-06-03 12:41:45 +00:00
|
|
|
<Fragment>
|
|
|
|
<PageTitle title={t('clients_settings')} />
|
|
|
|
{!dashboard.processingTopStats || (!dashboard.processingClients && <Loading />)}
|
|
|
|
{!dashboard.processingTopStats && !dashboard.processingClients && (
|
|
|
|
<Fragment>
|
|
|
|
<ClientsTable
|
|
|
|
clients={dashboard.clients}
|
|
|
|
topStats={dashboard.topStats}
|
|
|
|
isModalOpen={clients.isModalOpen}
|
|
|
|
modalClientName={clients.modalClientName}
|
|
|
|
modalType={clients.modalType}
|
|
|
|
addClient={this.props.addClient}
|
|
|
|
updateClient={this.props.updateClient}
|
|
|
|
deleteClient={this.props.deleteClient}
|
|
|
|
toggleClientModal={this.props.toggleClientModal}
|
|
|
|
processingAdding={clients.processingAdding}
|
|
|
|
processingDeleting={clients.processingDeleting}
|
|
|
|
processingUpdating={clients.processingUpdating}
|
|
|
|
/>
|
|
|
|
<AutoClients
|
|
|
|
autoClients={dashboard.autoClients}
|
|
|
|
topStats={dashboard.topStats}
|
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
</Fragment>
|
2019-05-22 14:59:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Clients.propTypes = {
|
|
|
|
t: PropTypes.func.isRequired,
|
2019-06-03 12:41:45 +00:00
|
|
|
dashboard: PropTypes.object.isRequired,
|
2019-05-22 14:59:57 +00:00
|
|
|
clients: PropTypes.array.isRequired,
|
|
|
|
topStats: PropTypes.object.isRequired,
|
|
|
|
toggleClientModal: PropTypes.func.isRequired,
|
|
|
|
deleteClient: PropTypes.func.isRequired,
|
|
|
|
addClient: PropTypes.func.isRequired,
|
|
|
|
updateClient: PropTypes.func.isRequired,
|
|
|
|
isModalOpen: PropTypes.bool.isRequired,
|
|
|
|
modalType: PropTypes.string.isRequired,
|
|
|
|
modalClientName: PropTypes.string.isRequired,
|
|
|
|
processingAdding: PropTypes.bool.isRequired,
|
|
|
|
processingDeleting: PropTypes.bool.isRequired,
|
|
|
|
processingUpdating: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withNamespaces()(Clients);
|