mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
- Fix typo ONWERS_DRAWING -> OWNERS_DRAWING in server constants - Change OwnerDrawing -> owner_drawing for consistency in webapp - Fix typo TRANSACRIONS_TYPE -> TRANSACTIONS_TYPE - Fix typo OnwersDrawing -> OwnerDrawing - Add missing Icon and FDateInput imports - Add dark mode styling for BranchRowDivider Co-Authored-By: Claude Code <noreply@anthropic.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
import { useFormikContext } from 'formik';
|
|
import { transactionNumber } from '@/utils';
|
|
import { first, isEqual, isNull } from 'lodash';
|
|
|
|
import { useMoneyOutDialogContext } from './MoneyOutDialogProvider';
|
|
import { useMoneyOutFieldsContext } from './MoneyOutFieldsProvider';
|
|
|
|
export const useObserveTransactionNoSettings = (prefix, nextNumber) => {
|
|
const { setFieldValue } = useFormikContext();
|
|
|
|
React.useEffect(() => {
|
|
const TransactionNo = transactionNumber(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 useForeignAccount = () => {
|
|
const { values } = useFormikContext();
|
|
const { account } = useMoneyOutFieldsContext();
|
|
|
|
return (
|
|
!isEqual(account.currency_code, values.currency_code) &&
|
|
!isNull(account.currency_code)
|
|
);
|
|
};
|
|
export const BranchRowDivider = styled.div`
|
|
height: 1px;
|
|
background: #ebf1f6;
|
|
margin-bottom: 15px;
|
|
|
|
.bp4-dark & {
|
|
background: var(--color-dark-gray5);
|
|
}
|
|
`;
|