mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix(InvoiceForm): control display exchange rate input for foreign customers.
This commit is contained in:
28
src/containers/Sales/Invoices/InvoiceForm/components.js
Normal file
28
src/containers/Sales/Invoices/InvoiceForm/components.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { ExchangeRateInputGroup } from 'components';
|
||||
import { useCurrentOrganization } from 'hooks/state';
|
||||
import { useInvoiceIsForeignCustomer } from './utils';
|
||||
|
||||
/**
|
||||
* Invoice exchange rate input field.
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
export function InvoiceExchangeRateInputField({ ...props }) {
|
||||
const currentOrganization = useCurrentOrganization();
|
||||
const { values } = useFormikContext();
|
||||
|
||||
const isForeignCustomer = useInvoiceIsForeignCustomer();
|
||||
|
||||
// Can't continue if the customer is not foreign.
|
||||
if (!isForeignCustomer) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ExchangeRateInputGroup
|
||||
fromCurrency={values.currency_code}
|
||||
toCurrency={currentOrganization.base_currency}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user