All files / src/hooks/common useCountryCodes.tsx

100% Statements 6/6
100% Branches 1/1
100% Functions 4/4
100% Lines 6/6

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      116x 1271x 1271x 307582x 307152x           1271x        
import React from "react";
import { country_dial_codes } from "@utils/country_dial_codes";
 
const useCountryCodes = (excludeCountries = [""]) => {
  const selectCountriesList = React.useMemo(() => {
    return country_dial_codes
      .filter((country) => !excludeCountries.includes(country.code))
      .map((country) => ({
        label: country.name,
        value: country.code,
      }));
  }, [excludeCountries]);
 
  return { selectCountriesList };
};
 
export default useCountryCodes;