This commit is contained in:
a.bouhuolia
2021-09-08 16:32:59 +02:00
49 changed files with 305 additions and 216 deletions

View File

@@ -14,7 +14,7 @@ import CustomerFormAfterPrimarySection from './CustomerFormAfterPrimarySection';
import CustomersTabs from './CustomersTabs';
import CustomerFloatingActions from './CustomerFloatingActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose, transformToForm } from 'utils';
import { useCustomerFormContext } from './CustomerFormProvider';
@@ -59,10 +59,7 @@ const defaultInitialValues = {
/**
* Customer form.
*/
function CustomerForm({
// #withSettings
baseCurrency,
}) {
function CustomerForm({ organization: { base_currency } }) {
const {
customer,
customerId,
@@ -75,7 +72,6 @@ function CustomerForm({
// const isNewMode = !customerId;
const history = useHistory();
/**
* Initial values in create and edit mode.
@@ -83,10 +79,10 @@ function CustomerForm({
const initialValues = useMemo(
() => ({
...defaultInitialValues,
currency_code: baseCurrency,
currency_code: base_currency,
...transformToForm(contactDuplicate || customer, defaultInitialValues),
}),
[customer, contactDuplicate, baseCurrency],
[customer, contactDuplicate, base_currency],
);
//Handles the form submit.
@@ -153,8 +149,4 @@ function CustomerForm({
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(CustomerForm);
export default compose(withCurrentOrganization())(CustomerForm);

View File

@@ -95,6 +95,11 @@ function CustomersTable({
openDrawer('contact-detail-drawer', { contactId: id });
};
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('contact-detail-drawer', { contactId: cell.row.original.id });
};
if (isEmptyStatus) {
return <CustomersEmptyStatus />;
}
@@ -122,6 +127,7 @@ function CustomersTable({
autoResetPage={false}
TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader}
onCellClick={handleCellClick}
payload={{
onDelete: handleCustomerDelete,
onEdit: handleCustomerEdit,

View File

@@ -104,6 +104,7 @@ export function useCustomersTableColumns() {
width: 45,
disableResizing: true,
disableSortBy: true,
clickable: true,
},
{
id: 'display_name',
@@ -111,6 +112,7 @@ export function useCustomersTableColumns() {
accessor: 'display_name',
className: 'display_name',
width: 150,
clickable: true,
},
{
id: 'company_name',
@@ -118,6 +120,7 @@ export function useCustomersTableColumns() {
accessor: 'company_name',
className: 'company_name',
width: 150,
clickable: true,
},
{
id: 'work_phone',
@@ -125,6 +128,7 @@ export function useCustomersTableColumns() {
accessor: PhoneNumberAccessor,
className: 'phone_number',
width: 100,
clickable: true,
},
{
id: 'balance',
@@ -132,6 +136,7 @@ export function useCustomersTableColumns() {
accessor: BalanceAccessor,
className: 'receivable_balance',
width: 100,
clickable: true,
},
],
[],