mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix items connector.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/data
|
||||
.env
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import { useFormik } from 'formik';
|
||||
|
||||
import {
|
||||
FormGroup,
|
||||
MenuItem,
|
||||
@@ -13,19 +12,21 @@ import {
|
||||
import { Row, Col } from 'react-grid-system';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import AccountsConnect from 'connectors/Accounts.connector';
|
||||
import ItemsConnect from 'connectors/Items.connect';
|
||||
import {compose} from 'utils';
|
||||
|
||||
export default function ItemForm({
|
||||
submitItem,
|
||||
const ItemForm = ({
|
||||
requestSubmitItem,
|
||||
accounts,
|
||||
category,
|
||||
}) {
|
||||
}) => {
|
||||
const [selectedAccounts, setSelectedAccounts] = useState({});
|
||||
|
||||
const ItemTypeDisplay = [
|
||||
{ label: 'Select Item Type' },
|
||||
{ value: 'service', label: 'service' },
|
||||
{ value: 'inventory', label: 'inventory' },
|
||||
{ value: 'non-inventory', label: 'non-inventory' }
|
||||
{ value: null, label: 'Select Item Type' },
|
||||
{ value: 'service', label: 'Service' },
|
||||
{ value: 'inventory', label: 'Inventory' },
|
||||
{ value: 'non-inventory', label: 'Non-Inventory' }
|
||||
];
|
||||
const validationSchema = Yup.object().shape({
|
||||
name: Yup.string().required(),
|
||||
@@ -46,7 +47,7 @@ export default function ItemForm({
|
||||
validationSchema: validationSchema,
|
||||
initialValues: {},
|
||||
onSubmit: values => {
|
||||
submitItem(values)
|
||||
requestSubmitItem(values)
|
||||
.then(response => {
|
||||
AppToaster.show({
|
||||
message: 'The_Items_has_been_Submit'
|
||||
@@ -295,4 +296,9 @@ export default function ItemForm({
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default compose(
|
||||
AccountsConnect,
|
||||
ItemsConnect,
|
||||
)(ItemForm);
|
||||
@@ -19,11 +19,11 @@ export default [
|
||||
children: [
|
||||
{
|
||||
text: 'Items List',
|
||||
href: '/dashboard/accounts',
|
||||
href: '/dashboard/items/list',
|
||||
},
|
||||
{
|
||||
text: 'New Item',
|
||||
href: '/dashboard/accounts',
|
||||
href: '/dashboard/items/new',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import {connect} from 'react-redux';
|
||||
import {
|
||||
fetchItems,
|
||||
fetchItem,
|
||||
deleteItem,
|
||||
submitItem,
|
||||
} from 'store/items/items.actions';
|
||||
@@ -29,7 +28,7 @@ export const mapStateToProps = (state, props) => {
|
||||
};
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
fetchItems: (query) => dispatch(fetchItems({ query })),
|
||||
requestFetchItems: (query) => dispatch(fetchItems({ query })),
|
||||
requestDeleteItem: (id) => dispatch(deleteItem({ id })),
|
||||
requestSubmitItem: (form) => dispatch(submitItem({ form })),
|
||||
addBulkActionItem: (id) => dispatch({
|
||||
|
||||
@@ -5,43 +5,34 @@ import DashboardConnect from 'connectors/Dashboard.connector';
|
||||
import ItemForm from 'components/Items/ItemForm';
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import ItemsConnect from 'connectors/Items.connect';
|
||||
import AccountsConnect from 'connectors/Accounts.connector';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const ItemFormContainer = ({
|
||||
changePageTitle,
|
||||
fetchAccount,
|
||||
submitItem,
|
||||
editItem,
|
||||
fetchItems,
|
||||
fetchItem,
|
||||
deleteItem,
|
||||
accounts
|
||||
fetchAccounts,
|
||||
}) => {
|
||||
const { id } = useParams();
|
||||
useEffect(() => {
|
||||
id ? changePageTitle('Edit Item Details') : changePageTitle('New Item');
|
||||
id ?
|
||||
changePageTitle('Edit Item Details') :
|
||||
changePageTitle('New Item');
|
||||
}, []);
|
||||
|
||||
const fetchHook = useAsync(async () => {
|
||||
await Promise.all([fetchAccount()]);
|
||||
await Promise.all([
|
||||
fetchAccounts(),
|
||||
]);
|
||||
});
|
||||
return (
|
||||
<DashboardInsider isLoading={fetchHook.loading} name={'expense-form'}>
|
||||
<ItemForm
|
||||
{...{
|
||||
submitItem,
|
||||
editItem,
|
||||
fetchItem,
|
||||
fetchItems,
|
||||
deleteItem,
|
||||
accounts
|
||||
}}
|
||||
/>
|
||||
<DashboardInsider isLoading={fetchHook.loading} name={'item-form'}>
|
||||
<ItemForm />
|
||||
</DashboardInsider>
|
||||
);
|
||||
};
|
||||
|
||||
export default compose(
|
||||
DashboardConnect,
|
||||
ItemsConnect
|
||||
// AccountsConnect
|
||||
ItemsConnect,
|
||||
AccountsConnect,
|
||||
)(ItemFormContainer);
|
||||
|
||||
@@ -19,7 +19,7 @@ import Icon from 'components/Icon';
|
||||
import {handleBooleanChange} from 'utils';
|
||||
|
||||
const ItemsDataTable = ({
|
||||
fetchItems,
|
||||
requestFetchItems,
|
||||
filterConditions,
|
||||
currentPageItems,
|
||||
onEditItem,
|
||||
@@ -31,7 +31,7 @@ const ItemsDataTable = ({
|
||||
|
||||
const fetchHook = useAsync(async () => {
|
||||
await Promise.all([
|
||||
fetchItems({
|
||||
requestFetchItems({
|
||||
custom_view_id: customViewId,
|
||||
stringified_filter_roles: JSON.stringify(filterConditions),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user