diff --git a/client/admin/brewUtils/brewLookup/brewLookup.jsx b/client/admin/brewUtils/brewLookup/brewLookup.jsx index 50a2f2015..180e46b72 100644 --- a/client/admin/brewUtils/brewLookup/brewLookup.jsx +++ b/client/admin/brewUtils/brewLookup/brewLookup.jsx @@ -12,17 +12,18 @@ const BrewLookup = createClass({ }, getInitialState() { return { - query : '', - foundBrew : null, - searching : false, - error : null + query : '', + foundBrew : null, + searching : false, + error : null, + checkForScript : false }; }, handleChange(e){ this.setState({ query: e.target.value }); }, lookup(){ - this.setState({ searching: true, error: null }); + this.setState({ searching: true, error: null, checkForScript: false }); request.get(`/admin/lookup/${this.state.query}`) .then((res)=>this.setState({ foundBrew: res.body })) @@ -30,6 +31,23 @@ const BrewLookup = createClass({ .finally(()=>this.setState({ searching: false })); }, + checkForScript(){ + const brew = this.state.foundBrew; + const scriptCheck = brew.text.match(/(<\/?s)cript/); + this.setState({ + checkForScript : !!scriptCheck + }); + }, + + cleanScript(){ + if(!this.state.foundBrew?.shareId) return; + + request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`) + .then((res)=>this.setState({ foundBrew: res.body })) + .catch((err)=>this.setState({ error: err })) + .finally(()=>this.setState({ checkForScript: false })); + }, + renderFoundBrew(){ const brew = this.state.foundBrew; return