mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-13 11:20:31 +00:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import { DialogContent } from 'components';
|
|
import {
|
|
useCreateLockingTransactoin,
|
|
useEditTransactionsLocking,
|
|
} from 'hooks/query';
|
|
|
|
const LockingTransactionsContext = React.createContext();
|
|
|
|
/**
|
|
* Locking transactions form provider.
|
|
*/
|
|
function LockingTransactionsFormProvider({
|
|
moduleName,
|
|
isEnabled,
|
|
dialogName,
|
|
...props
|
|
}) {
|
|
// Create locking transactions mutations.
|
|
const { mutateAsync: createLockingTransactionMutate } =
|
|
useCreateLockingTransactoin();
|
|
|
|
const { data: transactionLocking, isLoading: isTransactionsLockingLoading } =
|
|
useEditTransactionsLocking(moduleName, {
|
|
enabled: !!isEnabled,
|
|
});
|
|
|
|
// State provider.
|
|
const provider = {
|
|
dialogName,
|
|
moduleName,
|
|
createLockingTransactionMutate,
|
|
transactionLocking,
|
|
isEnabled,
|
|
};
|
|
return (
|
|
<DialogContent isLoading={isTransactionsLockingLoading}>
|
|
<LockingTransactionsContext.Provider value={provider} {...props} />
|
|
</DialogContent>
|
|
);
|
|
}
|
|
|
|
const useLockingTransactionsContext = () =>
|
|
React.useContext(LockingTransactionsContext);
|
|
|
|
export { LockingTransactionsFormProvider, useLockingTransactionsContext };
|