import React from 'react';
import './SeasonDetail.scss';
import {IUserListProperties} from "../UserList/UserList";

const SeasonDetail: React.FC<IUserListProperties> = (props: IUserListProperties) => {
  const { seasonId, dates } = props.userStats

  return (
    <span className="SeasonDetail" data-testid="SeasonDetail">
      Season {seasonId} - Duration: {dateToString(dates.start)} - {dateToString(dates.end)}
    </span>
  )
}

const dateToString = (date?: Date): string => {
  return date ? date.toLocaleDateString('en-GB') : 'TBD';
}

export interface SeasonDetailProperties {
  seasonId?: string,
  maxSeasonId: string
  dates: {
    start?: Date,
    end?: Date
  }
}

export default SeasonDetail;
