diff --git a/client/src/components/DataTableCells/EstimatesListFieldCell.js b/client/src/components/DataTableCells/ItemsListCell.js
similarity index 50%
rename from client/src/components/DataTableCells/EstimatesListFieldCell.js
rename to client/src/components/DataTableCells/ItemsListCell.js
index 1923028c0..3923bd8da 100644
--- a/client/src/components/DataTableCells/EstimatesListFieldCell.js
+++ b/client/src/components/DataTableCells/ItemsListCell.js
@@ -1,15 +1,16 @@
import React, { useCallback, useMemo } from 'react';
-import EstimateListField from 'components/EstimateListField';
+import ItemListField from 'components/ItemListField';
import classNames from 'classnames';
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
-function EstimatesListFieldCell({
+
+function ItemsListCell({
column: { id },
row: { index },
cell: { value: initialValue },
- payload: { products, updateData, errors },
+ payload: { items, updateData, errors },
}) {
- const handleProductSelected = useCallback(
+ const handleItemSelected = useCallback(
(item) => {
updateData(index, id, item.id);
},
@@ -21,18 +22,15 @@ function EstimatesListFieldCell({
return (
-
);
}
-export default EstimatesListFieldCell;
+export default ItemsListCell;
diff --git a/client/src/components/DataTableCells/index.js b/client/src/components/DataTableCells/index.js
index 16bf06425..1c130ae2f 100644
--- a/client/src/components/DataTableCells/index.js
+++ b/client/src/components/DataTableCells/index.js
@@ -2,15 +2,15 @@ import AccountsListFieldCell from './AccountsListFieldCell';
import MoneyFieldCell from './MoneyFieldCell';
import InputGroupCell from './InputGroupCell';
import ContactsListFieldCell from './ContactsListFieldCell';
-import EstimatesListFieldCell from './EstimatesListFieldCell';
+import ItemsListCell from './ItemsListCell';
import PercentFieldCell from './PercentFieldCell';
-import { DivFieldCell,EmptyDiv } from './DivFieldCell';
+import { DivFieldCell, EmptyDiv } from './DivFieldCell';
export {
AccountsListFieldCell,
MoneyFieldCell,
InputGroupCell,
ContactsListFieldCell,
- EstimatesListFieldCell,
+ ItemsListCell,
PercentFieldCell,
DivFieldCell,
EmptyDiv,
diff --git a/client/src/components/EstimateListField.js b/client/src/components/EstimateListField.js
deleted file mode 100644
index affd29e4b..000000000
--- a/client/src/components/EstimateListField.js
+++ /dev/null
@@ -1,72 +0,0 @@
-import React, { useCallback, useMemo, useEffect, useState } from 'react';
-import { MenuItem } from '@blueprintjs/core';
-import ListSelect from 'components/ListSelect';
-
-function EstimateListField({
- products,
- initialProductId,
- selectedProductId,
- defautlSelectText = 'Click to select an item.',
- onProductSelected,
-}) {
- const initialProduct = useMemo(
- () => products.find((a) => a.id === initialProductId),
- [initialProductId],
- );
-
- const [selectedProduct, setSelectedProduct] = useState(
- initialProduct || null,
- );
-
- useEffect(() => {
- if (typeof selectedProductId !== 'undefined') {
- const product = selectedProductId
- ? products.find((a) => a.id === selectedProductId)
- : null;
- setSelectedProduct(product);
- }
- }, [selectedProductId, products, setSelectedProduct]);
-
- const onProductSelect = useCallback(
- (product) => {
- setSelectedProduct({ ...product });
- onProductSelected && onProductSelected(product);
- },
- [onProductSelected],
- );
-
- const productRenderer = useCallback(
- (item, { handleClick }) => (
-
- ),
- [],
- );
-
- const filterProduct = useCallback((query, product, _index, exactMatch) => {
- const normalizedTitle = product.name.toLowerCase();
- const normalizedQuery = query.toLowerCase();
-
- if (exactMatch) {
- return normalizedTitle === normalizedQuery;
- } else {
- return normalizedTitle.indexOf(normalizedQuery) >= 0;
- }
- }, []);
-
- return (
- }
- itemRenderer={productRenderer}
- itemPredicate={filterProduct}
- popoverProps={{ minimal: true }}
- onItemSelect={onProductSelect}
- selectedItem={`${selectedProductId}`}
- selectedItemProp={'id'}
- labelProp={'name'}
- defaultText={selectedProduct ? selectedProduct.name : defautlSelectText}
- />
- );
-}
-
-export default EstimateListField;
diff --git a/client/src/components/ItemListField.js b/client/src/components/ItemListField.js
new file mode 100644
index 000000000..46510cb86
--- /dev/null
+++ b/client/src/components/ItemListField.js
@@ -0,0 +1,69 @@
+import React, { useCallback, useMemo, useEffect, useState } from 'react';
+import { MenuItem } from '@blueprintjs/core';
+import ListSelect from 'components/ListSelect';
+
+function ItemListField({
+ items,
+ initialItemId,
+ selectedItemId,
+ defautlSelectText = 'Click to select an item.',
+ onItemSelected,
+}) {
+ const initialItem = useMemo(() => items.find((a) => a.id === initialItemId), [
+ initialItemId,
+ ]);
+
+ const [selectedItem, setSelectedItem] = useState(initialItem || null);
+
+ useEffect(() => {
+ if (typeof selectedItemId !== 'undefined') {
+ const item = selectedItemId
+ ? items.find((a) => a.id === selectedItemId)
+ : null;
+ setSelectedItem(item);
+ }
+ }, [selectedItemId, items, setSelectedItem]);
+
+ const onItemSelect = useCallback(
+ (item) => {
+ setSelectedItem({ ...item });
+ onItemSelected && onItemSelected(item);
+ },
+ [onItemSelected],
+ );
+
+ const itemRenderer = useCallback(
+ (item, { handleClick }) => (
+
+ ),
+ [],
+ );
+
+ const filterItem = useCallback((query, item, _index, exactMatch) => {
+ const normalizedTitle = item.name.toLowerCase();
+ const normalizedQuery = query.toLowerCase();
+
+ if (exactMatch) {
+ return normalizedTitle === normalizedQuery;
+ } else {
+ return normalizedTitle.indexOf(normalizedQuery) >= 0;
+ }
+ }, []);
+
+ return (
+ }
+ itemRenderer={itemRenderer}
+ itemPredicate={filterItem}
+ popoverProps={{ minimal: true }}
+ onItemSelect={onItemSelect}
+ selectedItem={`${selectedItemId}`}
+ selectedItemProp={'id'}
+ labelProp={'name'}
+ defaultText={selectedItem ? selectedItem.name : defautlSelectText}
+ />
+ );
+}
+
+export default ItemListField;
diff --git a/client/src/containers/Purchases/Bill/BillFloatingActions.js b/client/src/containers/Purchases/Bill/BillFloatingActions.js
new file mode 100644
index 000000000..2373433a4
--- /dev/null
+++ b/client/src/containers/Purchases/Bill/BillFloatingActions.js
@@ -0,0 +1,54 @@
+import React from 'react';
+import { Intent, Button } from '@blueprintjs/core';
+import { FormattedMessage as T } from 'react-intl';
+
+export default function BillFloatingActions({
+ formik: { isSubmitting },
+ onSubmitClick,
+ onCancelClick,
+ bill,
+}) {
+ return (
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Purchases/Bill/BillForm.js b/client/src/containers/Purchases/Bill/BillForm.js
index dc8fd018a..4c2954245 100644
--- a/client/src/containers/Purchases/Bill/BillForm.js
+++ b/client/src/containers/Purchases/Bill/BillForm.js
@@ -8,24 +8,21 @@ import React, {
import * as Yup from 'yup';
import { useFormik } from 'formik';
import moment from 'moment';
-import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
+import { Intent } from '@blueprintjs/core';
import classNames from 'classnames';
import { FormattedMessage as T, useIntl } from 'react-intl';
import { pick } from 'lodash';
import { CLASSES } from 'common/classes';
import BillFormHeader from './BillFormHeader';
import EstimatesItemsTable from 'containers/Sales/Estimate/EntriesItemsTable';
+import BillFloatingActions from './BillFloatingActions';
import BillFormFooter from './BillFormFooter';
-
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withMediaActions from 'containers/Media/withMediaActions';
-import withBills from './withBills';
import withBillActions from './withBillActions';
import withBillDetail from './withBillDetail';
-import withSettings from 'containers/Settings/withSettings';
-import { AppToaster, Row, Col } from 'components';
-import Dragzone from 'components/Dragzone';
+import { AppToaster } from 'components';
import useMedia from 'hooks/useMedia';
import { compose, repeatValue } from 'utils';
@@ -45,13 +42,6 @@ function BillForm({
//#withDashboard
changePageTitle,
- // #withBills
- nextBillNumberChanged,
-
- // #withSettings
- billNextNumber,
- billNumberPrefix,
-
//#withBillDetail
bill,
@@ -147,14 +137,11 @@ function BillForm({
[],
);
- const billNumber = billNumberPrefix
- ? `${billNumberPrefix}-${billNextNumber}`
- : billNextNumber;
const defaultInitialValues = useMemo(
() => ({
vendor_id: '',
- bill_number: billNumber,
+ bill_number: '',
bill_date: moment(new Date()).format('YYYY-MM-DD'),
due_date: moment(new Date()).format('YYYY-MM-DD'),
// status: 'Bill',
@@ -162,7 +149,7 @@ function BillForm({
note: '',
entries: [...repeatValue(defaultBill, MIN_LINES_NUMBER)],
}),
- [defaultBill, billNumber],
+ [defaultBill],
);
const orderingIndex = (_bill) => {
@@ -259,11 +246,6 @@ function BillForm({
},
});
- useEffect(() => {
- formik.setFieldValue('bill_number', billNumber);
- setBillNumberChanged(false);
- }, [nextBillNumberChanged, billNumber]);
-
const handleSubmitClick = useCallback(
(payload) => {
setPayload(payload);
@@ -290,7 +272,7 @@ function BillForm({
},
[setDeletedFiles, deletedFiles],
);
-
+
const onClickCleanAllLines = () => {
formik.setFieldValue(
'entries',
@@ -305,10 +287,7 @@ function BillForm({
);
};
return (
-
+
-
@@ -354,11 +316,6 @@ function BillForm({
export default compose(
withBillActions,
withBillDetail(),
- withBills(({ nextBillNumberChanged }) => ({ nextBillNumberChanged })),
withDashboardActions,
withMediaActions,
- withSettings(({ billsettings }) => ({
- billNextNumber: billsettings?.next_number,
- billNumberPrefix: billsettings?.number_prefix,
- })),
)(BillForm);
diff --git a/client/src/containers/Purchases/Bill/BillFormFooter.js b/client/src/containers/Purchases/Bill/BillFormFooter.js
index 1be37d6d9..4475b15d8 100644
--- a/client/src/containers/Purchases/Bill/BillFormFooter.js
+++ b/client/src/containers/Purchases/Bill/BillFormFooter.js
@@ -1,54 +1,32 @@
import React from 'react';
-import { Intent, Button } from '@blueprintjs/core';
+import { FormGroup, TextArea } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
+import { Row, Col } from 'components';
+import Dragzone from 'components/Dragzone';
-export default function BillFormFooter({
- formik: { isSubmitting },
- onSubmitClick,
- onCancelClick,
- bill,
+export default function BillFloatingActions({
+ formik: { getFieldProps },
+ oninitialFiles,
+ onDropFiles,
}) {
return (
-
-
+
);
}
diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeFormFooter.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js
similarity index 100%
rename from client/src/containers/Purchases/PaymentMades/PaymentMadeFormFooter.js
rename to client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js
diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
index bd1f12896..3206c6ab5 100644
--- a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
+++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
@@ -16,7 +16,7 @@ import { pick, values } from 'lodash';
import PaymentMadeHeader from './PaymentMadeFormHeader';
import PaymentMadeItemsTable from './PaymentMadeItemsTable';
-import PaymentMadeFooter from './PaymentMadeFormFooter';
+import PaymentMadeFloatingActions from './PaymentMadeFloatingActions';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withMediaActions from 'containers/Media/withMediaActions';
@@ -319,7 +319,7 @@ function PaymentMadeForm({
hint={'Attachments: Maxiumum size: 20MB'}
/> */}
-
{
);
};
-function EstimateTable({
+function EntriesItemsTable({
//#withitems
itemsCurrentPage,
@@ -109,7 +109,8 @@ function EstimateTable({
Header: ItemHeaderCell,
id: 'item_id',
accessor: 'item_id',
- Cell: EstimatesListFieldCell,
+ Cell: ItemsListCell,
+ // ItemsListCell
disableSortBy: true,
width: 180,
},
@@ -239,7 +240,7 @@ function EstimateTable({
data={rows}
rowClassNames={rowClassNames}
payload={{
- products: itemsCurrentPage,
+ items: itemsCurrentPage,
errors: errors.entries || [],
updateData: handleUpdateData,
removeRow: handleRemoveRow,
@@ -270,4 +271,4 @@ export default compose(
withItems(({ itemsCurrentPage }) => ({
itemsCurrentPage,
})),
-)(EstimateTable);
+)(EntriesItemsTable);
diff --git a/client/src/containers/Sales/Estimate/EstimateFormFooter.js b/client/src/containers/Sales/Estimate/EstimateFloatingActions.js
similarity index 96%
rename from client/src/containers/Sales/Estimate/EstimateFormFooter.js
rename to client/src/containers/Sales/Estimate/EstimateFloatingActions.js
index ac6c3469d..dd8646263 100644
--- a/client/src/containers/Sales/Estimate/EstimateFormFooter.js
+++ b/client/src/containers/Sales/Estimate/EstimateFloatingActions.js
@@ -3,7 +3,7 @@ import { Intent, Button } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
import { queryCache } from 'react-query';
-export default function EstimateFormFooter({
+export default function EstimateFloatingActions({
formik: { isSubmitting, resetForm },
onSubmitClick,
onCancelClick,
diff --git a/client/src/containers/Sales/Estimate/EstimateForm.js b/client/src/containers/Sales/Estimate/EstimateForm.js
index 43d71e04f..c1df70b5c 100644
--- a/client/src/containers/Sales/Estimate/EstimateForm.js
+++ b/client/src/containers/Sales/Estimate/EstimateForm.js
@@ -15,8 +15,8 @@ import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import EstimateFormHeader from './EstimateFormHeader';
-import EstimatesItemsTable from './EntriesItemsTable';
-import EstimateFormFooter from './EstimateFormFooter';
+import EntriesItemsTable from './EntriesItemsTable';
+import EstimateFloatingActions from './EstimateFloatingActions';
import withEstimateActions from './withEstimateActions';
import withEstimateDetail from './withEstimateDetail';
@@ -308,7 +308,7 @@ const EstimateForm = ({
)}>
-
- */}
-
-
-