function formatNumber(value?: number | null) {
  const number = typeof value === 'number' && !isNaN(value) ? value : 0;

  if (number >= 1000 && number < 10000) {
    return (number / 1000).toFixed(1) + 'k';
  } else if (number >= 10000) {
    return (number / 1000).toFixed(0) + 'k';
  }

  return number.toString();
}

export default formatNumber;
