WIP / FIx & no-unused-vars

This commit is contained in:
elforjani3
2020-05-25 19:31:42 +02:00
parent 18a032ffd1
commit d107e84285
95 changed files with 324 additions and 352 deletions

View File

@@ -12,7 +12,6 @@ import AppToaster from 'components/AppToaster';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import ItemCategoriesDataTable from 'containers/Items/ItemCategoriesTable';
import ItemsCategoryActionsBar from 'containers/Items/ItemsCategoryActionsBar';
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
import withDialog from 'connectors/Dialog.connector';
import withDashboardActions from 'containers/Dashboard/withDashboard';
@@ -46,7 +45,7 @@ const ItemCategoryList = ({
id
? changePageTitle(formatMessage({ id: 'edit_category_details' }))
: changePageTitle(formatMessage({ id: 'category_list' }));
}, []);
}, [id,changePageTitle,formatMessage]);
const fetchCategories = useQuery(
['items-categories-table', filter],
@@ -126,7 +125,7 @@ const ItemCategoryList = ({
.catch((errors) => {
setBulkDelete(false);
});
}, [requestDeleteBulkItemCategories, bulkDelete]);
}, [requestDeleteBulkItemCategories, bulkDelete,formatMessage]);
//Handel cancel itemCategories bulk delete.

View File

@@ -28,10 +28,9 @@ const ItemsCategoryList = ({
}) => {
const {formatMessage} = useIntl();
const handelEditCategory = (category) => { onEditCategory(category); };
const handleDeleteCategory = (category) => { onDeleteCategory(category); };
const actionMenuList = (category) => (
const handelEditCategory=useCallback((category)=>{onEditCategory(category);},[onEditCategory])
const handleDeleteCategory =useCallback((category)=>{onDeleteCategory(category);},[onDeleteCategory])
const actionMenuList = useCallback((category) => (
<Menu>
<MenuItem
text={<T id={'edit_category'} />}
@@ -41,7 +40,8 @@ const ItemsCategoryList = ({
onClick={() => handleDeleteCategory(category)}
/>
</Menu>
);
), [handelEditCategory,handleDeleteCategory]);
const columns = useMemo(() => [
{
@@ -79,11 +79,11 @@ const ItemsCategoryList = ({
width: 50,
disableResizing: false
},
], [actionMenuList]);
], [actionMenuList,formatMessage]);
const handelFetchData = useCallback((...params) => {
onFetchData && onFetchData(...params);
}, []);
}, [onFetchData]);
const handleSelectedRowsChange = useCallback((selectedRows) => {
onSelectedRowsChange && onSelectedRowsChange(selectedRows.map(s => s.original));

View File

@@ -1,6 +1,6 @@
import React, { useState, useMemo, useCallback,useEffect } from 'react';
import * as Yup from 'yup';
import { useFormik, Formik } from 'formik';
import { useFormik } from 'formik';
import {
FormGroup,
MenuItem,
@@ -14,7 +14,7 @@ import {
import { Row, Col } from 'react-grid-system';
import { FormattedMessage as T, useIntl } from 'react-intl';
import { queryCache } from 'react-query';
import { useParams, useHistory } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import { pick } from 'lodash';
import classNames from 'classnames';
@@ -30,7 +30,6 @@ import withItemCategories from 'containers/Items/withItemCategories'
import withAccounts from 'containers/Accounts/withAccounts';
import withMediaActions from 'containers/Media/withMediaActions';
import useMedia from 'hooks/useMedia';
import withItems from './withItems';
import withItemDetail from 'containers/Items/withItemDetail'
import withDashboardActions from 'containers/Dashboard/withDashboard';
import withAccountDetail from 'containers/Accounts/withAccountDetail';
@@ -62,9 +61,7 @@ const ItemForm = ({
const history = useHistory();
const { formatMessage } = useIntl();
const {id} =useParams();
const {
files,
setFiles,
saveMedia,
deletedFiles,
@@ -80,7 +77,7 @@ const ItemForm = ({
{ value: 'service', label: formatMessage({id:'service'}) },
{ value: 'inventory', label: formatMessage({id:'inventory'}) },
{ value: 'non-inventory', label: formatMessage({id:'non_inventory'}) },
], []);
], [formatMessage]);
const validationSchema = Yup.object().shape({
active: Yup.boolean(),
@@ -133,7 +130,7 @@ const ItemForm = ({
itemDetail && itemDetail.id ?
changePageTitle(formatMessage({id:'edit_item_details'})) :
changePageTitle(formatMessage({id:'new_item'}));
}, [changePageTitle,itemDetail]);
}, [changePageTitle,itemDetail,formatMessage]);
const {
getFieldProps,
@@ -270,7 +267,7 @@ const ItemForm = ({
}
});
},
[setDeletedFiles, deletedFiles]
[setDeletedFiles, deletedFiles,]
);
const handleCancelClickBtn = () => {

View File

@@ -1,17 +1,16 @@
import React, { useEffect,useCallback } from 'react';
import React, {useCallback } from 'react';
import { useParams,useHistory } from 'react-router-dom';
import { useQuery } from 'react-query';
import ItemForm from 'containers/Items/ItemForm';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import ItemForm from 'containers/Items/ItemForm';
import withDashboard from 'containers/Dashboard/withDashboard';
import withAccountsActions from 'containers/Accounts/withAccountsActions';
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
import withItemsActions from './withItemsActions';
import { compose } from 'utils';
import { FormattedMessage as T, useIntl } from 'react-intl';
import withItemsActions from './withItemsActions';
const ItemFormContainer = ({
@@ -28,7 +27,6 @@ const ItemFormContainer = ({
requestFetchItemCategories,
}) => {
const { id } = useParams();
const {formatMessage} =useIntl()
const history = useHistory();
const fetchAccounts = useQuery('accounts-list',
@@ -50,7 +48,7 @@ const handleFormSubmit =useCallback((payload)=>{
const handleCancel =useCallback(()=>{
history.push('/items/new');
},[])
},[history])
return (
<DashboardInsider

View File

@@ -8,6 +8,7 @@ import {
Position,
PopoverInteractionKind,
} from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
import classNames from 'classnames';
import { connect } from 'react-redux';
import { If } from 'components';
@@ -21,7 +22,6 @@ import withDialog from 'connectors/Dialog.connector';
import withDashboard from 'containers/Dashboard/withDashboard';
import { compose } from 'utils';
import { FormattedMessage as T, useIntl } from 'react-intl';
const ItemsCategoryActionsBar = ({
// #withResourceDetail

View File

@@ -8,13 +8,13 @@ import {
Position,
} from '@blueprintjs/core'
import { FormattedMessage as T, useIntl } from 'react-intl';
import {compose} from 'utils';
import DataTable from 'components/DataTable';
import Icon from 'components/Icon';
import Money from 'components/Money';
import withItems from 'containers/Items/withItems';
import LoadingIndicator from 'components/LoadingIndicator';
import withItems from 'containers/Items/withItems';
import {compose} from 'utils';
const ItemsDataTable = ({
loading,
@@ -48,8 +48,8 @@ const ItemsDataTable = ({
);
const handleDeleteItem = (item) => () => { onDeleteItem(item); };
// const handleDeleteItem = (item) => () => { onDeleteItem(item); };
const handleDeleteItem =useCallback((item)=>()=>{onDeleteItem(item)},[onDeleteItem])
const actionMenuList = useCallback((item) =>
(<Menu>
<MenuItem text={<T id={'view_details'}/>} />
@@ -112,7 +112,7 @@ const ItemsDataTable = ({
className: 'actions',
width: 50,
},
], [actionMenuList]);
], [actionMenuList,formatMessage]);
const selectionColumn = useMemo(() => ({
minWidth: 42,
@@ -122,7 +122,7 @@ const ItemsDataTable = ({
const handleFetchData = useCallback((...args) => {
onFetchData && onFetchData(...args)
}, [onFetchData]);
}, []);
const handleSelectedRowsChange = useCallback((selectedRows) => {
onSelectedRowsChange && onSelectedRowsChange(selectedRows.map(s => s.original));
@@ -151,4 +151,8 @@ export default compose(
itemsCurrentPage,
itemsTableLoading,
})),
)(ItemsDataTable);
)(ItemsDataTable);

View File

@@ -98,7 +98,7 @@ function ItemsList({
});
setDeleteItem(false);
});
}, [requestDeleteItem, deleteItem]);
}, [requestDeleteItem, deleteItem,formatMessage]);
// Handle fetch data table.
const handleFetchData = useCallback(({ pageIndex, pageSize, sortBy }) => {
@@ -155,7 +155,7 @@ function ItemsList({
}).catch((errors) => {
setBulkDelete(false);
});
}, [requestDeleteBulkItems, bulkDelete]);
}, [requestDeleteBulkItems, bulkDelete,formatMessage]);
// Handle cancel accounts bulk delete.
const handleCancelBulkDelete = useCallback(() => {

View File

@@ -20,7 +20,7 @@ import withDashboard from 'containers/Dashboard/withDashboard';
import withViewDetail from 'containers/Views/withViewDetails';
import withItems from 'containers/Items/withItems';
import { FormattedMessage as T, useIntl } from 'react-intl';
import { FormattedMessage as T} from 'react-intl';
function ItemsViewsTabs({
// #withViewDetail

View File

@@ -1,5 +1,4 @@
import { connect } from 'react-redux';
import t from 'store/types';
import { getItemById } from 'store/items/items.reducer';
const mapStateToProps = (state, props) => ({