mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feature : Puschases & Sales / fix : tasks
This commit is contained in:
@@ -9,9 +9,10 @@ import * as Yup from 'yup';
|
||||
import { useFormik } from 'formik';
|
||||
import moment from 'moment';
|
||||
import { Intent, FormGroup, TextArea } from '@blueprintjs/core';
|
||||
import { Row, Col } from 'react-grid-system';
|
||||
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import { pick, omit } from 'lodash';
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import BillFormHeader from './BillFormHeader';
|
||||
import EstimatesItemsTable from 'containers/Sales/Estimate/EntriesItemsTable';
|
||||
@@ -82,6 +83,7 @@ function BillForm({
|
||||
}
|
||||
}, [changePageTitle, bill, formatMessage]);
|
||||
|
||||
// @todo abstruct validation schema to sperated file.
|
||||
const validationSchema = Yup.object().shape({
|
||||
vendor_id: Yup.number()
|
||||
.required()
|
||||
@@ -102,7 +104,6 @@ function BillForm({
|
||||
.min(1)
|
||||
.max(1024)
|
||||
.label(formatMessage({ id: 'note' })),
|
||||
|
||||
entries: Yup.array().of(
|
||||
Yup.object().shape({
|
||||
quantity: Yup.number().nullable(),
|
||||
@@ -180,14 +181,6 @@ function BillForm({
|
||||
[bill, defaultInitialValues, defaultBill],
|
||||
);
|
||||
|
||||
// const initialValues = useMemo(
|
||||
// () => ({
|
||||
// ...defaultInitialValues,
|
||||
// entries: orderingIndex(defaultInitialValues.entries),
|
||||
// }),
|
||||
// [defaultInitialValues],
|
||||
// );
|
||||
|
||||
const initialAttachmentFiles = useMemo(() => {
|
||||
return bill && bill.media
|
||||
? bill.media.map((attach) => ({
|
||||
@@ -207,14 +200,10 @@ function BillForm({
|
||||
onSubmit: async (values, { setSubmitting, setErrors, resetForm }) => {
|
||||
setSubmitting(true);
|
||||
|
||||
const entries = values.entries.filter(
|
||||
(item) => item.item_id && item.quantity,
|
||||
);
|
||||
const form = {
|
||||
...values,
|
||||
entries,
|
||||
entries: values.entries.filter((item) => item.item_id && item.quantity),
|
||||
};
|
||||
|
||||
const requestForm = { ...form };
|
||||
if (bill && bill.id) {
|
||||
requestEditBill(bill.id, requestForm)
|
||||
@@ -243,8 +232,8 @@ function BillForm({
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setSubmitting(false);
|
||||
resetForm();
|
||||
saveBillSubmit({ action: 'new', ...payload });
|
||||
resetForm();
|
||||
})
|
||||
.catch((errors) => {
|
||||
setSubmitting(false);
|
||||
@@ -292,10 +281,6 @@ function BillForm({
|
||||
orderingIndex([...formik.values.entries, defaultBill]),
|
||||
);
|
||||
};
|
||||
|
||||
console.log(formik.errors, 'Errors');
|
||||
console.log(formik.values, 'values');
|
||||
|
||||
return (
|
||||
<div className={'bill-form'}>
|
||||
<form onSubmit={formik.handleSubmit}>
|
||||
@@ -306,15 +291,25 @@ function BillForm({
|
||||
onClickAddNewRow={onClickAddNewRow}
|
||||
onClickClearAllLines={onClickCleanAllLines}
|
||||
/>
|
||||
<FormGroup label={<T id={'note'} />} className={'form-group--'}>
|
||||
<TextArea growVertically={true} {...formik.getFieldProps('note')} />
|
||||
</FormGroup>
|
||||
<Dragzone
|
||||
initialFiles={initialAttachmentFiles}
|
||||
onDrop={handleDropFiles}
|
||||
onDeleteFile={handleDeleteFile}
|
||||
hint={'Attachments: Maxiumum size: 20MB'}
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
<FormGroup label={<T id={'note'} />} className={'form-group--'}>
|
||||
<TextArea
|
||||
growVertically={true}
|
||||
{...formik.getFieldProps('note')}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
|
||||
<Col>
|
||||
<Dragzone
|
||||
initialFiles={initialAttachmentFiles}
|
||||
onDrop={handleDropFiles}
|
||||
onDeleteFile={handleDeleteFile}
|
||||
hint={'Attachments: Maxiumum size: 20MB'}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</form>
|
||||
<BillFormFooter
|
||||
formik={formik}
|
||||
|
||||
@@ -9,7 +9,7 @@ export default function BillFormFooter({
|
||||
bill,
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<div className={'form__floating-footer'}>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
|
||||
@@ -76,12 +76,10 @@ function BillFormHeader({
|
||||
}
|
||||
};
|
||||
|
||||
console.log(vendorsCurrentPage, 'vendorsCurrentPage');
|
||||
console.log(vendorItems, 'vendorItems');
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
{/* vendor account name */}
|
||||
<div className="page-form page-form--bill">
|
||||
<div className={'page-form__primary-section'}>
|
||||
{/* Vendor account name */}
|
||||
<FormGroup
|
||||
label={<T id={'vendor_name'} />}
|
||||
inline={true}
|
||||
|
||||
@@ -106,6 +106,7 @@ function BillsDataTable({
|
||||
text={formatMessage({ id: 'delete_bill' })}
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleDeleteBill(bill)}
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
/>
|
||||
</Menu>
|
||||
),
|
||||
|
||||
@@ -3,20 +3,25 @@ import { getResourceViews } from 'store/customViews/customViews.selectors';
|
||||
import {
|
||||
getBillCurrentPageFactory,
|
||||
getBillPaginationMetaFactory,
|
||||
getBillTableQuery,
|
||||
getBillTableQueryFactory,
|
||||
} from 'store/Bills/bills.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
const getBillsItems = getBillCurrentPageFactory();
|
||||
const getBillsPaginationMeta = getBillPaginationMetaFactory();
|
||||
const getBillTableQuery = getBillTableQueryFactory();
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const query = getBillTableQuery(state, props);
|
||||
const tableQuery = getBillTableQuery(state, props);
|
||||
|
||||
const mapped = {
|
||||
billsCurrentPage: getBillsItems(state, props, query),
|
||||
billsCurrentPage: getBillsItems(state, props, tableQuery),
|
||||
billsViews: getResourceViews(state, props, 'bills'),
|
||||
billsItems: state.bills.items,
|
||||
billsTableQuery: query,
|
||||
billsPageination: getBillsPaginationMeta(state, props, query),
|
||||
billsTableQuery: tableQuery,
|
||||
|
||||
// @todo un-unncessery shit.
|
||||
billsPageination: getBillsPaginationMeta(state, props, tableQuery),
|
||||
billsLoading: state.bills.loading,
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
|
||||
Reference in New Issue
Block a user