import React from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import Styles from './index.css' import { PREV_DAY, NEXT_DAY, } from '../../const' import { DateContext } from '../../context' import { withContext } from '../../utils' class Index extends React.Component { selectDay = (day, event) => { if (day.disabled) { return } const { context: { onSelectDay } } = this.props onSelectDay(day, event) } render() { const { context: { weekTags, days } } = this.props return (
{ weekTags.map(weekName => ( { weekName } )) } { days.map(day => ( this.selectDay(day, e)} role="presentation" > { day.day } )) }
) } } Index.propTypes = { context: PropTypes.shape({ weekTags: PropTypes.array.isRequired, days: PropTypes.array.isRequired, onSelectDay: PropTypes.func.isRequired, }).isRequired, } export default withContext(DateContext, Index)