All files / src/features/GiveSignup helpers.ts

94.44% Statements 17/18
72.72% Branches 8/11
100% Functions 5/5
100% Lines 17/17

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54        483x 45x 45x   45x 45x       45x           483x 1x 1x 1x       1x 3x       483x                           483x     155x   483x 966x    
import useCheckEnvironment from "@hooks/common/useCheckEnvironment";
import { SignupEnum, TInputName } from "./types";
import { enterpriseName, initialBarsValue } from "./constants";
 
export const getURL = (classification: TInputName) => {
  const { getEnvironmentDomain, isProduction } = useCheckEnvironment();
  const enviroment = getEnvironmentDomain();
 
  Iif (!classification || !enterpriseName[classification]) return;
  const host = isProduction
    ? `${enterpriseName[classification]}.givepayments.com`
    : `${enterpriseName[classification]}.${enviroment}.givepayments.com`;
 
  return {
    host,
    URL: `https://${host}/signup?classification=${classification}`,
  };
};
 
export const generateRedirectHosts = () => {
  const { getEnvironmentDomain } = useCheckEnvironment();
  const environment = getEnvironmentDomain();
  const domain = environment
    ? `${environment}.givepayments.com`
    : "givepayments.com";
 
  return ["portal", "givepaid", "givecause"].map(
    (value) => `${value}.${domain}`,
  );
};
 
const LABEL_MAP: Record<string, string> = {
  iso: "ISO",
  psp: "PSP",
  fiscal_sponsor: "Fiscal Sponsor",
  msp: "MSP",
  payment_facilitator: "Payment Facilitator",
  reseller: "Reseller",
  other: "Other",
  profit: "Merchant",
  non_profit: "Non Profit",
  individual: "Your",
  crowdfunding: "Crowdfunder",
};
 
export const generateNameLabelPlaceholder = (
  type: string,
  fallback = "Merchant",
) => LABEL_MAP[type] ?? fallback;
 
export const personalDetailsStepIndex = initialBarsValue.findIndex(
  (value) => value.label === SignupEnum.PERSONAL_DETAILS,
);