
export const buildClasses = (classes, defaultClass) => {
  let classList = defaultClass || '';

  classes?.forEach(item => {
    const { condition, name } = item;
    if (condition) classList += ` ${name}`;
  });

  return classList;
};

export const truncate = (num, limit) => {
  num = num === 0 || !num ? '0.00000000' : num.toString();
  const hasFloatVal = num?.includes('.');

  if (hasFloatVal) {
    const split = num.split('.');
    const int = (+(split[0])).toLocaleString('en-US');
    const float = split[1].slice(0, limit ?? 2);
    const truncatedVal = `${int}${limit === 0 ? '' : '.'}${float}`;

    return truncatedVal;
  }

  return (+(num)).toLocaleString('en-US');
};