mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-27 07:12:39 +00:00
Add functional Lock Brew component
This commit is contained in:
@@ -34,8 +34,7 @@ const LockTools = createClass({
|
||||
<hr />
|
||||
<LockTable title='Brews Awaiting Review' resultName='reviewDocuments' fetchURL='/admin/lock/reviews' propertyNames={['shareId', 'title']} ></LockTable>
|
||||
<hr />
|
||||
<h2>Lock Brew</h2>
|
||||
<LockLookup>NYI</LockLookup>
|
||||
<LockBrew></LockBrew>
|
||||
<hr />
|
||||
<LockLookup title='Unlock Brew' fetchURL='/admin/unlock' updateFn={this.updateReviewCount}></LockLookup>
|
||||
<hr />
|
||||
@@ -44,6 +43,77 @@ const LockTools = createClass({
|
||||
}
|
||||
});
|
||||
|
||||
const LockBrew = createClass({
|
||||
getInitialState : function() {
|
||||
return {
|
||||
brewId : '',
|
||||
code : 1000,
|
||||
editMessage : '',
|
||||
shareMessage : ''
|
||||
};
|
||||
},
|
||||
|
||||
handleChange : function(e, varName) {
|
||||
const output = {};
|
||||
output[varName] = e.target.value;
|
||||
this.setState(output);
|
||||
},
|
||||
|
||||
submit : function(e){
|
||||
e.preventDefault();
|
||||
if(!this.state.editMessage) return;
|
||||
const newLock = {
|
||||
code : parseInt(this.state.code) || 100,
|
||||
editMessage : this.state.editMessage,
|
||||
shareMessage : this.state.shareMessage,
|
||||
applied : new Date,
|
||||
locked : true
|
||||
};
|
||||
|
||||
request.post(`/admin/lock/${this.state.brewId}`)
|
||||
.send(newLock)
|
||||
.set('Content-Type', 'application/json')
|
||||
.then((response)=>{
|
||||
console.log(response.body);
|
||||
});
|
||||
},
|
||||
|
||||
renderInput : function (name) {
|
||||
return <input type='text' name={name} value={this.state[name]} onChange={(e)=>this.handleChange(e, name)} autoComplete='off' required/>;
|
||||
},
|
||||
|
||||
render : function() {
|
||||
return <div className='lockBrew'>
|
||||
<h2>Lock Brew</h2>
|
||||
<form onSubmit={this.submit}>
|
||||
<label>
|
||||
ID:
|
||||
{this.renderInput('brewId')}
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
Error Code:
|
||||
{this.renderInput('code')}
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
Edit Message:
|
||||
{this.renderInput('editMessage')}
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
Share Message:
|
||||
{this.renderInput('shareMessage')}
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
<input type='submit' />
|
||||
</label>
|
||||
</form>
|
||||
</div>;
|
||||
}
|
||||
});
|
||||
|
||||
const LockTable = createClass({
|
||||
getDefaultProps : function() {
|
||||
return {
|
||||
@@ -140,6 +210,7 @@ const LockLookup = createClass({
|
||||
},
|
||||
|
||||
renderResult : function(){
|
||||
console.log(this.state.result);
|
||||
return <>
|
||||
<h3>Result:</h3>
|
||||
<table>
|
||||
|
||||
Reference in New Issue
Block a user