feat(qucikpayment):add exchange rate muted.

This commit is contained in:
elforjani13
2022-03-07 18:35:11 +02:00
parent d12e35f649
commit b26b4c5491
9 changed files with 252 additions and 37 deletions

View File

@@ -1,6 +1,11 @@
import React from 'react';
import { DialogContent } from 'components';
import { useBill, useAccounts, useCreatePaymentMade } from 'hooks/query';
import {
useBill,
useAccounts,
useBranches,
useCreatePaymentMade,
} from 'hooks/query';
import { pick } from 'lodash';
@@ -9,7 +14,12 @@ const QuickPaymentMadeContext = React.createContext();
/**
* Quick payment made dialog provider.
*/
function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
function QuickPaymentMadeFormProvider({
billId,
baseCurrency,
dialogName,
...props
}) {
// Handle fetch bill details.
const { isLoading: isBillLoading, data: bill } = useBill(billId, {
enabled: !!billId,
@@ -21,6 +31,13 @@ function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
// Create payment made mutations.
const { mutateAsync: createPaymentMadeMutate } = useCreatePaymentMade();
// Fetches the branches list.
const {
data: branches,
isLoading: isBranchesLoading,
isSuccess: isBranchesSuccess,
} = useBranches();
// State provider.
const provider = {
bill: {
@@ -29,12 +46,17 @@ function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
payment_amount: bill?.due_amount,
},
accounts,
branches,
dialogName,
baseCurrency,
createPaymentMadeMutate,
isBranchesSuccess,
};
return (
<DialogContent isLoading={isAccountsLoading || isBillLoading}>
<DialogContent
isLoading={isAccountsLoading || isBillLoading || isBranchesLoading}
>
<QuickPaymentMadeContext.Provider value={provider} {...props} />
</DialogContent>
);