From f35b4716a9743f2aeec193753670c21f1485edab Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Wed, 17 Jun 2020 15:56:46 +0200 Subject: [PATCH] WIP feature/Customers --- client/src/config/sidebarMenu.js | 2 +- client/src/containers/Customers/Customer.js | 29 +- .../Customers/CustomerActionsBar.js | 132 +++++++ .../Customers/CustomerAddressTabs.js | 246 ++++++++++++ .../Customers/CustomerAttachmentTabs.js | 23 ++ .../src/containers/Customers/CustomerForm.js | 361 +++++++++++++++--- .../containers/Customers/CustomerNotTabs.js | 36 ++ .../src/containers/Customers/CustomerTable.js | 164 ++++++++ .../src/containers/Customers/CustomersList.js | 232 +++++++++++ .../src/containers/Customers/CustomersTabs.js | 41 ++ .../Customers/withCustomersActions.js | 5 +- client/src/lang/en/index.js | 32 +- client/src/routes/dashboard.js | 7 +- .../src/store/customers/customers.actions.js | 16 + .../src/store/customers/customers.reducer.js | 6 +- .../store/customers/customers.selectors.js | 2 +- client/src/style/pages/customer.scss | 95 ++++- 17 files changed, 1358 insertions(+), 71 deletions(-) create mode 100644 client/src/containers/Customers/CustomerActionsBar.js create mode 100644 client/src/containers/Customers/CustomerAddressTabs.js create mode 100644 client/src/containers/Customers/CustomerAttachmentTabs.js create mode 100644 client/src/containers/Customers/CustomerNotTabs.js create mode 100644 client/src/containers/Customers/CustomerTable.js create mode 100644 client/src/containers/Customers/CustomersList.js create mode 100644 client/src/containers/Customers/CustomersTabs.js diff --git a/client/src/config/sidebarMenu.js b/client/src/config/sidebarMenu.js index 338df7efc..72ace0b7b 100644 --- a/client/src/config/sidebarMenu.js +++ b/client/src/config/sidebarMenu.js @@ -134,7 +134,7 @@ export default [ children: [ { text: , - // href: '/', + href: '/customers', }, { text: , diff --git a/client/src/containers/Customers/Customer.js b/client/src/containers/Customers/Customer.js index 021d3b33e..e4a8e237b 100644 --- a/client/src/containers/Customers/Customer.js +++ b/client/src/containers/Customers/Customer.js @@ -6,15 +6,36 @@ import DashboardInsider from 'components/Dashboard/DashboardInsider'; import CustomerForm from 'containers/Customers/CustomerForm'; import withDashboardActions from 'containers/Dashboard/withDashboardActions'; +import withCustomersActions from './withCustomersActions'; import { compose } from 'utils'; -function Customer({}) { +function Customer({ + // #withDashboardActions + changePageTitle, + + formik, + //#withCustomersActions + requestFetchCustomers, +}) { + const { id } = useParams(); + const history = useHistory(); + + const fetchCustomers = useQuery('customers-list', () => + requestFetchCustomers({}), + ); + + const fetchCustomerDatails =useQuery(id && ['customer-detail',id],()=>requestFetchCustomers()) + return ( - - + + ); } -export default Customer; +export default compose(withDashboardActions, withCustomersActions)(Customer); diff --git a/client/src/containers/Customers/CustomerActionsBar.js b/client/src/containers/Customers/CustomerActionsBar.js new file mode 100644 index 000000000..8dae4374b --- /dev/null +++ b/client/src/containers/Customers/CustomerActionsBar.js @@ -0,0 +1,132 @@ +import React, { useCallback, useMemo, useState } from 'react'; +import { + NavbarGroup, + NavbarDivider, + Button, + Classes, + Intent, + Popover, + Position, + PopoverInteractionKind, +} from '@blueprintjs/core'; +import { FormattedMessage as T, useIntl } from 'react-intl'; +import classNames from 'classnames'; +import { connect } from 'react-redux'; +import { useHistory } from 'react-router-dom'; + +import Icon from 'components/Icon'; +import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; +import FilterDropdown from 'components/FilterDropdown'; +import { If } from 'components'; + +import withResourceDetail from 'containers/Resources/withResourceDetails'; +import withDashboardActions from 'containers/Dashboard/withDashboardActions'; +import addCustomersTableQueries from 'containers/Customers/withCustomersActions'; +import { compose } from 'utils'; +import withCustomersActions from 'containers/Customers/withCustomersActions'; + +const CustomerActionsBar = ({ + // #withResourceDetail + resourceFields, + + //#withCustomersActions + addCustomersTableQueries, + + // #ownProps + selectedRows = [], + onFilterChanged, + onBulkDelete, +}) => { + const [filterCount, setFilterCount] = useState(0); + const history = useHistory(); + const { formatMessage } = useIntl(); + + const onClickNewCustomer = useCallback(() => { + history.push('/customers/new'); + }, [history]); + + const filterDropdown = FilterDropdown({ + fields: resourceFields, + onFilterChange: (filterConditions) => { + setFilterCount(filterConditions.length || 0); + addCustomersTableQueries({ + filter_roles: filterConditions || '', + }); + onFilterChanged && onFilterChanged(filterConditions); + }, + }); + + const hasSelectedRows = useMemo(() => selectedRows.length > 0, [ + selectedRows, + ]); + + const handleBulkDelete = useCallback(() => { + onBulkDelete && onBulkDelete(selectedRows.map((r) => r.id)); + }, [onBulkDelete, selectedRows]); + + return ( + + + + + - diff --git a/client/src/containers/Customers/CustomerNotTabs.js b/client/src/containers/Customers/CustomerNotTabs.js new file mode 100644 index 000000000..554ef9c39 --- /dev/null +++ b/client/src/containers/Customers/CustomerNotTabs.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { + Button, + Classes, + FormGroup, + InputGroup, + Intent, + TextArea, + MenuItem, +} from '@blueprintjs/core'; +import { FormattedMessage as T, useIntl } from 'react-intl'; +import ErrorMessage from 'components/ErrorMessage'; + +const CustomerBillingAddress = ({ + formik: { errors, touched, setFieldValue, getFieldProps }, +}) => { + return ( +
+ } + // className={'form-group--description'} + intent={errors.note && touched.note && Intent.DANGER} + helperText={} + inline={true} + > +