mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 16:32:40 +00:00
Add functional Lock Brew component
This commit is contained in:
@@ -34,8 +34,7 @@ const LockTools = createClass({
|
|||||||
<hr />
|
<hr />
|
||||||
<LockTable title='Brews Awaiting Review' resultName='reviewDocuments' fetchURL='/admin/lock/reviews' propertyNames={['shareId', 'title']} ></LockTable>
|
<LockTable title='Brews Awaiting Review' resultName='reviewDocuments' fetchURL='/admin/lock/reviews' propertyNames={['shareId', 'title']} ></LockTable>
|
||||||
<hr />
|
<hr />
|
||||||
<h2>Lock Brew</h2>
|
<LockBrew></LockBrew>
|
||||||
<LockLookup>NYI</LockLookup>
|
|
||||||
<hr />
|
<hr />
|
||||||
<LockLookup title='Unlock Brew' fetchURL='/admin/unlock' updateFn={this.updateReviewCount}></LockLookup>
|
<LockLookup title='Unlock Brew' fetchURL='/admin/unlock' updateFn={this.updateReviewCount}></LockLookup>
|
||||||
<hr />
|
<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({
|
const LockTable = createClass({
|
||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
return {
|
return {
|
||||||
@@ -140,6 +210,7 @@ const LockLookup = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderResult : function(){
|
renderResult : function(){
|
||||||
|
console.log(this.state.result);
|
||||||
return <>
|
return <>
|
||||||
<h3>Result:</h3>
|
<h3>Result:</h3>
|
||||||
<table>
|
<table>
|
||||||
|
|||||||
Reference in New Issue
Block a user