mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
fix(paymentmade): fix payment date & cancel and clear button.
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
||||||
@@ -21,8 +22,11 @@ import { Icon } from 'components';
|
|||||||
* Payment made floating actions bar.
|
* Payment made floating actions bar.
|
||||||
*/
|
*/
|
||||||
export default function PaymentMadeFloatingActions() {
|
export default function PaymentMadeFloatingActions() {
|
||||||
|
// History context.
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
// Formik context.
|
// Formik context.
|
||||||
const { isSubmitting } = useFormikContext();
|
const { isSubmitting, resetForm } = useFormikContext();
|
||||||
|
|
||||||
// Payment made form context.
|
// Payment made form context.
|
||||||
const { setSubmitPayload, paymentMadeId } = usePaymentMadeFormContext();
|
const { setSubmitPayload, paymentMadeId } = usePaymentMadeFormContext();
|
||||||
@@ -33,10 +37,14 @@ export default function PaymentMadeFloatingActions() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle clear button click.
|
// Handle clear button click.
|
||||||
const handleClearBtnClick = (event) => {};
|
const handleClearBtnClick = (event) => {
|
||||||
|
resetForm();
|
||||||
|
};
|
||||||
|
|
||||||
// Handle cancel button click.
|
// Handle cancel button click.
|
||||||
const handleCancelBtnClick = (event) => {};
|
const handleCancelBtnClick = (event) => {
|
||||||
|
history.goBack();
|
||||||
|
};
|
||||||
|
|
||||||
// Handle submit & new button click.
|
// Handle submit & new button click.
|
||||||
const handleSubmitAndNewClick = (event) => {
|
const handleSubmitAndNewClick = (event) => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
Position,
|
Position,
|
||||||
Classes,
|
Classes,
|
||||||
ControlGroup,
|
ControlGroup,
|
||||||
Button
|
Button,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, Field, useFormikContext, ErrorMessage } from 'formik';
|
import { FastField, Field, useFormikContext, ErrorMessage } from 'formik';
|
||||||
@@ -21,13 +21,14 @@ import {
|
|||||||
Money,
|
Money,
|
||||||
Hint,
|
Hint,
|
||||||
Icon,
|
Icon,
|
||||||
MoneyInputGroup
|
MoneyInputGroup,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
tansformDateValue,
|
tansformDateValue,
|
||||||
|
handleDateChange,
|
||||||
inputIntent,
|
inputIntent,
|
||||||
compose,
|
compose,
|
||||||
safeSumBy,
|
safeSumBy,
|
||||||
@@ -40,7 +41,10 @@ import {
|
|||||||
*/
|
*/
|
||||||
function PaymentMadeFormHeaderFields({ baseCurrency }) {
|
function PaymentMadeFormHeaderFields({ baseCurrency }) {
|
||||||
// Formik form context.
|
// Formik form context.
|
||||||
const { values: { entries }, setFieldValue } = useFormikContext();
|
const {
|
||||||
|
values: { entries },
|
||||||
|
setFieldValue,
|
||||||
|
} = useFormikContext();
|
||||||
|
|
||||||
// Payment made form context.
|
// Payment made form context.
|
||||||
const {
|
const {
|
||||||
@@ -49,10 +53,12 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
|
|||||||
isNewMode,
|
isNewMode,
|
||||||
setPaymentVendorId,
|
setPaymentVendorId,
|
||||||
} = usePaymentMadeFormContext();
|
} = usePaymentMadeFormContext();
|
||||||
|
|
||||||
// Sumation of payable full-amount.
|
// Sumation of payable full-amount.
|
||||||
const payableFullAmount = useMemo(() => safeSumBy(entries, 'due_amount'), [entries]);
|
const payableFullAmount = useMemo(() => safeSumBy(entries, 'due_amount'), [
|
||||||
|
entries,
|
||||||
|
]);
|
||||||
|
|
||||||
// Handle receive full-amount click.
|
// Handle receive full-amount click.
|
||||||
const handleReceiveFullAmountClick = () => {
|
const handleReceiveFullAmountClick = () => {
|
||||||
const newEntries = fullAmountPaymentEntries(entries);
|
const newEntries = fullAmountPaymentEntries(entries);
|
||||||
@@ -97,7 +103,7 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
|
|||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/* ------------ Payment date ------------ */}
|
{/* ------------ Payment date ------------ */}
|
||||||
<FastField name={'customer_id'}>
|
<FastField name={'payment_date'}>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'payment_date'} />}
|
label={<T id={'payment_date'} />}
|
||||||
@@ -110,7 +116,9 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
|
|||||||
<DateInput
|
<DateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
{...momentFormatter('YYYY/MM/DD')}
|
||||||
value={tansformDateValue(value)}
|
value={tansformDateValue(value)}
|
||||||
// onChange={handleDateChange('payment_date')}
|
onChange={handleDateChange((formattedDate) => {
|
||||||
|
form.setFieldValue('payment_date', formattedDate);
|
||||||
|
})}
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
leftIcon: <Icon icon={'date-range'} />,
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
|
|||||||
Reference in New Issue
Block a user