diff --git a/client/src/components/CategoriesSelectList.js b/client/src/components/CategoriesSelectList.js
new file mode 100644
index 000000000..1b7022bed
--- /dev/null
+++ b/client/src/components/CategoriesSelectList.js
@@ -0,0 +1,49 @@
+import React, { useCallback } from 'react';
+import { FormattedMessage as T } from 'react-intl';
+import { ListSelect } from 'components';
+import { MenuItem } from '@blueprintjs/core';
+
+export default function CategoriesSelectList({
+ categoriesList,
+ selecetedCategoryId,
+ defaultSelectText = ,
+ onCategorySelected,
+ ...restProps
+}) {
+
+ // Filter Items Category
+ const filterItemCategory = (query, item, _index, exactMatch) => {
+ const normalizedTitle = item.name.toLowerCase();
+ const normalizedQuery = query.toLowerCase();
+ if (exactMatch) {
+ return normalizedTitle === normalizedQuery;
+ } else {
+ return `${item.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
+ }
+ };
+
+ const handleItemCategorySelected = useCallback(
+ (ItemCategory) => onCategorySelected && onCategorySelected(ItemCategory),
+ [],
+ );
+ const categoryItem = useCallback(
+ (item, { handleClick }) => (
+
+ ),
+ [],
+ );
+
+ return (
+
+ );
+}
diff --git a/client/src/components/index.js b/client/src/components/index.js
index 45bacda7c..ffdd3a48c 100644
--- a/client/src/components/index.js
+++ b/client/src/components/index.js
@@ -25,6 +25,8 @@ import Dialog from './Dialog/Dialog';
import DialogContent from './Dialog/DialogContent';
import DialogSuspense from './Dialog/DialogSuspense';
import InputPrependButton from './Forms/InputPrependButton';
+import CategoriesSelectList from './CategoriesSelectList';
+
const Hint = FieldHint;
export {
@@ -55,5 +57,6 @@ export {
Dialog,
DialogContent,
DialogSuspense,
- InputPrependButton
-};
\ No newline at end of file
+ InputPrependButton,
+ CategoriesSelectList
+};
diff --git a/client/src/containers/Customers/Customer.js b/client/src/containers/Customers/Customer.js
index c179fc8f5..c0f263f57 100644
--- a/client/src/containers/Customers/Customer.js
+++ b/client/src/containers/Customers/Customer.js
@@ -17,6 +17,7 @@ function Customer({
formik,
//#withCustomersActions
requestFetchCustomers,
+ requestFetchCustomer,
}) {
const { id } = useParams();
const history = useHistory();
@@ -26,11 +27,12 @@ function Customer({
requestFetchCustomers({}),
);
// Handle fetch customer details.
- const fetchCustomer= useQuery(['customer', id], () =>
- requestFetchCustomers(),
- { enabled: !!id },
+ const fetchCustomer = useQuery(
+ ['customer', id],
+ (key, customerId) => requestFetchCustomer(customerId),
+ { enabled: id && id },
);
-
+
const handleFormSubmit = useCallback(
(payload) => {
payload.redirect && history.push('/customers');
diff --git a/client/src/containers/Customers/withCustomersActions.js b/client/src/containers/Customers/withCustomersActions.js
index 590004dd3..ae3808859 100644
--- a/client/src/containers/Customers/withCustomersActions.js
+++ b/client/src/containers/Customers/withCustomersActions.js
@@ -1,20 +1,21 @@
import { connect } from 'react-redux';
import {
fetchCustomers,
+ fetchCustomer,
submitCustomer,
editCustomer,
deleteCustomer,
- deleteBulkCustomers
+ deleteBulkCustomers,
} from 'store/customers/customers.actions';
import t from 'store/types';
export const mapDispatchToProps = (dispatch) => ({
requestFetchCustomers: (query) => dispatch(fetchCustomers({ query })),
requestDeleteCustomer: (id) => dispatch(deleteCustomer({ id })),
- requestDeleteBulkCustomers:(ids)=>dispatch(deleteBulkCustomers({ids})),
+ requestDeleteBulkCustomers: (ids) => dispatch(deleteBulkCustomers({ ids })),
requestSubmitCustomer: (form) => dispatch(submitCustomer({ form })),
requestEditCustomer: (id, form) => dispatch(editCustomer({ id, form })),
-
+ requestFetchCustomer: (id) => dispatch(fetchCustomer({ id })),
addCustomersTableQueries: (queries) =>
dispatch({
type: t.CUSTOMERS_TABLE_QUERIES_ADD,
diff --git a/client/src/containers/Items/ItemCategoriesTable.js b/client/src/containers/Items/ItemCategoriesTable.js
index 518400615..4347e9965 100644
--- a/client/src/containers/Items/ItemCategoriesTable.js
+++ b/client/src/containers/Items/ItemCategoriesTable.js
@@ -50,6 +50,7 @@ const ItemsCategoryList = ({
(category) => (