mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
35 lines
931 B
TypeScript
35 lines
931 B
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import { DialogContent } from '@/components';
|
|
import { useAccount } from '@/hooks/query';
|
|
import { useMoneyInDailogContext } from './MoneyInDialogProvider';
|
|
|
|
const MoneyInFieldsContext = React.createContext();
|
|
|
|
/**
|
|
* Money in dialog provider.
|
|
*/
|
|
function MoneyInFieldsProvider({ ...props }) {
|
|
const { accountId } = useMoneyInDailogContext();
|
|
|
|
// Fetches the specific account details.
|
|
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
|
|
enabled: !!accountId,
|
|
});
|
|
// Provider data.
|
|
const provider = {
|
|
account,
|
|
};
|
|
const isLoading = isAccountLoading;
|
|
|
|
return (
|
|
<DialogContent isLoading={isLoading}>
|
|
<MoneyInFieldsContext.Provider value={provider} {...props} />
|
|
</DialogContent>
|
|
);
|
|
}
|
|
|
|
const useMoneyInFieldsContext = () => React.useContext(MoneyInFieldsContext);
|
|
|
|
export { MoneyInFieldsProvider, useMoneyInFieldsContext };
|