import React from 'react';

const FormattedDuration = ({ seconds }) => {
  // const fullDays = Math.floor(seconds / 86400);
  const fullHours = Math.floor(seconds / 3600);
  // const hoursLeft = Math.floor(fullHours % 24);
  const fullMinutes = Math.floor(seconds / 60);
  let minutesLeft = Math.floor(fullMinutes % 60);
  let secondsLeft = seconds % 60;

  if (secondsLeft < 10) {
    secondsLeft = '0' + secondsLeft.toFixed(0);
  } else {
    secondsLeft = secondsLeft.toFixed(0);
  }

  if (minutesLeft < 10) {
    minutesLeft = '0' + minutesLeft.toFixed(0);
  } else {
    minutesLeft = minutesLeft.toFixed(0);
  }

  let duration = `${minutesLeft}:${secondsLeft}`;
  if (seconds >= 3600) {
    duration = `${fullHours}:${duration}`;
  }

  return <span> {duration} </span>;
};

export default FormattedDuration;
