All files / src/features/Merchants/GiveCreateMerchantPanel/components LocalBA.tsx

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                    3x 77x 77x   77x 77x 77x   77x             77x                          
import { Box } from "@mui/material";
 
import { IMerchantBankAccount } from "components/Merchants/MerchantPreview/data.types";
import { useFormContext } from "react-hook-form";
import BankAccountSection from "features/Merchants/MerchantSidePanel/GiveMerchantFile/components/BankAccountSection";
 
type Props = {
  onCloseModal?: (data?: IMerchantBankAccount, id?: number) => void;
};
 
const LocalBA = ({ onCloseModal }: Props) => {
  const { watch } = useFormContext();
  const values = watch();
 
  const data: IMerchantBankAccount[] = values.bankAccounts;
  const linkedBankAccountID = values.linkedBankAccountID;
  const merchantInfo = values.merchantInfo;
 
  const bankAccountSettings = {
    linkedAccountID: linkedBankAccountID as number,
    isLinkAccount: Boolean(linkedBankAccountID),
    allowTransfers: values?.allowTransfers,
    allowBankAccounts: values?.allowBankAccounts,
  };
 
  return (
    <Box data-testid="local-ba-container" mx="20px">
      <BankAccountSection
        bankAccounts={data}
        parentAccID={merchantInfo.enterpriseID}
        bankAccountSettings={bankAccountSettings}
        onCloseModal={onCloseModal}
      />
    </Box>
  );
};
 
export default LocalBA;