2019-05-22 14:59:57 +00:00
|
|
|
import React, { Component, Fragment } from 'react';
|
2020-05-22 14:06:05 +00:00
|
|
|
import { withTranslation } 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 {
|
2019-06-05 12:49:01 +00:00
|
|
|
componentDidMount() {
|
|
|
|
this.props.getClients();
|
2019-08-22 13:10:47 +00:00
|
|
|
this.props.getStats();
|
2019-06-05 12:49:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-22 14:59:57 +00:00
|
|
|
render() {
|
2019-06-03 13:08:50 +00:00
|
|
|
const {
|
|
|
|
t,
|
|
|
|
dashboard,
|
2019-08-22 13:10:47 +00:00
|
|
|
stats,
|
2019-06-03 13:08:50 +00:00
|
|
|
clients,
|
|
|
|
addClient,
|
|
|
|
updateClient,
|
|
|
|
deleteClient,
|
|
|
|
toggleClientModal,
|
2020-01-13 14:41:59 +00:00
|
|
|
getStats,
|
2019-06-03 13:08:50 +00:00
|
|
|
} = this.props;
|
2019-05-22 14:59:57 +00:00
|
|
|
|
|
|
|
return (
|
2019-06-03 12:41:45 +00:00
|
|
|
<Fragment>
|
2019-06-06 14:45:24 +00:00
|
|
|
<PageTitle title={t('client_settings')} />
|
2019-08-22 13:10:47 +00:00
|
|
|
{(stats.processingStats || dashboard.processingClients) && <Loading />}
|
|
|
|
{!stats.processingStats && !dashboard.processingClients && (
|
2019-06-03 12:41:45 +00:00
|
|
|
<Fragment>
|
|
|
|
<ClientsTable
|
|
|
|
clients={dashboard.clients}
|
2019-12-20 11:15:57 +00:00
|
|
|
normalizedTopClients={stats.normalizedTopClients}
|
2019-06-03 12:41:45 +00:00
|
|
|
isModalOpen={clients.isModalOpen}
|
|
|
|
modalClientName={clients.modalClientName}
|
|
|
|
modalType={clients.modalType}
|
2019-06-03 13:08:50 +00:00
|
|
|
addClient={addClient}
|
|
|
|
updateClient={updateClient}
|
|
|
|
deleteClient={deleteClient}
|
|
|
|
toggleClientModal={toggleClientModal}
|
2019-06-03 12:41:45 +00:00
|
|
|
processingAdding={clients.processingAdding}
|
|
|
|
processingDeleting={clients.processingDeleting}
|
|
|
|
processingUpdating={clients.processingUpdating}
|
2020-01-13 14:41:59 +00:00
|
|
|
getStats={getStats}
|
2020-01-28 11:07:47 +00:00
|
|
|
supportedTags={dashboard.supportedTags}
|
2019-06-03 12:41:45 +00:00
|
|
|
/>
|
|
|
|
<AutoClients
|
|
|
|
autoClients={dashboard.autoClients}
|
2019-12-20 11:15:57 +00:00
|
|
|
normalizedTopClients={stats.normalizedTopClients}
|
2019-06-03 12:41:45 +00:00
|
|
|
/>
|
|
|
|
</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-08-22 13:10:47 +00:00
|
|
|
stats: PropTypes.object.isRequired,
|
2019-06-03 13:08:50 +00:00
|
|
|
clients: PropTypes.object.isRequired,
|
2019-05-22 14:59:57 +00:00
|
|
|
toggleClientModal: PropTypes.func.isRequired,
|
|
|
|
deleteClient: PropTypes.func.isRequired,
|
|
|
|
addClient: PropTypes.func.isRequired,
|
|
|
|
updateClient: PropTypes.func.isRequired,
|
2019-06-05 12:49:01 +00:00
|
|
|
getClients: PropTypes.func.isRequired,
|
2019-08-22 13:10:47 +00:00
|
|
|
getStats: PropTypes.func.isRequired,
|
2019-05-22 14:59:57 +00:00
|
|
|
};
|
|
|
|
|
2020-05-22 14:06:05 +00:00
|
|
|
export default withTranslation()(Clients);
|