import { ITraining } from "../types";
import { calculateRating } from "../utils";

const TrainingMeta = ({ training }: { training: ITraining }) => {
  return (
    <aside>
      <div className="info">
        <span className="caption">Type: </span>
        <span className="data">{training.type.name}</span>
      </div>
      <div className="info">
        <span className="caption">Date: </span>
        <span className="data">
          {new Date(training.trainingDate).toLocaleString()}
        </span>
      </div>
      <div className="info">
        <span className="caption">Location: </span>
        <span className="data">{training.location}</span>
      </div>
      {/*<div className="info">
        <span className="caption">Registrations: </span>
        <span className="data">{training.registrations.length} </span>
      </div>
      <div className="info">
        <span className="caption">Attendance: </span>
        <span className="data">{training.attendance}</span>
      </div>
      <div className="info">
        <span className="caption">Rating: </span>
        <span className="data">
          {calculateRating(training.ratings)} [
          <a href="">{training.ratings.length}</a>] Rate it!
          <a href="">*</a>
          <a href="">*</a>
          <a href="">*</a>
          <a href="">*</a>
          <a href="">*</a>
        </span>
      </div>
          <button>Register now!</button>*/}

      <style jsx>{`
        aside {
          grid-area: information;
          background: rgba(200, 200, 200, 0.8);
          min-height: 370px;
          padding: 0.2em 1em;
          margin: 0;
        }
        .info .caption {
          font-weight: 900;
          display: inline-block;
          min-width: 7em;
        }
      `}</style>
    </aside>
  );
};

export default TrainingMeta;
