From 63f4104f816be59e0335b84d002086b7897c2eda Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 13 Oct 2024 13:45:24 +1300 Subject: [PATCH] Add UI to Admin page --- .../admin/brewUtils/brewLookup/brewLookup.jsx | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) 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
@@ -52,6 +70,8 @@ const BrewLookup = createClass({
Num of Views
{brew.views}
+ + {this.state.checkForScript && }
; },