diff --git a/client/src/containers/Alerts/Item/ItemActivateAlert.js b/client/src/containers/Alerts/Item/ItemActivateAlert.js
new file mode 100644
index 000000000..8af112266
--- /dev/null
+++ b/client/src/containers/Alerts/Item/ItemActivateAlert.js
@@ -0,0 +1,77 @@
+import React from 'react';
+import {
+ FormattedMessage as T,
+ useIntl,
+} from 'react-intl';
+import { Intent, Alert } from '@blueprintjs/core';
+import { queryCache } from 'react-query';
+import { AppToaster } from 'components';
+
+import withItemsActions from 'containers/Items/withItemsActions';
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Item activate alert.
+ */
+function ItemActivateAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { itemId },
+
+ // #withItemsActions
+ requestActivateItem,
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { formatMessage } = useIntl();
+
+ // Handle activate item alert cancel.
+ const handleCancelActivateItem = () => {
+ closeAlert(name);
+ };
+
+ // Handle confirm item activated.
+ const handleConfirmItemActivate = () => {
+ requestActivateItem(itemId)
+ .then(() => {
+ closeAlert(name);
+ AppToaster.show({
+ message: formatMessage({
+ id: 'the_item_has_been_activated_successfully',
+ }),
+ intent: Intent.SUCCESS,
+ });
+ queryCache.invalidateQueries('items-table');
+ })
+ .catch((error) => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={}
+ intent={Intent.WARNING}
+ isOpen={isOpen}
+ onCancel={handleCancelActivateItem}
+ onConfirm={handleConfirmItemActivate}
+ >
+
+
+
+
+ );
+}
+
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+ withItemsActions,
+)(ItemActivateAlert);
diff --git a/client/src/containers/Alerts/Item/ItemBulkDeleteAlert.js b/client/src/containers/Alerts/Item/ItemBulkDeleteAlert.js
new file mode 100644
index 000000000..0aa178eb5
--- /dev/null
+++ b/client/src/containers/Alerts/Item/ItemBulkDeleteAlert.js
@@ -0,0 +1,74 @@
+import React from 'react';
+import { FormattedMessage as T, useIntl } from 'react-intl';
+import { Intent, Alert } from '@blueprintjs/core';
+import { AppToaster } from 'components';
+
+import withItemsActions from 'containers/Items/withItemsActions';
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Item bulk delete alert.
+ */
+function ItemBulkDeleteAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { itemsIds },
+
+ // #withItemsActions
+ requestDeleteBulkItems,
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { formatMessage } = useIntl();
+
+ // handle cancel item bulk delete alert.
+ const handleCancelBulkDelete = () => {
+ closeAlert(name);
+ };
+ // Handle confirm items bulk delete.
+ const handleConfirmBulkDelete = () => {
+ requestDeleteBulkItems(itemsIds)
+ .then(() => {
+ closeAlert(name);
+ AppToaster.show({
+ message: formatMessage({
+ id: 'the_items_has_been_deleted_successfully',
+ }),
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch((errors) => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={
+
+ }
+ icon="trash"
+ intent={Intent.DANGER}
+ isOpen={isOpen}
+ onCancel={handleCancelBulkDelete}
+ onConfirm={handleConfirmBulkDelete}
+ >
+
+
+
+
+ );
+}
+
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+ withItemsActions,
+)(ItemBulkDeleteAlert);
diff --git a/client/src/containers/Alerts/Item/ItemDeleteAlert.js b/client/src/containers/Alerts/Item/ItemDeleteAlert.js
new file mode 100644
index 000000000..529caa4aa
--- /dev/null
+++ b/client/src/containers/Alerts/Item/ItemDeleteAlert.js
@@ -0,0 +1,83 @@
+import React from 'react';
+import {
+ FormattedMessage as T,
+ FormattedHTMLMessage,
+ useIntl,
+} from 'react-intl';
+import { Intent, Alert } from '@blueprintjs/core';
+import { queryCache } from 'react-query';
+import { AppToaster } from 'components';
+
+import { handleDeleteErrors } from 'containers/Items/utils';
+
+import withItemsActions from 'containers/Items/withItemsActions';
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Item delete alerts.
+ */
+function ItemDeleteAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { itemId },
+
+ // #withItemsActions
+ requestDeleteItem,
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { formatMessage } = useIntl();
+
+ // handle cancel delete item alert.
+ const handleCancelItemDelete = () => {
+ closeAlert(name);
+ };
+
+ const handleConfirmDeleteItem = () => {
+ requestDeleteItem(itemId)
+ .then(() => {
+ closeAlert(name);
+ AppToaster.show({
+ message: formatMessage({
+ id: 'the_item_has_been_deleted_successfully',
+ }),
+ intent: Intent.SUCCESS,
+ });
+ queryCache.invalidateQueries('items-table');
+ })
+ .catch(({ errors }) => {
+ handleDeleteErrors(errors);
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={}
+ icon="trash"
+ intent={Intent.DANGER}
+ isOpen={isOpen}
+ onCancel={handleCancelItemDelete}
+ onConfirm={handleConfirmDeleteItem}
+ >
+
+
+
+
+ );
+}
+
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+ withItemsActions,
+)(ItemDeleteAlert);
diff --git a/client/src/containers/Alerts/Item/ItemInactivateAlert.js b/client/src/containers/Alerts/Item/ItemInactivateAlert.js
new file mode 100644
index 000000000..975f2ca00
--- /dev/null
+++ b/client/src/containers/Alerts/Item/ItemInactivateAlert.js
@@ -0,0 +1,77 @@
+import React from 'react';
+import {
+ FormattedMessage as T,
+ useIntl,
+} from 'react-intl';
+import { Intent, Alert } from '@blueprintjs/core';
+import { queryCache } from 'react-query';
+import { AppToaster } from 'components';
+
+import withItemsActions from 'containers/Items/withItemsActions';
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Item inactivate alert.
+ */
+function ItemInactivateAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { itemId },
+
+ // #withItemsActions
+ requestInactiveItem,
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { formatMessage } = useIntl();
+
+ // handle cancel inactivate alert.
+ const handleCancelInactivateItem = () => {
+ closeAlert(name);
+ };
+
+ // Handle confirm item Inactive.
+ const handleConfirmItemInactive = () => {
+ requestInactiveItem(itemId)
+ .then(() => {
+ closeAlert(name);
+ AppToaster.show({
+ message: formatMessage({
+ id: 'the_item_has_been_inactivated_successfully',
+ }),
+ intent: Intent.SUCCESS,
+ });
+ queryCache.invalidateQueries('items-table');
+ })
+ .catch((error) => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={}
+ intent={Intent.WARNING}
+ isOpen={isOpen}
+ onCancel={handleCancelInactivateItem}
+ onConfirm={handleConfirmItemInactive}
+ >
+
+
+
+
+ );
+}
+
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+ withItemsActions,
+)(ItemInactivateAlert);
diff --git a/client/src/containers/Items/ItemsActionsBar.js b/client/src/containers/Items/ItemsActionsBar.js
index 2e4897c37..33c159e87 100644
--- a/client/src/containers/Items/ItemsActionsBar.js
+++ b/client/src/containers/Items/ItemsActionsBar.js
@@ -22,6 +22,7 @@ import { If, DashboardActionViewsList } from 'components';
import withResourceDetail from 'containers/Resources/withResourceDetails';
import withItems from 'containers/Items/withItems';
import withItemsActions from './withItemsActions';
+import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
import { connect } from 'react-redux';
@@ -32,27 +33,23 @@ const ItemsActionsBar = ({
// #withItems
itemsViews,
+ itemsSelectedRows,
//#withItemActions
addItemsTableQueries,
changeItemsCurrentView,
+ // #withAlertActions
+ openAlert,
onFilterChanged,
- selectedRows = [],
- onBulkDelete,
}) => {
const { formatMessage } = useIntl();
const history = useHistory();
- const [filterCount, setFilterCount] = useState(0);
const onClickNewItem = useCallback(() => {
history.push('/items/new');
}, [history]);
- const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
- selectedRows,
- ]);
-
const filterDropdown = FilterDropdown({
fields: resourceFields,
initialCondition: {
@@ -68,10 +65,6 @@ const ItemsActionsBar = ({
},
});
- const handleBulkDelete = useCallback(() => {
- onBulkDelete && onBulkDelete(selectedRows.map((r) => r.id));
- }, [onBulkDelete, selectedRows]);
-
const handleTabChange = (viewId) => {
changeItemsCurrentView(viewId.id || -1);
addItemsTableQueries({
@@ -79,6 +72,11 @@ const ItemsActionsBar = ({
});
};
+ // Handle cancel/confirm items bulk.
+ const handleBulkDelete = () => {
+ openAlert('items-bulk-delete', { itemsIds: itemsSelectedRows });
+ };
+
return (
@@ -105,18 +103,12 @@ const ItemsActionsBar = ({
>
- ) : (
- `${filterCount} ${formatMessage({ id: 'filters_applied' })}`
- )
- }
+ text={`${formatMessage({ id: 'filters_applied' })}`}
icon={}
/>
-
+
}
@@ -149,11 +141,13 @@ const withItemsActionsBar = connect(mapStateToProps);
export default compose(
withItemsActionsBar,
- withItems(({ itemsViews }) => ({
+ withItems(({ itemsViews, itemsSelectedRows }) => ({
itemsViews,
+ itemsSelectedRows,
})),
withResourceDetail(({ resourceFields }) => ({
resourceFields,
})),
withItemsActions,
+ withAlertActions,
)(ItemsActionsBar);
diff --git a/client/src/containers/Items/ItemsAlerts.js b/client/src/containers/Items/ItemsAlerts.js
new file mode 100644
index 000000000..8046b865b
--- /dev/null
+++ b/client/src/containers/Items/ItemsAlerts.js
@@ -0,0 +1,19 @@
+import React from 'react';
+import ItemDeleteAlert from 'containers/Alerts/Item/ItemDeleteAlert';
+import ItemInactivateAlert from 'containers/Alerts/Item/ItemInactivateAlert';
+import ItemActivateAlert from 'containers/Alerts/Item/ItemActivateAlert';
+import ItemBulkDeleteAlert from 'containers/Alerts/Item/ItemBulkDeleteAlert';
+
+/**
+ * Items alert.
+ */
+export default function ItemsAlerts() {
+ return (
+
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Items/ItemsList.js b/client/src/containers/Items/ItemsList.js
index 593bc56c2..1283c93bb 100644
--- a/client/src/containers/Items/ItemsList.js
+++ b/client/src/containers/Items/ItemsList.js
@@ -1,22 +1,15 @@
import React, { useEffect, useCallback, useState, useMemo } from 'react';
-import { Route, Switch, useHistory } from 'react-router-dom';
-import { Intent, Alert } from '@blueprintjs/core';
-import { useQuery, queryCache } from 'react-query';
-import {
- FormattedMessage as T,
- FormattedHTMLMessage,
- useIntl,
-} from 'react-intl';
+import { useQuery } from 'react-query';
+import { FormattedMessage as T, useIntl } from 'react-intl';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import { compose } from 'utils';
-import ItemsViewsTabs from 'containers/Items/ItemsViewsTabs';
-import ItemsDataTable from './ItemsDataTable';
+import ItemsViewPage from './ItemsViewPage';
import ItemsActionsBar from 'containers/Items/ItemsActionsBar';
+import ItemsAlerts from './ItemsAlerts';
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
-import AppToaster from 'components/AppToaster';
import withItems from 'containers/Items/withItems';
import withResourceActions from 'containers/Resources/withResourcesActions';
@@ -41,21 +34,10 @@ function ItemsList({
itemsTableQuery,
// #withItemsActions
- requestDeleteItem,
requestFetchItems,
- requestInactiveItem,
- requestActivateItem,
addItemsTableQueries,
- requestDeleteBulkItems,
}) {
- const [deleteItem, setDeleteItem] = useState(false);
- const [inactiveItem, setInactiveItem] = useState(false);
- const [activateItem, setActivateItem] = useState(false);
- const [selectedRows, setSelectedRows] = useState([]);
- const [bulkDelete, setBulkDelete] = useState(false);
-
const { formatMessage } = useIntl();
- const history = useHistory();
useEffect(() => {
changePageTitle(formatMessage({ id: 'items_list' }));
@@ -78,76 +60,6 @@ function ItemsList({
requestFetchItems({ ..._query }),
);
- // Handle click delete item.
- const handleDeleteItem = useCallback(
- (item) => {
- setDeleteItem(item);
- },
- [setDeleteItem],
- );
-
- const handleEditItem = useCallback(
- (item) => {
- history.push(`/items/${item.id}/edit`);
- },
- [history],
- );
-
- // Handle cancel delete the item.
- const handleCancelDeleteItem = useCallback(() => {
- setDeleteItem(false);
- }, [setDeleteItem]);
-
- const handleDeleteErrors = (errors) => {
- if (
- errors.find((error) => error.type === 'ITEM_HAS_ASSOCIATED_TRANSACTINS')
- ) {
- AppToaster.show({
- message: formatMessage({
- id: 'the_item_has_associated_transactions',
- }),
- intent: Intent.DANGER,
- });
- }
-
- if (
- errors.find(
- (error) => error.type === 'ITEM_HAS_ASSOCIATED_INVENTORY_ADJUSTMENT',
- )
- ) {
- AppToaster.show({
- message: formatMessage({
- id:
- 'you_could_not_delete_item_that_has_associated_inventory_adjustments_transacions',
- }),
- intent: Intent.DANGER,
- });
- }
- };
-
- // handle confirm delete item.
- const handleConfirmDeleteItem = useCallback(() => {
- requestDeleteItem(deleteItem.id)
- .then(() => {
- AppToaster.show({
- message: formatMessage({
- id: 'the_item_has_been_deleted_successfully',
- }),
- intent: Intent.SUCCESS,
- });
- queryCache.invalidateQueries('items-table');
- setDeleteItem(false);
- })
- .catch(({ errors }) => {
- setDeleteItem(false);
- handleDeleteErrors(errors);
- });
- }, [requestDeleteItem, deleteItem, formatMessage]);
-
- const handleFetchData = useCallback(({ pageIndex, pageSize, sortBy }) => {}, [
- addItemsTableQueries,
- ]);
-
// Handle filter change to re-fetch the items.
const handleFilterChanged = useCallback(
(filterConditions) => {
@@ -158,193 +70,17 @@ function ItemsList({
[addItemsTableQueries],
);
- // Handle selected rows change.
- const handleSelectedRowsChange = useCallback(
- (accounts) => {
- setSelectedRows(accounts);
- },
- [setSelectedRows],
- );
-
- // Calculates the data table selected rows count.
- const selectedRowsCount = useMemo(() => Object.values(selectedRows).length, [
- selectedRows,
- ]);
-
- // Handle items bulk delete button click.,
-
- const handleBulkDelete = useCallback(
- (itemsIds) => {
- setBulkDelete(itemsIds);
- },
- [setBulkDelete],
- );
-
- // Handle confirm items bulk delete.
- const handleConfirmBulkDelete = useCallback(() => {
- requestDeleteBulkItems(bulkDelete)
- .then(() => {
- setBulkDelete(false);
- AppToaster.show({
- message: formatMessage({
- id: 'the_items_has_been_deleted_successfully',
- }),
- intent: Intent.SUCCESS,
- });
- })
- .catch((errors) => {
- setBulkDelete(false);
- });
- }, [requestDeleteBulkItems, bulkDelete, formatMessage]);
-
- // Handle cancel accounts bulk delete.
- const handleCancelBulkDelete = useCallback(() => {
- setBulkDelete(false);
- }, []);
-
- // Handle cancel/confirm item inactive.
- const handleInactiveItem = useCallback((item) => {
- setInactiveItem(item);
- }, []);
-
- // Handle cancel inactive item alert.
- const handleCancelInactiveItem = useCallback(() => {
- setInactiveItem(false);
- }, []);
-
- // Handle confirm item Inactive.
- const handleConfirmItemInactive = useCallback(() => {
- requestInactiveItem(inactiveItem.id)
- .then(() => {
- setInactiveItem(false);
- AppToaster.show({
- message: formatMessage({
- id: 'the_item_has_been_inactivated_successfully',
- }),
- intent: Intent.SUCCESS,
- });
- queryCache.invalidateQueries('items-table');
- })
- .catch((error) => {
- setInactiveItem(false);
- });
- }, [inactiveItem, requestInactiveItem, formatMessage]);
-
- // Handle activate item click.
- const handleActivateItem = useCallback((item) => {
- setActivateItem(item);
- });
-
- // Handle activate item alert cancel.
- const handleCancelActivateItem = useCallback(() => {
- setActivateItem(false);
- });
-
- // Handle activate item confirm.
- const handleConfirmItemActivate = useCallback(() => {
- requestActivateItem(activateItem.id)
- .then(() => {
- setActivateItem(false);
- AppToaster.show({
- message: formatMessage({
- id: 'the_item_has_been_activated_successfully',
- }),
- intent: Intent.SUCCESS,
- });
- queryCache.invalidateQueries('items-table');
- })
- .catch((error) => {
- setActivateItem(false);
- });
- }, [activateItem, requestActivateItem, formatMessage]);
-
return (
-
+
-
-
-
-
-
- }
- confirmButtonText={}
- icon="trash"
- intent={Intent.DANGER}
- isOpen={deleteItem}
- onCancel={handleCancelDeleteItem}
- onConfirm={handleConfirmDeleteItem}
- >
-
-
-
-
-
- }
- confirmButtonText={`${formatMessage({
- id: 'delete',
- })} (${selectedRowsCount})`}
- icon="trash"
- intent={Intent.DANGER}
- isOpen={bulkDelete}
- onCancel={handleCancelBulkDelete}
- onConfirm={handleConfirmBulkDelete}
- >
-
-
-
-
- }
- confirmButtonText={}
- intent={Intent.WARNING}
- isOpen={inactiveItem}
- onCancel={handleCancelInactiveItem}
- onConfirm={handleConfirmItemInactive}
- >
-
-
-
-
- }
- confirmButtonText={}
- intent={Intent.WARNING}
- isOpen={activateItem}
- onCancel={handleCancelActivateItem}
- onConfirm={handleConfirmItemActivate}
- >
-
-
-
-
-
-
+
+
);
}
diff --git a/client/src/containers/Items/ItemsViewPage.js b/client/src/containers/Items/ItemsViewPage.js
new file mode 100644
index 000000000..4d81ba339
--- /dev/null
+++ b/client/src/containers/Items/ItemsViewPage.js
@@ -0,0 +1,67 @@
+import React, { memo } from 'react';
+import { Switch, Route, useHistory } from 'react-router-dom';
+
+import ItemsViewsTabs from 'containers/Items/ItemsViewsTabs';
+import ItemsDataTable from 'containers/Items/ItemsDataTable';
+import withItemsActions from 'containers/Items/withItemsActions';
+import withAlertsActions from 'containers/Alert/withAlertActions';
+import { compose } from 'utils';
+
+function ItemsViewPage({
+ // #withAlertsActions.
+ openAlert,
+
+ // #withItemsActions.
+ setSelectedRowsItems,
+}) {
+ const history = useHistory();
+
+ // Handle delete action Item.
+ const handleDeleteItem = ({ id }) => {
+ openAlert('item-delete', { itemId: id });
+ };
+
+ // Handle cancel/confirm item inactive.
+ const handleInactiveItem = ({ id }) => {
+ openAlert('item-inactivate', { itemId: id });
+ };
+
+ // Handle cancel/confirm item activate.
+ const handleActivateItem = ({ id }) => {
+ openAlert('item-activate', { itemId: id });
+ };
+
+ // Handle select item rows.
+ const handleSelectedRowsChange = (selectedRows) => {
+ const selectedRowsIds = selectedRows.map((r) => r.id);
+ setSelectedRowsItems(selectedRowsIds);
+ };
+
+ // Handle Edit item.
+ const handleEditItem = ({ id }) => {
+ history.push(`/items/${id}/edit`);
+ };
+
+ return (
+
+
+
+
+
+
+
+ );
+}
+
+const ItemsViewPageMemo = memo(ItemsViewPage);
+
+export default compose(withAlertsActions, withItemsActions)(ItemsViewPageMemo);
diff --git a/client/src/containers/Items/utils.js b/client/src/containers/Items/utils.js
index 36d880039..c94bfa919 100644
--- a/client/src/containers/Items/utils.js
+++ b/client/src/containers/Items/utils.js
@@ -1,10 +1,40 @@
-import { formatMessage } from "services/intl";
+import { formatMessage } from 'services/intl';
+import { Intent } from '@blueprintjs/core';
+import { AppToaster } from 'components';
export const transitionItemTypeKeyToLabel = (itemTypeKey) => {
const table = {
- 'service': formatMessage({ id: 'service' }),
- 'inventory': formatMessage({ id: 'inventory' }),
+ service: formatMessage({ id: 'service' }),
+ inventory: formatMessage({ id: 'inventory' }),
'non-inventory': formatMessage({ id: 'non_inventory' }),
};
return typeof table[itemTypeKey] === 'string' ? table[itemTypeKey] : '';
-};
\ No newline at end of file
+};
+
+// handle delete errors.
+export const handleDeleteErrors = (errors) => {
+ if (
+ errors.find((error) => error.type === 'ITEM_HAS_ASSOCIATED_TRANSACTINS')
+ ) {
+ AppToaster.show({
+ message: formatMessage({
+ id: 'the_item_has_associated_transactions',
+ }),
+ intent: Intent.DANGER,
+ });
+ }
+
+ if (
+ errors.find(
+ (error) => error.type === 'ITEM_HAS_ASSOCIATED_INVENTORY_ADJUSTMENT',
+ )
+ ) {
+ AppToaster.show({
+ message: formatMessage({
+ id:
+ 'you_could_not_delete_item_that_has_associated_inventory_adjustments_transacions',
+ }),
+ intent: Intent.DANGER,
+ });
+ }
+};
diff --git a/client/src/containers/Items/withItems.js b/client/src/containers/Items/withItems.js
index 297696917..116219311 100644
--- a/client/src/containers/Items/withItems.js
+++ b/client/src/containers/Items/withItems.js
@@ -21,6 +21,7 @@ export default (mapState) => {
itemsCurrentPage: getItemsCurrentPage(state, props),
itemsBulkSelected: state.items.bulkActions,
itemsTableLoading: state.items.loading,
+ itemsSelectedRows: state.items.selectedRows,
itemsTableQuery: getItemsTableQuery(state, props),
itemsPagination: getItemsPaginationMeta(state, props),
itemsCurrentViewId: getItemsCurrentViewId(state, props),
diff --git a/client/src/containers/Items/withItemsActions.js b/client/src/containers/Items/withItemsActions.js
index 0f34cb269..29c4c3797 100644
--- a/client/src/containers/Items/withItemsActions.js
+++ b/client/src/containers/Items/withItemsActions.js
@@ -17,7 +17,7 @@ export const mapDispatchToProps = (dispatch) => ({
requestDeleteItem: (id) => dispatch(deleteItem({ id })),
requestDeleteBulkItems: (ids) => dispatch(deleteBulkItems({ ids })),
requestSubmitItem: (form) => dispatch(submitItem({ form })),
- requestEditItem: (id, form) => dispatch(editItem( id, form )),
+ requestEditItem: (id, form) => dispatch(editItem(id, form)),
requestInactiveItem: (id) => dispatch(inactiveItem({ id })),
requestActivateItem: (id) => dispatch(activateItem({ id })),
addBulkActionItem: (id) =>
@@ -47,6 +47,11 @@ export const mapDispatchToProps = (dispatch) => ({
type: t.ITEMS_SET_CURRENT_VIEW,
currentViewId: parseInt(id, 10),
}),
+ setSelectedRowsItems: (selectedRows) =>
+ dispatch({
+ type: t.ITEM_SELECTED_ROWS_SET,
+ payload: { selectedRows },
+ }),
});
export default connect(null, mapDispatchToProps);
diff --git a/client/src/store/items/items.reducer.js b/client/src/store/items/items.reducer.js
index 51fb2579c..625759dd0 100644
--- a/client/src/store/items/items.reducer.js
+++ b/client/src/store/items/items.reducer.js
@@ -18,6 +18,7 @@ const initialState = {
page_size: 12,
page: 1,
},
+ selectedRows: [],
};
export default createReducer(initialState, {
@@ -58,6 +59,11 @@ export default createReducer(initialState, {
[t.ITEM_BULK_ACTION_ADD]: (state, action) => {
state.bulkActions[action.itemId] = true;
},
+
+ [t.ITEM_SELECTED_ROWS_SET]: (state, action) => {
+ const { selectedRows } = action.payload;
+ state.selectedRows = selectedRows;
+ },
[t.ITEM_BULK_ACTION_REMOVE]: (state, action) => {
delete state.bulkActions[action.itemId];
diff --git a/client/src/store/items/items.types.js b/client/src/store/items/items.types.js
index 7bcc2b765..41a74eee5 100644
--- a/client/src/store/items/items.types.js
+++ b/client/src/store/items/items.types.js
@@ -13,4 +13,5 @@ export default {
ITEMS_TABLE_LOADING: 'ITEMS_TABLE_LOADING',
ITEMS_SET_CURRENT_VIEW: 'ITEMS_SET_CURRENT_VIEW',
ITEMS_BULK_DELETE: 'ITEMS_BULK_DELETE',
+ ITEM_SELECTED_ROWS_SET: 'ITEM_SELECTED_ROWS_SET',
};