feat(cashflow): add ExchangeRateMutedField.

This commit is contained in:
elforjani13
2022-03-06 20:20:25 +02:00
parent 5c52f80536
commit 7467b63e54
20 changed files with 382 additions and 58 deletions

View File

@@ -1,6 +1,10 @@
import React from 'react';
import styled from 'styled-components';
import { useFormikContext } from 'formik';
import { transactionNumber } from 'utils';
import { first } from 'lodash';
import { useMoneyOutDialogContext } from './MoneyOutDialogProvider';
export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
const { setFieldValue } = useFormikContext();
@@ -10,3 +14,23 @@ export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
setFieldValue('transacttion_numner', TransactionNo);
}, [setFieldValue, prefix, nextNumber]);
};
export const useSetPrimaryBranchToForm = () => {
const { setFieldValue } = useFormikContext();
const { branches, isBranchesSuccess } = useMoneyOutDialogContext();
React.useEffect(() => {
if (isBranchesSuccess) {
const primaryBranch = branches.find((b) => b.primary) || first(branches);
if (primaryBranch) {
setFieldValue('branch_id', primaryBranch.id);
}
}
}, [isBranchesSuccess, setFieldValue, branches]);
};
export const BranchRowDivider = styled.div`
height: 1px;
background: #ebf1f6;
margin-bottom: 15px;
`;