mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
WIP feature/editItem
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useMemo, useCallback } from 'react';
|
import React, { useState, useMemo, useCallback,useEffect } from 'react';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import {
|
import {
|
||||||
@@ -15,35 +15,61 @@ import { Row, Col } from 'react-grid-system';
|
|||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { Select } from '@blueprintjs/select';
|
import { Select } from '@blueprintjs/select';
|
||||||
import { queryCache } from 'react-query';
|
import { queryCache } from 'react-query';
|
||||||
|
import {useParams} from 'react-router-dom';
|
||||||
import AppToaster from 'components/AppToaster';
|
import AppToaster from 'components/AppToaster';
|
||||||
import AccountsConnect from 'connectors/Accounts.connector';
|
|
||||||
import ItemsConnect from 'connectors/Items.connect';
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import ErrorMessage from 'components/ErrorMessage';
|
import ErrorMessage from 'components/ErrorMessage';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import ItemCategoryConnect from 'connectors/ItemsCategory.connect';
|
import withItemsActions from 'containers/Items/withItemsActions';
|
||||||
|
import withItemCategories from 'containers/Items/withItemCategories'
|
||||||
|
import withAccounts from 'containers/Accounts/withAccounts';
|
||||||
|
import withMediaActions from 'containers/Media/withMediaActions';
|
||||||
|
|
||||||
import MoneyInputGroup from 'components/MoneyInputGroup';
|
import MoneyInputGroup from 'components/MoneyInputGroup';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import Dragzone from 'components/Dragzone';
|
import Dragzone from 'components/Dragzone';
|
||||||
import MediaConnect from 'connectors/Media.connect';
|
|
||||||
import useMedia from 'hooks/useMedia';
|
import useMedia from 'hooks/useMedia';
|
||||||
|
import withItems from './withItems';
|
||||||
|
import withItemDetail from 'containers/Items/withItemDetail'
|
||||||
|
import { pick } from 'lodash';
|
||||||
|
import withDashboardActions from 'containers/Dashboard/withDashboard';
|
||||||
|
|
||||||
|
|
||||||
const ItemForm = ({
|
const ItemForm = ({
|
||||||
|
|
||||||
|
// #withItemActions
|
||||||
requestSubmitItem,
|
requestSubmitItem,
|
||||||
|
requestEditItem,
|
||||||
|
|
||||||
|
|
||||||
accounts,
|
accounts,
|
||||||
categories,
|
accountsTypes,
|
||||||
|
itemDetail,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #withDashboard
|
||||||
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withItemCategories
|
||||||
|
categoriesList,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #withMediaActions
|
||||||
requestSubmitMedia,
|
requestSubmitMedia,
|
||||||
requestDeleteMedia,
|
requestDeleteMedia,
|
||||||
|
|
||||||
|
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const [selectedAccounts, setSelectedAccounts] = useState({});
|
const [selectedAccounts, setSelectedAccounts] = useState({});
|
||||||
|
const [selectedAccountType, setSelectedAccountType] = useState(null);
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const {id} =useParams();
|
||||||
const {
|
const {
|
||||||
files,
|
files,
|
||||||
setFiles,
|
setFiles,
|
||||||
@@ -81,7 +107,7 @@ const ItemForm = ({
|
|||||||
stock: Yup.string() || Yup.boolean(),
|
stock: Yup.string() || Yup.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialValues = useMemo(
|
const defaultInitialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
active: true,
|
active: true,
|
||||||
name: '',
|
name: '',
|
||||||
@@ -97,6 +123,21 @@ const ItemForm = ({
|
|||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
const initialValues = useMemo(() => ({
|
||||||
|
...(itemDetail) ? {
|
||||||
|
...pick(itemDetail, Object.keys(defaultInitialValues)),
|
||||||
|
|
||||||
|
} : {
|
||||||
|
...defaultInitialValues,
|
||||||
|
}
|
||||||
|
}), [itemDetail, defaultInitialValues]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
itemDetail && itemDetail.id ?
|
||||||
|
changePageTitle(formatMessage({id:'edit_item_details'})) :
|
||||||
|
changePageTitle(formatMessage({id:'new_item'}));
|
||||||
|
}, [changePageTitle,itemDetail]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getFieldProps,
|
getFieldProps,
|
||||||
@@ -112,24 +153,47 @@ const ItemForm = ({
|
|||||||
initialValues: {
|
initialValues: {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
},
|
},
|
||||||
onSubmit: (values, { setSubmitting }) => {
|
onSubmit: (values, { setSubmitting,resetForm,setErrors }) => {
|
||||||
|
|
||||||
const saveItem = (mediaIds) => {
|
const saveItem = (mediaIds) => {
|
||||||
const formValues = { ...values, media_ids: mediaIds };
|
const formValues = { ...values, media_ids: mediaIds };
|
||||||
|
if(itemDetail && itemDetail.id ){
|
||||||
|
|
||||||
return requestSubmitItem(formValues).then((response) => {
|
requestEditItem(itemDetail.id,formValues)
|
||||||
AppToaster.show({
|
.then((response)=>{
|
||||||
message: formatMessage({
|
AppToaster.show({
|
||||||
id: 'service_has_been_successful_created',
|
message:formatMessage({
|
||||||
}, {
|
id:'the_item_has_been_successfully_edited',
|
||||||
name: values.name,
|
},{
|
||||||
service: formatMessage({ id: 'item' }),
|
number:itemDetail.id
|
||||||
}),
|
}),
|
||||||
intent: Intent.SUCCESS,
|
intent:Intent.SUCCESS
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
resetForm();
|
||||||
|
}).catch((errors)=>{
|
||||||
|
setSubmitting(false)
|
||||||
});
|
});
|
||||||
queryCache.removeQueries(['items-table']);
|
|
||||||
history.push('/dashboard/items');
|
}else{
|
||||||
});
|
|
||||||
};
|
requestSubmitItem(formValues).then((response) => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'service_has_been_successful_created',
|
||||||
|
}, {
|
||||||
|
name: values.name,
|
||||||
|
service: formatMessage({ id: 'item' }),
|
||||||
|
}),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
queryCache.removeQueries(['items-table']);
|
||||||
|
history.push('/items');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Promise.all([saveMedia(), deleteMedia()]).then(
|
Promise.all([saveMedia(), deleteMedia()]).then(
|
||||||
([savedMediaResponses]) => {
|
([savedMediaResponses]) => {
|
||||||
@@ -152,6 +216,7 @@ const ItemForm = ({
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Filter Account Items
|
// Filter Account Items
|
||||||
const filterAccounts = (query, account, _index, exactMatch) => {
|
const filterAccounts = (query, account, _index, exactMatch) => {
|
||||||
const normalizedTitle = account.name.toLowerCase();
|
const normalizedTitle = account.name.toLowerCase();
|
||||||
@@ -163,6 +228,19 @@ const ItemForm = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Set default
|
||||||
|
// useEffect(()=>{
|
||||||
|
|
||||||
|
// if(itemDetail && itemDetail.id){
|
||||||
|
// const defaultType = itemDetail.find(
|
||||||
|
// (t) => t.id === itemDetail.id
|
||||||
|
// );
|
||||||
|
|
||||||
|
// defaultType && setSelectedAccountType(defaultType);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// },[])
|
||||||
const onItemAccountSelect = useCallback(
|
const onItemAccountSelect = useCallback(
|
||||||
(filedName) => {
|
(filedName) => {
|
||||||
return (account) => {
|
return (account) => {
|
||||||
@@ -183,6 +261,7 @@ const ItemForm = ({
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const getSelectedAccountLabel = useCallback(
|
const getSelectedAccountLabel = useCallback(
|
||||||
(fieldName, defaultLabel) => {
|
(fieldName, defaultLabel) => {
|
||||||
return typeof selectedAccounts[fieldName] !== 'undefined'
|
return typeof selectedAccounts[fieldName] !== 'undefined'
|
||||||
@@ -199,10 +278,18 @@ const ItemForm = ({
|
|||||||
setFieldValue(fieldKey, value);
|
setFieldValue(fieldKey, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialAttachmentFiles = useMemo(() => {
|
|
||||||
return [];
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
const initialAttachmentFiles =useMemo(()=>{
|
||||||
|
return itemDetail && itemDetail.media
|
||||||
|
? itemDetail.media.map((attach)=>({
|
||||||
|
|
||||||
|
preview:attach.attachment_file,
|
||||||
|
upload:true,
|
||||||
|
metadata:{...attach}
|
||||||
|
|
||||||
|
})):[];
|
||||||
|
|
||||||
|
},[itemDetail])
|
||||||
const handleDropFiles = useCallback((_files) => {
|
const handleDropFiles = useCallback((_files) => {
|
||||||
setFiles(_files.filter((file) => file.uploaded === false));
|
setFiles(_files.filter((file) => file.uploaded === false));
|
||||||
}, []);
|
}, []);
|
||||||
@@ -297,7 +384,7 @@ const ItemForm = ({
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
items={categories}
|
items={categoriesList}
|
||||||
itemRenderer={categoryItem}
|
itemRenderer={categoryItem}
|
||||||
itemPredicate={filterAccounts}
|
itemPredicate={filterAccounts}
|
||||||
popoverProps={{ minimal: true }}
|
popoverProps={{ minimal: true }}
|
||||||
@@ -532,7 +619,8 @@ const ItemForm = ({
|
|||||||
|
|
||||||
<div class='form__floating-footer'>
|
<div class='form__floating-footer'>
|
||||||
<Button intent={Intent.PRIMARY} disabled={isSubmitting} type='submit'>
|
<Button intent={Intent.PRIMARY} disabled={isSubmitting} type='submit'>
|
||||||
<T id={'save'}/>
|
|
||||||
|
{ itemDetail && itemDetail.id ? <T id={'edit'}/> : <T id={'save'}/> }
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button className={'ml1'} disabled={isSubmitting}>
|
<Button className={'ml1'} disabled={isSubmitting}>
|
||||||
@@ -549,8 +637,15 @@ const ItemForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
AccountsConnect,
|
withAccounts(({accounts,accountsTypes})=>({
|
||||||
ItemsConnect,
|
accounts,
|
||||||
ItemCategoryConnect,
|
accountsTypes
|
||||||
MediaConnect
|
})),
|
||||||
|
withItemsActions,
|
||||||
|
withItemDetail,
|
||||||
|
withItemCategories(({ categoriesList }) => ({
|
||||||
|
categoriesList,
|
||||||
|
})),
|
||||||
|
withDashboardActions,
|
||||||
|
withMediaActions,
|
||||||
)(ItemForm);
|
)(ItemForm);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect,useCallback } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams,useHistory } from 'react-router-dom';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
import ItemForm from 'containers/Items/ItemForm';
|
import ItemForm from 'containers/Items/ItemForm';
|
||||||
@@ -11,6 +11,7 @@ import withItemCategoriesActions from 'containers/Items/withItemCategoriesAction
|
|||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
|
import withItemsActions from './withItemsActions';
|
||||||
|
|
||||||
|
|
||||||
const ItemFormContainer = ({
|
const ItemFormContainer = ({
|
||||||
@@ -20,16 +21,15 @@ const ItemFormContainer = ({
|
|||||||
// #withAccountsActions
|
// #withAccountsActions
|
||||||
requestFetchAccounts,
|
requestFetchAccounts,
|
||||||
|
|
||||||
|
// #withItemsActions
|
||||||
|
requestFetchItems,
|
||||||
|
|
||||||
// #withItemCategoriesActions
|
// #withItemCategoriesActions
|
||||||
requestFetchItemCategories,
|
requestFetchItemCategories,
|
||||||
}) => {
|
}) => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const {formatMessage} =useIntl()
|
const {formatMessage} =useIntl()
|
||||||
useEffect(() => {
|
const history = useHistory();
|
||||||
id ?
|
|
||||||
changePageTitle(formatMessage({id:'edit_item_details'})) :
|
|
||||||
changePageTitle(formatMessage({id:'new_item'}));
|
|
||||||
}, [id, changePageTitle]);
|
|
||||||
|
|
||||||
const fetchAccounts = useQuery('accounts-list',
|
const fetchAccounts = useQuery('accounts-list',
|
||||||
(key) => requestFetchAccounts());
|
(key) => requestFetchAccounts());
|
||||||
@@ -37,11 +37,30 @@ const ItemFormContainer = ({
|
|||||||
const fetchCategories = useQuery('item-categories-list',
|
const fetchCategories = useQuery('item-categories-list',
|
||||||
(key) => requestFetchItemCategories());
|
(key) => requestFetchItemCategories());
|
||||||
|
|
||||||
|
const fetchItemDetail = useQuery(
|
||||||
|
id && ['item-detail-list', id],
|
||||||
|
(key) => requestFetchItems());
|
||||||
|
|
||||||
|
const handleFormSubmit =useCallback((payload)=>{
|
||||||
|
|
||||||
|
payload.redirect && history.push('/items/new');
|
||||||
|
|
||||||
|
},[history])
|
||||||
|
|
||||||
|
const handleCancel =useCallback(()=>{
|
||||||
|
|
||||||
|
history.push('/items/new');
|
||||||
|
},[])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider
|
<DashboardInsider
|
||||||
loading={fetchAccounts.isFetching || fetchCategories.isFetching}
|
loading={fetchItemDetail.isFetching || fetchAccounts.isFetching || fetchCategories.isFetching }
|
||||||
name={'item-form'}>
|
name={'item-form'}>
|
||||||
<ItemForm />
|
<ItemForm
|
||||||
|
itemId={id}
|
||||||
|
onFormSubmit={handleFormSubmit}
|
||||||
|
onCancelForm={handleCancel}
|
||||||
|
/>
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -50,4 +69,5 @@ export default compose(
|
|||||||
withDashboard,
|
withDashboard,
|
||||||
withAccountsActions,
|
withAccountsActions,
|
||||||
withItemCategoriesActions,
|
withItemCategoriesActions,
|
||||||
|
withItemsActions
|
||||||
)(ItemFormContainer);
|
)(ItemFormContainer);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
Position,
|
Position,
|
||||||
} from '@blueprintjs/core'
|
} from '@blueprintjs/core'
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
@@ -17,7 +16,6 @@ import Money from 'components/Money';
|
|||||||
import withItems from 'containers/Items/withItems';
|
import withItems from 'containers/Items/withItems';
|
||||||
import LoadingIndicator from 'components/LoadingIndicator';
|
import LoadingIndicator from 'components/LoadingIndicator';
|
||||||
|
|
||||||
|
|
||||||
const ItemsDataTable = ({
|
const ItemsDataTable = ({
|
||||||
loading,
|
loading,
|
||||||
|
|
||||||
@@ -32,6 +30,7 @@ const ItemsDataTable = ({
|
|||||||
onSelectedRowsChange,
|
onSelectedRowsChange,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
|
|
||||||
const {formatMessage} = useIntl();
|
const {formatMessage} = useIntl();
|
||||||
const [initialMount, setInitialMount] = useState(false);
|
const [initialMount, setInitialMount] = useState(false);
|
||||||
|
|
||||||
@@ -41,7 +40,14 @@ const ItemsDataTable = ({
|
|||||||
}
|
}
|
||||||
}, [itemsTableLoading, setInitialMount]);
|
}, [itemsTableLoading, setInitialMount]);
|
||||||
|
|
||||||
const handleEditItem = (item) => () => { onEditItem(item); };
|
const handleEditItem = useCallback(
|
||||||
|
(item) => () => {
|
||||||
|
onEditItem && onEditItem(item);
|
||||||
|
},
|
||||||
|
[onEditItem]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
const handleDeleteItem = (item) => () => { onDeleteItem(item); };
|
const handleDeleteItem = (item) => () => { onDeleteItem(item); };
|
||||||
|
|
||||||
const actionMenuList = useCallback((item) =>
|
const actionMenuList = useCallback((item) =>
|
||||||
@@ -53,6 +59,7 @@ const ItemsDataTable = ({
|
|||||||
</Menu>), [handleEditItem, handleDeleteItem]);
|
</Menu>), [handleEditItem, handleDeleteItem]);
|
||||||
|
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
|
|
||||||
{
|
{
|
||||||
Header: formatMessage({ id:'item_name' }),
|
Header: formatMessage({ id:'item_name' }),
|
||||||
accessor: 'name',
|
accessor: 'name',
|
||||||
@@ -136,6 +143,7 @@ const ItemsDataTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
|
|
||||||
withItems(({ itemsCurrentPage, itemsTableLoading }) => ({
|
withItems(({ itemsCurrentPage, itemsTableLoading }) => ({
|
||||||
itemsCurrentPage,
|
itemsCurrentPage,
|
||||||
itemsTableLoading,
|
itemsTableLoading,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useEffect, useCallback, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
Route,
|
Route,
|
||||||
Switch,
|
Switch,
|
||||||
|
useHistory
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Intent,
|
Intent,
|
||||||
@@ -49,6 +50,8 @@ function ItemsList({
|
|||||||
|
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle(formatMessage({id:'items_list'}));
|
changePageTitle(formatMessage({id:'items_list'}));
|
||||||
}, [changePageTitle]);
|
}, [changePageTitle]);
|
||||||
@@ -68,7 +71,14 @@ function ItemsList({
|
|||||||
setDeleteItem(item);
|
setDeleteItem(item);
|
||||||
}, [setDeleteItem]);
|
}, [setDeleteItem]);
|
||||||
|
|
||||||
const handleEditItem = () => {};
|
const handleEditItem = useCallback(
|
||||||
|
(item) => {
|
||||||
|
history.push(`/items/${item.id}/edit`);
|
||||||
|
},
|
||||||
|
[history]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle cancel delete the item.
|
// Handle cancel delete the item.
|
||||||
const handleCancelDeleteItem = useCallback(() => {
|
const handleCancelDeleteItem = useCallback(() => {
|
||||||
@@ -121,6 +131,9 @@ function ItemsList({
|
|||||||
setSelectedRows(accounts);
|
setSelectedRows(accounts);
|
||||||
}, [setSelectedRows]);
|
}, [setSelectedRows]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider
|
<DashboardInsider
|
||||||
isLoading={fetchHook.isFetching}
|
isLoading={fetchHook.isFetching}
|
||||||
|
|||||||
9
client/src/containers/Items/withItemDetail.js
Normal file
9
client/src/containers/Items/withItemDetail.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import t from 'store/types';
|
||||||
|
import { getItemById } from 'store/items/items.reducer';
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
itemDetail: getItemById(state, props.itemId),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps);
|
||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
fetchItems,
|
fetchItems,
|
||||||
deleteItem,
|
deleteItem,
|
||||||
submitItem,
|
submitItem,
|
||||||
|
editItem,
|
||||||
} from 'store/items/items.actions';
|
} from 'store/items/items.actions';
|
||||||
import t from 'store/types';
|
import t from 'store/types';
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ export const mapDispatchToProps = (dispatch) => ({
|
|||||||
requestFetchItems: (query) => dispatch(fetchItems({ query })),
|
requestFetchItems: (query) => dispatch(fetchItems({ query })),
|
||||||
requestDeleteItem: (id) => dispatch(deleteItem({ id })),
|
requestDeleteItem: (id) => dispatch(deleteItem({ id })),
|
||||||
requestSubmitItem: (form) => dispatch(submitItem({ form })),
|
requestSubmitItem: (form) => dispatch(submitItem({ form })),
|
||||||
|
requestEditItem:(id,form) => dispatch(editItem({id,form})),
|
||||||
addBulkActionItem: (id) => dispatch({
|
addBulkActionItem: (id) => dispatch({
|
||||||
type: t.ITEM_BULK_ACTION_ADD, itemId: id
|
type: t.ITEM_BULK_ACTION_ADD, itemId: id
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ export default [
|
|||||||
}),
|
}),
|
||||||
breadcrumb: 'Categories',
|
breadcrumb: 'Categories',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: `/items/:id/edit`,
|
||||||
|
component: LazyLoader({
|
||||||
|
loader: () => import('containers/Items/ItemFormPage'),
|
||||||
|
}),
|
||||||
|
breadcrumb: 'Edit Item',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: `/items/new`,
|
path: `/items/new`,
|
||||||
component: LazyLoader({
|
component: LazyLoader({
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export default {
|
|||||||
check('sell_price').exists().isNumeric(),
|
check('sell_price').exists().isNumeric(),
|
||||||
check('cost_account_id').exists().isInt(),
|
check('cost_account_id').exists().isInt(),
|
||||||
check('sell_account_id').exists().isInt(),
|
check('sell_account_id').exists().isInt(),
|
||||||
check('category_id').optional().isInt(),
|
check('category_id').optional({ nullable: true }).isInt().toInt(),
|
||||||
check('note').optional(),
|
check('note').optional(),
|
||||||
check('attachment').optional(),
|
check('attachment').optional(),
|
||||||
check('')
|
check('')
|
||||||
|
|||||||
Reference in New Issue
Block a user