All files / src/sections/PayBuilder helpers.ts

93.33% Statements 14/15
85.71% Branches 6/7
100% Functions 3/3
92.85% Lines 13/14

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      180x 285x 13x 13x 12x   1x       180x 72x       53x   19x       180x 901x 901x    
// PayBuilder helper functions to break circular dependencies
import { FormType } from "./constants";
 
export const isUrl = (string: string | null) => {
  if (!string) return false;
  try {
    new URL(string);
    return true;
  } catch (_) {
    return false;
  }
};
 
export const getItemName = (type?: string) => {
  switch (type) {
    case FormType.MEMBERSHIPS:
      return "Membership";
    case FormType.EVENTS:
      return "Ticket";
    default:
      return "Item";
  }
};
 
export const parseNumber = (value?: string) => {
  const processedValue = value?.trim()?.replace(/,/g, "");
  return isNaN(Number(processedValue)) ? 0 : Number(processedValue);
};