export const handleScrollTo = (e: React.MouseEvent<HTMLAnchorElement>) => {
  e.preventDefault();
  const link: HTMLAnchorElement = e.currentTarget;
  if (link.hash && link.hash != "") {
    document
      .getElementById(link.hash.substring(1, undefined))
      ?.scrollIntoView({ behavior: "smooth", block: "start" });
  }
};

export function capitalization(str: string): string {
  return str.substring(0, 1).toUpperCase() + str.substring(1);
}

export function formatNumber(num: number): string {
  return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ');
}

export function joinClassnames(first?: string, second?: string): string {
  return [
    first ?? '',
    second ?? '',
  ].join('');
}