feat: controlled transactions locking type.

This commit is contained in:
a.bouhuolia
2021-12-14 19:01:15 +02:00
parent bd97a73c65
commit 29a34f826a

View File

@@ -1,6 +1,7 @@
import React from 'react';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import { useTransactionsLocking } from 'hooks/query';
import { useWatchImmediate } from '../../hooks/utils/useWatch';
const TransactionsLockingContext = React.createContext();
@@ -15,9 +16,17 @@ function TransactionsLockingProvider({ ...props }) {
isLoading: isTransactionLockingLoading,
} = useTransactionsLocking();
// Transactions locking type.
const [transactionLockingType, setTransactionLockingType] =
React.useState('partial');
// Locking type controlled from response.
useWatchImmediate(() => {
if (transactionsLocking.locking_type) {
setTransactionLockingType(transactionsLocking.locking_type);
}
}, transactionsLocking.locking_type);
// Provider
const provider = {
transactionsLocking,