mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 03:52:40 +00:00
Reduce code duplication in sorting radio options
This commit is contained in:
@@ -83,6 +83,22 @@ const UserPage = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderSortRadioOption : function(sortTitle, sortValue){
|
||||||
|
return <td>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type='radio'
|
||||||
|
name='sortType'
|
||||||
|
value={`${sortValue}`}
|
||||||
|
checked={this.state.sortType == `${sortValue}`}
|
||||||
|
className='sort-radio'
|
||||||
|
onChange={this.handleSortOptionChange}
|
||||||
|
/>
|
||||||
|
{`${sortTitle}`}
|
||||||
|
</label>
|
||||||
|
</td>;
|
||||||
|
},
|
||||||
|
|
||||||
renderSortOptions : function(){
|
renderSortOptions : function(){
|
||||||
return <div className='sort-container'>
|
return <div className='sort-container'>
|
||||||
<table>
|
<table>
|
||||||
@@ -90,72 +106,12 @@ const UserPage = createClass({
|
|||||||
<td>
|
<td>
|
||||||
<h6>Sort Type :</h6>
|
<h6>Sort Type :</h6>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
{this.renderSortRadioOption('Title', 'alpha')}
|
||||||
<label>
|
{this.renderSortRadioOption('Created Date', 'created')}
|
||||||
<input
|
{this.renderSortRadioOption('Updated Date', 'updated')}
|
||||||
type='radio'
|
{this.renderSortRadioOption('Views', 'views')}
|
||||||
name='sortType'
|
{/* {this.renderSortRadioOption('Latest', 'latest')} */}
|
||||||
value='alpha'
|
<td>
|
||||||
checked={this.state.sortType == 'alpha'}
|
|
||||||
className='sort-radio'
|
|
||||||
onChange={this.handleSortOptionChange}
|
|
||||||
/>
|
|
||||||
Title
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type='radio'
|
|
||||||
name='sortType'
|
|
||||||
value='created'
|
|
||||||
checked={this.state.sortType == 'created'}
|
|
||||||
className='sort-radio'
|
|
||||||
onChange={this.handleSortOptionChange}
|
|
||||||
/>
|
|
||||||
Created Date
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type='radio'
|
|
||||||
name='sortType'
|
|
||||||
value='updated'
|
|
||||||
checked={this.state.sortType == 'updated'}
|
|
||||||
className='sort-radio'
|
|
||||||
onChange={this.handleSortOptionChange}
|
|
||||||
/>
|
|
||||||
Updated Date
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type='radio'
|
|
||||||
name='sortType'
|
|
||||||
value='views'
|
|
||||||
checked={this.state.sortType == 'views'}
|
|
||||||
className='sort-radio'
|
|
||||||
onChange={this.handleSortOptionChange}
|
|
||||||
/>
|
|
||||||
Views
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type='radio'
|
|
||||||
name='sortType'
|
|
||||||
value='latest'
|
|
||||||
checked={this.state.sortType == 'latest'}
|
|
||||||
className='sort-radio'
|
|
||||||
onChange={this.handleSortOptionChange}
|
|
||||||
/>
|
|
||||||
Latest
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<h6>Direction :</h6>
|
<h6>Direction :</h6>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user