All files / src/features/Merchants/MerchantSidePanel/components/NameInput NameInput.tsx

100% Statements 5/5
50% Branches 1/2
100% Functions 3/3
100% Lines 5/5

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 55 56 57 58 59                                      7x                     27x                       8x                 7x         8x    
import React, { memo } from "react";
import { HFGiveInput } from "@shared/HFInputs/HFGiveInput/HFGiveInput";
import { normalizeNameInput } from "@validation/utils";
 
type NameInputProps = {
  id?: string;
  name: string;
  label?: string;
  placeholder?: string;
  disabled?: boolean;
  isLegalName?: boolean;
  isMerchantName?: boolean;
  autoComplete?: boolean;
  maxLength?: string;
  focusViewColor?: string;
  value?: string;
  helper?: string;
};
 
const NameInput = ({
  name,
  label,
  placeholder,
  disabled,
  isLegalName,
  isMerchantName,
  autoComplete,
  maxLength,
  ...rest
}: NameInputProps) => {
  return (
    <HFGiveInput
      name={name}
      label={label}
      disabled={disabled}
      fullWidth
      placeholder={placeholder}
      autoComplete={autoComplete ? "" : "null"}
      inputProps={{
        maxLength,
      }}
      handleNormalizeInput={(e) =>
        normalizeInput(e, isLegalName, isMerchantName)
      }
      {...rest}
    />
  );
};
 
export default memo(NameInput);
 
const normalizeInput = (
  value: string,
  isLegalName?: boolean,
  isMerchantName?: boolean,
) => {
  return normalizeNameInput(value, { isLegalName, isMerchantName });
};