mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import intl from 'react-intl-universal';
|
|
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
|
import {
|
|
useTransactionsByReference,
|
|
usePaymentMade,
|
|
usePaymentMadeEditPage,
|
|
} from 'hooks/query';
|
|
|
|
const PaymentMadeDetailContext = React.createContext();
|
|
|
|
/**
|
|
* Payment made detail provider.
|
|
*/
|
|
function PaymentMadeDetailProvider({ paymentMadeId, ...props }) {
|
|
// Handle fetch specific payment made details.
|
|
const { data: paymentMade, isLoading: isPaymentMadeLoading } = usePaymentMade(
|
|
paymentMadeId,
|
|
{
|
|
enabled: !!paymentMadeId,
|
|
},
|
|
);
|
|
// Provider state.
|
|
const provider = {
|
|
paymentMadeId,
|
|
paymentMade,
|
|
};
|
|
|
|
const loading = isPaymentMadeLoading;
|
|
|
|
return (
|
|
<DrawerLoading loading={loading}>
|
|
<DrawerHeaderContent
|
|
name="payment-made-detail-drawer"
|
|
title={intl.get('payment_made.drawer.title', {
|
|
number: paymentMade.payment_number
|
|
? `(${paymentMade.payment_number})`
|
|
: '',
|
|
})}
|
|
/>
|
|
<PaymentMadeDetailContext.Provider value={provider} {...props} />
|
|
</DrawerLoading>
|
|
);
|
|
}
|
|
|
|
const usePaymentMadeDetailContext = () =>
|
|
React.useContext(PaymentMadeDetailContext);
|
|
export { PaymentMadeDetailProvider, usePaymentMadeDetailContext };
|