interface ITrial {
  is_paid: boolean;
  is_free: boolean;
  days: number;
  price_cents: number;
}

export const roundToWhole = (value: string | number): number => {
  value = Number(value);
  if (value % Math.floor(value) !== 0) {
    return value;
  }
  return Math.floor(value);
};

export const removeAfterDot = (value: string): string => {
  const _value = Number(value.split("$")[1]);
  if (_value % Math.floor(_value) !== 0 && _value !== 0) {
    return value;
  }
  return value.split(".")[0];
};

export const getPriceFromTrial = (trial: ITrial | null) => {
  if (!trial) {
    return 0;
  }
  return (trial.price_cents === 100 ? 99 : trial.price_cents || 0) / 100;
};

export const getPriceCentsToDollars = (cents: number) => {
  return (cents / 100).toFixed(2);
};
