All files / src/components/common/BusinessProfileInputs GiveBusinessTypeSelect.tsx

100% Statements 7/7
50% Branches 2/4
100% Functions 3/3
100% Lines 7/7

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                      48x         371x 371x 427x     371x                     280x                   48x                            
import { useAppSelector } from "@redux/hooks";
import { useGetLegalEntitiesTypes } from "@services/api/merchants";
import HFGiveSelect from "@shared/HFInputs/HFGiveSelect/HFGiveSelect";
 
type GiveBusinessTypeSelectProps = {
  name: string;
  label: string;
  disabled?: boolean;
  hasArrowDownIcon?: boolean;
};
 
const GiveBusinessTypeSelect = ({
  name,
  label,
  disabled,
}: GiveBusinessTypeSelectProps) => {
  const { data, isFetching, isError } = useGetLegalEntitiesTypes();
  const hasNotLETypesPermission = useAppSelector(
    (state) => state.app.permissions?.get_legal_entities_types,
  );
 
  return (
    <HFGiveSelect
      isFetchindData={isFetching}
      isError={isError}
      errorsMessage={
        hasNotLETypesPermission ? "Legal Entities types hidden" : undefined
      }
      name={name}
      label={label}
      disabled={disabled}
      options={
        data?.data?.map((item) => ({
          value: item.name,
          label: businessTypes[item.name as BusinessUnionTypes] as string,
        })) || []
      }
      data-testid="business-type"
    />
  );
};
 
export const businessTypes = {
  general_partnership: "General Partnership",
  individual_sole_proprietorship: "Sole Proprietor",
  corporation: "Corporation",
  limited_liability_company: "LLC",
  limited_partnership: "Limited Partnership",
  partnership: "Partnership",
  tax_exempt_organization: "Tax Exempt Organization",
  government_agency: "Government Agency",
};
 
export type BusinessUnionTypes = keyof typeof businessTypes;
 
export default GiveBusinessTypeSelect;