'use strict'; import React from 'react'; import { Link } from 'react-router'; import { getLangText } from '../../utils/lang_utils'; let PaginationButton = React.createClass({ propTypes: { direction: React.PropTypes.oneOf(['previous', 'next']), goToPage: React.PropTypes.func.isRequired, currentPage: React.PropTypes.number.isRequired, totalPages: React.PropTypes.number.isRequired }, isInRange(page) { return page > 0 && page <= this.props.totalPages; }, render() { let directionDisplay; let page = this.props.currentPage; let isDisabled = ''; let anchor; if(this.props.direction === 'previous') { page -= 1; directionDisplay = ( ); } else { page += 1; directionDisplay = ( {getLangText('Previous')} {getLangText('Next')} ); } if (this.isInRange(page)) { anchor = ( {directionDisplay} ); } else { isDisabled += ' disabled'; anchor = ( {directionDisplay} ); } return (