mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: controlled transactions locking type.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import { useTransactionsLocking } from 'hooks/query';
|
import { useTransactionsLocking } from 'hooks/query';
|
||||||
|
import { useWatchImmediate } from '../../hooks/utils/useWatch';
|
||||||
|
|
||||||
const TransactionsLockingContext = React.createContext();
|
const TransactionsLockingContext = React.createContext();
|
||||||
|
|
||||||
@@ -15,9 +16,17 @@ function TransactionsLockingProvider({ ...props }) {
|
|||||||
isLoading: isTransactionLockingLoading,
|
isLoading: isTransactionLockingLoading,
|
||||||
} = useTransactionsLocking();
|
} = useTransactionsLocking();
|
||||||
|
|
||||||
|
// Transactions locking type.
|
||||||
const [transactionLockingType, setTransactionLockingType] =
|
const [transactionLockingType, setTransactionLockingType] =
|
||||||
React.useState('partial');
|
React.useState('partial');
|
||||||
|
|
||||||
|
// Locking type controlled from response.
|
||||||
|
useWatchImmediate(() => {
|
||||||
|
if (transactionsLocking.locking_type) {
|
||||||
|
setTransactionLockingType(transactionsLocking.locking_type);
|
||||||
|
}
|
||||||
|
}, transactionsLocking.locking_type);
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
transactionsLocking,
|
transactionsLocking,
|
||||||
|
|||||||
Reference in New Issue
Block a user