mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat(qucikpayment):add exchange rate muted.
This commit is contained in:
@@ -1,14 +1,25 @@
|
||||
import React, { useContext, createContext } from 'react';
|
||||
import { pick } from 'lodash';
|
||||
import { DialogContent } from 'components';
|
||||
import { useAccounts, useInvoice, useSettingsPaymentReceives, useCreatePaymentReceive } from 'hooks/query';
|
||||
import {
|
||||
useAccounts,
|
||||
useInvoice,
|
||||
useBranches,
|
||||
useSettingsPaymentReceives,
|
||||
useCreatePaymentReceive,
|
||||
} from 'hooks/query';
|
||||
|
||||
const QuickPaymentReceiveContext = createContext();
|
||||
|
||||
/**
|
||||
* Quick payment receive dialog provider.
|
||||
*/
|
||||
function QuickPaymentReceiveFormProvider({ invoiceId, dialogName, ...props }) {
|
||||
function QuickPaymentReceiveFormProvider({
|
||||
invoiceId,
|
||||
dialogName,
|
||||
baseCurrency,
|
||||
...props
|
||||
}) {
|
||||
// Handle fetch accounts data.
|
||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||
|
||||
@@ -22,9 +33,19 @@ function QuickPaymentReceiveFormProvider({ invoiceId, dialogName, ...props }) {
|
||||
// Fetch payment made settings.
|
||||
const { isLoading: isSettingsLoading } = useSettingsPaymentReceives();
|
||||
|
||||
// Fetches the branches list.
|
||||
const {
|
||||
data: branches,
|
||||
isLoading: isBranchesLoading,
|
||||
isSuccess: isBranchesSuccess,
|
||||
} = useBranches();
|
||||
|
||||
|
||||
|
||||
// State provider.
|
||||
const provider = {
|
||||
accounts,
|
||||
branches,
|
||||
invoice: {
|
||||
...pick(invoice, ['id', 'due_amount', 'customer', 'currency_code']),
|
||||
customer_id: invoice?.customer?.display_name,
|
||||
@@ -32,13 +53,16 @@ function QuickPaymentReceiveFormProvider({ invoiceId, dialogName, ...props }) {
|
||||
},
|
||||
isAccountsLoading,
|
||||
isSettingsLoading,
|
||||
isBranchesSuccess,
|
||||
dialogName,
|
||||
|
||||
baseCurrency,
|
||||
createPaymentReceiveMutate,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent isLoading={isAccountsLoading || isInvoiceLoading}>
|
||||
<DialogContent
|
||||
isLoading={isAccountsLoading || isInvoiceLoading || isBranchesLoading}
|
||||
>
|
||||
<QuickPaymentReceiveContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user