All files / src/sections/PayBuilder/Checkout/components PayNowButtonSection.tsx

55.55% Statements 5/9
25% Branches 1/4
33.33% Functions 1/3
55.55% Lines 5/9

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            44x 20x 20x 20x 20x                                                
import { MoneyIcon } from "@phosphor-icons/react";
import { HFGiveInput } from "@shared/HFInputs/HFGiveInput/HFGiveInput";
import { Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { usePayBuilderForm } from "@sections/PayBuilder/provider/PayBuilderFormProvider";
import useCheckFormType from "@sections/PayBuilder/components/hooks/useCheckFormType";
const PayNowButtonSection = () => {
  const { methods } = usePayBuilderForm();
  const { isFundraiser } = useCheckFormType();
  const inputLabel = isFundraiser ? "Donate" : "Pay";
  return (
    <Stack gap="12px">
      <Stack gap="8px" alignItems="center" flexDirection="row">
        <MoneyIcon size={24} />
        <GiveText>{`${inputLabel} Now Button Text`}</GiveText>
      </Stack>
      <HFGiveInput
        data-testid="pay-input"
        name="Checkout.payButtonText"
        maxLength={50}
        handleNormalizeInput={(value: string) => {
          return value.replace(/[^a-zA-Z ]/g, "");
        }}
        onBlur={() => {
          const value = methods.getValues("Checkout.payButtonText").trim();
          if (value === "")
            methods.setValue("Checkout.payButtonText", `${inputLabel} Now`);
        }}
      />
    </Stack>
  );
};
 
export default PayNowButtonSection;