From 6e10ed0721ee63d9a79286a93c6b5985299554c3 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Tue, 9 Feb 2021 13:56:37 +0200 Subject: [PATCH] refactoring: inventory adjustments list. refactoring: items categories list. --- .../ItemCategoryDialog/ItemCategoryForm.js | 6 +- .../InventoryAdjustmentDataTable.js | 195 ------------------ .../InventoryAdjustmentList.js | 17 +- .../InventoryAdjustmentTable.js | 101 +++++++++ .../InventoryAdjustmentView.js | 13 +- .../InventoryAdjustmentsAlerts.js | 2 +- .../InventoryAdjustmentsProvider.js | 14 +- .../InventoryAdjustments/components.js | 150 +++++++++----- .../withInventoryAdjustmentActions.js | 21 +- .../withInventoryAdjustments.js | 23 +-- .../ItemsCategories/ItemCategoriesList.js | 5 +- .../ItemsCategories/ItemCategoriesTable.js | 85 ++++---- .../ItemsCategories/ItemCategoriesViewPage.js | 47 ----- .../ItemsCategoriesProvider.js | 9 +- .../ItemsCategoryActionsBar.js | 10 +- .../containers/ItemsCategories/components.js | 41 ++++ .../ItemsCategories/withItemCategories.js | 15 +- .../withItemCategoriesActions.js | 35 +--- .../src/hooks/query/inventoryAdjustments.js | 41 ++-- client/src/hooks/query/items.js | 3 + client/src/hooks/query/itemsCategories.js | 78 +++---- .../inventoryAdjustment.actions.js | 94 +-------- .../inventoryAdjustment.reducer.js | 70 +------ .../inventoryAdjustment.selector.js | 51 +---- .../inventoryAdjustment.type.js | 17 +- .../ItemsCategories.selectors.js | 33 +-- .../itemCategories/itemsCategory.actions.js | 107 +--------- .../itemCategories/itemsCategory.reducer.js | 57 +---- .../itemCategories/itemsCategory.type.js | 9 +- client/src/store/reducers.js | 4 +- client/src/utils.js | 8 +- .../Inventory/InventoryAdjustments.ts | 18 +- 32 files changed, 497 insertions(+), 882 deletions(-) delete mode 100644 client/src/containers/InventoryAdjustments/InventoryAdjustmentDataTable.js create mode 100644 client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js delete mode 100644 client/src/containers/ItemsCategories/ItemCategoriesViewPage.js diff --git a/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js b/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js index bcb8981be..df4561014 100644 --- a/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js +++ b/client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js @@ -67,7 +67,7 @@ function ItemCategoryForm({ const afterSubmit = () => { closeDialog(dialogName); }; - // Handle the response success/ + // Handle the response success. const onSuccess = ({ response }) => { AppToaster.show({ message: formatMessage({ @@ -80,7 +80,9 @@ function ItemCategoryForm({ afterSubmit(response); }; // Handle the response error. - const onError = (errors) => { + const onError = (error) => { + const { response: { data: { errors } } } = error; + transformErrors(errors, { setErrors }); setSubmitting(false); }; diff --git a/client/src/containers/InventoryAdjustments/InventoryAdjustmentDataTable.js b/client/src/containers/InventoryAdjustments/InventoryAdjustmentDataTable.js deleted file mode 100644 index 4a2ce1330..000000000 --- a/client/src/containers/InventoryAdjustments/InventoryAdjustmentDataTable.js +++ /dev/null @@ -1,195 +0,0 @@ - import React, { useCallback, useMemo } from 'react'; -import { - Button, - Popover, - Menu, - Intent, - MenuItem, - MenuDivider, - Position, -} from '@blueprintjs/core'; -import { useIntl } from 'react-intl'; -import moment from 'moment'; -import classNames from 'classnames'; -import { withRouter } from 'react-router-dom'; - -import { DataTable, Icon } from 'components'; -import { CLASSES } from 'common/classes'; -import { - PublishAccessor, - TypeAccessor, -} from './components'; - -import withDialogActions from 'containers/Dialog/withDialogActions'; -import withInventoryAdjustmentActions from './withInventoryAdjustmentActions'; - -import { compose, saveInvoke } from 'utils'; - -function InventoryAdjustmentDataTable({ - // withInventoryAdjustmentsActions - addInventoryAdjustmentTableQueries, - - // #ownProps - isLoading, - inventoryAdjustments, - pagination, - onDeleteInventoryAdjustment, - onSelectedRowsChange, -}) { - const { formatMessage } = useIntl(); - - const handleDeleteInventoryAdjustment = useCallback( - (_adjustment) => () => { - saveInvoke(onDeleteInventoryAdjustment, _adjustment); - }, - [onDeleteInventoryAdjustment], - ); - - const actionMenuList = useCallback( - (adjustment) => ( - - } - text={formatMessage({ id: 'view_details' })} - /> - - } - /> - - ), - [handleDeleteInventoryAdjustment, formatMessage], - ); - - const onRowContextMenu = useCallback( - (cell) => actionMenuList(cell.row.original), - [actionMenuList], - ); - - const columns = useMemo( - () => [ - { - id: 'date', - Header: formatMessage({ id: 'date' }), - accessor: (r) => moment(r.date).format('YYYY MMM DD'), - width: 115, - className: 'date', - }, - { - id: 'type', - Header: formatMessage({ id: 'type' }), - accessor: TypeAccessor, - className: 'type', - width: 100, - }, - { - id: 'reason', - Header: formatMessage({ id: 'reason' }), - accessor: 'reason', - className: 'reason', - width: 115, - }, - { - id: 'reference_no', - Header: formatMessage({ id: 'reference_no' }), - accessor: 'reference_no', - className: 'reference_no', - width: 100, - }, - { - id: 'publish', - Header: formatMessage({ id: 'status' }), - accessor: PublishAccessor, - width: 95, - className: 'publish', - }, - { - id: 'description', - Header: formatMessage({ id: 'description' }), - accessor: 'description', - disableSorting: true, - width: 85, - className: 'description', - }, - { - id: 'created_at', - Header: formatMessage({ id: 'created_at' }), - accessor: (r) => moment(r.created_at).format('YYYY MMM DD'), - width: 125, - className: 'created_at', - }, - { - id: 'actions', - Header: '', - Cell: ({ cell }) => ( - -