All files / src/sections/PayBuilder/hooks useExpandedActions.ts

63.63% Statements 7/11
0% Branches 0/2
50% Functions 1/2
63.63% Lines 7/11

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            12x 204x 204x 204x 204x   204x                                         204x    
import NiceModal from "@ebay/nice-modal-react";
import { PUBLIC_FORM_PATHS } from "@routes/paths";
import { useNavigate, useParams } from "react-router-dom";
import { useGetRebrandedFormTypes } from "../utils";
import { DonationType } from "@types/products/fundraiser.types";
 
export const useExpandedActions = (data: DonationType, modalId: string) => {
  const navigate = useNavigate();
  const { id } = useParams();
  const rebrandedFormTypes = useGetRebrandedFormTypes();
  const type = data?.typeName;
 
  const editPaymentForm = () => {
    if (rebrandedFormTypes.includes(type)) {
      navigate(
        {
          pathname: `/${PUBLIC_FORM_PATHS.PAY_PRODUCT_BUILDER}/${id}`,
          search: `type=${type}&edit=true`,
        },
        {
          state: {
            id: id,
            prevUrl: location.pathname,
            formType: type,
            isEdit: true,
          },
        },
      );
      return;
    }
    NiceModal.show(modalId, { id });
  };
 
  return { editPaymentForm };
};