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