All files / src/sections/PayBuilder/Checkout/hooks useCardProcessingFees.tsx

12.5% Statements 1/8
100% Branches 0/0
0% Functions 0/2
12.5% Lines 1/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          13x                            
import { useCart } from "@sections/PayBuilder/provider/CartContext";
import { useEffect } from "react";
import { FEE_PAYER_OPTIONS } from "../consts";
import { usePayBuilderForm } from "@sections/PayBuilder/provider/PayBuilderFormProvider";
 
export const useCardProcessingFees = () => {
  const { setDisplayFees } = useCart();
  const { methods } = usePayBuilderForm();
  const checkoutSidepanelValues = methods.watch();
 
  const isCustomerCoveringFees =
    checkoutSidepanelValues.Checkout.feePayer === FEE_PAYER_OPTIONS.CUSTOMER;
 
  useEffect(() => {
    setDisplayFees(isCustomerCoveringFees);
  }, [isCustomerCoveringFees]);
 
  return { isCustomerCoveringFees };
};