Skip to content

Commit

Permalink
perf(customer): export pop-ups data for customer list when filtering …
Browse files Browse the repository at this point in the history
…by pop ups

Closes #1674
  • Loading branch information
munkhjin0223 committed Feb 8, 2020
1 parent cfbfb4a commit a62308b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
13 changes: 10 additions & 3 deletions ui/src/modules/customers/components/list/CustomersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface IProps extends IRouterProps {
}
) => Promise<void>;
queryParams: any;
exportCustomers: (bulk: string[]) => void;
exportData: (bulk: Array<{ _id: string }>, popupData: boolean) => void;
responseId: string;
}

Expand Down Expand Up @@ -170,7 +170,7 @@ class CustomersList extends React.Component<IProps, State> {
location,
history,
queryParams,
exportCustomers,
exportData,
mergeCustomerLoading
} = this.props;

Expand Down Expand Up @@ -245,10 +245,17 @@ class CustomersList extends React.Component<IProps, State> {
</Link>
</li>
<li>
<a href="#export" onClick={exportCustomers.bind(this, bulk)}>
<a href="#export" onClick={exportData.bind(this, bulk, false)}>
{__('Export customers')}
</a>
</li>
{queryParams.form && (
<li>
<a href="#export" onClick={exportData.bind(this, bulk, true)}>
{__('Export Pop-Ups data')}
</a>
</li>
)}
</Dropdown.Menu>
</Dropdown>
<Link to="/settings/importHistories?type=customer">
Expand Down
14 changes: 10 additions & 4 deletions ui/src/modules/customers/containers/CustomersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CustomerListContainer extends React.Component<FinalProps, State> {
});
};

const exportCustomers = bulk => {
const exportData = (bulk: Array<{ _id: string }>, popupData: boolean) => {
const { REACT_APP_API_URL } = getEnv();
const { queryParams } = this.props;

Expand All @@ -121,10 +121,16 @@ class CustomerListContainer extends React.Component<FinalProps, State> {
queryParams.ids = bulk.map(customer => customer._id);
}

const stringified = queryString.stringify({
const exportQuery = {
...queryParams,
type: 'customer'
});
};

if (popupData) {
exportQuery.popupData = true;
}

const stringified = queryString.stringify(exportQuery);

window.open(`${REACT_APP_API_URL}/file-export?${stringified}`, '_blank');
};
Expand All @@ -139,7 +145,7 @@ class CustomerListContainer extends React.Component<FinalProps, State> {
columnsConfig,
customers: list,
totalCount,
exportCustomers,
exportData,
integrations: KIND_CHOICES.ALL_LIST,
searchValue,
loading: customersMainQuery.loading || this.state.loading,
Expand Down

0 comments on commit a62308b

Please sign in to comment.