/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/ require('./lockTools.less'); const React = require('react'); const createClass = require('create-react-class'); // const request = require('superagent'); import request from '../../homebrew/utils/request-middleware.js'; const LockTools = createClass({ getInitialState : function() { return { fetching : false, reviewCount : 0 }; }, componentDidMount : function() { this.updateReviewCount(); }, updateReviewCount : async function() { const newCount = await request.get('/api/lock/count') .then((res)=>{return res.body?.count || 'Unknown';}); if(newCount != this.state.reviewCount){ this.setState({ reviewCount : newCount }); } }, render : function() { return

Lock Count

Number of brews currently locked: {this.state.reviewCount}





; } }); const LockBrew = createClass({ getInitialState : function() { // Default values return { brewId : '', code : 455, editMessage : '', shareMessage : 'This Brew has been locked.', result : {} }; }, 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 }; request.post(`/api/lock/${this.state.brewId}`) .send(newLock) .set('Content-Type', 'application/json') .then((response)=>{ this.setState({ result: response.body }); }); }, renderInput : function (name) { return this.handleChange(e, name)} autoComplete='off' required/>; }, renderResult : function(){ return <>

Result:

{Object.keys(this.state.result).map((key, idx)=>{ return ; })}
{key} {this.state.result[key].toString()}
; }, render : function() { return

Lock Brew





{this.state.result && this.renderResult()}

Suggestions

Codes

  • 455 - Generic Lock
  • 456 - Copyright issues
  • 457 - Confidential Information Leakage
  • 458 - Sensitive Personal Information
  • 459 - Defamation or Libel
  • 460 - Hate Speech or Discrimination
  • 461 - Illegal Activities
  • 462 - Malware or Phishing
  • 463 - Plagiarism
  • 465 - Misrepresentation
  • 466 - Inappropriate Content

Messages

  • Edit Message: This is the private message that is ONLY displayed to the authors of the locked brew. This message MUST specify exactly what actions must be taken in order to have the brew unlocked.
  • Share Message: This is the public message that is displayed to the EVERYONE that attempts to view the locked brew.
; } }); const LockTable = createClass({ getDefaultProps : function() { return { title : '', fetchURL : '/api/locks', resultName : '', propertyNames : ['shareId'] }; }, getInitialState : function() { return { result : '', error : '', searching : false }; }, clickFn(){ this.setState({ searching: true, error: null }); request.get(this.props.fetchURL) .then((res)=>this.setState({ result: res.body })) .catch((err)=>this.setState({ error: err })) .finally(()=>{ this.setState({ searching: false }); }); }, render : function () { return <>

{this.props.title}

{this.state.result[this.props.resultName] && <>

Total Reviews Waiting: {this.state.result[this.props.resultName].length}

{this.props.propertyNames.map((name, idx)=>{ return ; })} {this.state.result[this.props.resultName].map((result, resultIdx)=>{ return {this.props.propertyNames.map((name, nameIdx)=>{ return ; })} ; })}
{name}clip view
{result[name].toString()} {navigator.clipboard.writeText(result.shareId.toString());}}>
}
; } }); const LockLookup = createClass({ getDefaultProps : function() { return { fetchURL : '/api/lookup' }; }, getInitialState : function() { return { query : '', result : '', error : '', searching : false }; }, handleChange(e){ this.setState({ query: e.target.value }); }, clickFn(){ this.setState({ searching: true, error: null }); request.put(`${this.props.fetchURL}/${this.state.query}`) .then((res)=>this.setState({ result: res.body })) .catch((err)=>this.setState({ error: err })) .finally(()=>{ this.setState({ searching: false }); }); }, renderResult : function(){ return <>

Result:

{Object.keys(this.state.result).map((key, idx)=>{ return ; })}
{key} {this.state.result[key].toString()}
; }, render : function() { return

{this.props.title}

{this.state.error &&
{this.state.error.toString()}
} {this.state.result && this.renderResult()}
; } }); module.exports = LockTools;