PageSourceSearch

https://greyjcr.co.uk/assets/ManageDebtPage-3ca94669.js

js greyjcr.co.uk collected 2026-10-08 08:15:34 UTC 7,417 bytes, 1 lines download raw bytes

1var x=Object.defineProperty;var f=(d,i,t)=>i in d?x(d,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[i]=t;var o=(d,i,t)=>(f(d,typeof i!="symbol"?i+"":i,t),t);import{R as h,a as u,j as e,P as m,b as g,d as j}from"./index-af0b897b.js";import{d as y}from"./dateformat-9257cb92.js";class b extends h.Component{constructor(t){super(t);o(this,"deleteSelf",async()=>{this.setState({disabled:!0});const{debtId:t}=this.state.debt;try{await u.delete(`/debt/${t}`)}catch{alert("An error occurred deleting this record");return}this.props.onDelete(this.state.debt)});o(this,"makeDisplayName",t=>{if(!t.firstNames)return"Not Signed Up";let s=t.firstNames.split(",")[0];s=s.substring(0,1).toUpperCase()+s.substring(1).toLowerCase();let n=t.surname;return n=n.substring(0,1).toUpperCase()+n.substring(1).toLowerCase(),`${s} ${n}`});this.state={debt:this.props.debt,disabled:!1}}render(){const{debt:t,disabled:r}=this.state;return e.jsxs("tr",{className:"text-center border-b border-gray-400",children:[e.jsx("td",{className:"p-2 border-r border-gray-400",children:this.makeDisplayName(t)}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:t.username}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:t.email||"Not Signed Up"}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:t.lastLogin?y(t.lastLogin,"dd/mm/yyyy HH:MM"):"Not Signed Up"}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:t.description}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:Number(t.amount).toFixed(2)}),e.jsx("td",{className:"p-2 border-r border-gray-400",children:e.jsx("button",{onClick:this.deleteSelf,disabled:r,className:"px-4 py-1 rounded bg-red-700 text-white w-32 font-semibold focus:outline-none focus:ring-2 focus:ring-gray-400 disabled:opacity-50",children:"Remove"})})]})}}b.propTypes={debt:m.object.isRequired,onDelete:m.func.isRequired};class C extends h.Component{constructor(t){super(t);o(this,"componentDidMount",async()=>{let t;try{t=await u.get("/auth/verify")}catch(a){this.setState({status:a.response.status,error:"Unable to verify admin status"});return}if(t.data.user.permissions){if(t.data.user.permissions.length===0){this.setState({status:403,error:"You are not an admin"});return}if(!t.data.user.permissions.includes(this.requiredPermission)){this.setState({status:403,error:"You are not an admin"});return}}else{this.setState({status:403,error:"You are not an admin"});return}let r;try{r=await u.get("/debt/all")}catch(a){this.setState({loaded:!0,status:a.response.status,error:a.response.data.error});return}const{debts:s}=r.data,n=s.map(a=>Number(a.amount)).reduce((a,l)=>a+l,0);this.setState({loaded:!0,debts:s,total:n})});o(this,"onInputChange",t=>{this.setState({[t.target.name]:t.target.type==="checkbox"?t.target.checked:t.target.value})});o(this,"canCreateDebt",()=>{const{username:t,amount:r,description:s}=this.state;return t!=null&&t.length===6&&r!=null&&r.length!==0&&Number(r)>0&&s!=null&&s.length!==0&&s.length<1e4});o(this,"createDebt",async()=>{this.setState({addDisabled:!0});const{username:t,amount:r,description:s}=this.state;if(!this.canCreateDebt()){alert("Please check the data entered");return}let n;try{n=await u.post("/debt",{username:t,amount:r,description:s})}catch(c){alert(c.response.data.error),this.setState({addDisabled:!1});return}let{debts:a}=this.state;a.push(n.data.debt);const l=a.map(c=>Number(c.amount)).reduce((c,p)=>c+p,0);this.setState({addDisabled:!1,username:"",amount:0,description:"",debts:a,total:l})});o(this,"onRowDelete",t=>{const{debtId:r}=t;let{debts:s}=this.state;s=s.filter(a=>a.debtId!==r);const n=s.map(a=>Number(a.amount)).reduce((a,l)=>a+l,0);this.setState({debts:s,total:n})});this.state={loaded:!1,status:0,error:"",debts:null,username:"",amount:0,description:"",addDisabled:!1,total:0},this.requiredPermission="debt.manage"}render(){return this.state.loaded?e.jsx("div",{className:"flex flex-col justify-start",children:e.jsxs("div",{className:"container mx-auto text-center p-4",children:[e.jsx("h1",{className:"font-semibold text-5xl pb-4",children:"Manage Debt"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-left font-semibold text-2xl",children:"Add Debt"}),e.jsxs("div",{className:"pt-2 pb-2 border-b-2",children:[e.jsx("label",{htmlFor:"username",className:"flex flex-row justify-start text-xl font-semibold",children:"Username:"}),e.jsx("span",{className:"flex flex-row justify-start text-sm mb-2",children:"(Must be 6 characters)"}),e.jsx("input",{type:"text",className:"w-full border rounded py-1 px-2 focus:outline-none focus:ring-2 disabled:opacity-50 focus:ring-gray-400",value:this.state.username,name:"username",onChange:this.onInputChange,maxLength:6,autoComplete:"",disabled:this.state.addDisabled})]}),e.jsxs("div",{className:"pt-2 pb-2 border-b-2",children:[e.jsx("label",{htmlFor:"amount",className:"flex flex-row justify-start text-xl font-semibold",children:"Amount:"}),e.jsx("span",{className:"flex flex-row justify-start text-sm mb-2",children:"(Must be a positive number)"}),e.jsx("input",{type:"number",className:"w-full border rounded py-1 px-2 focus:outline-none focus:ring-2 disabled:opacity-50 focus:ring-gray-400",value:this.state.amount,name:"amount",onChange:this.onInputChange,min:0,step:.
101,autoComplete:"",disabled:this.state.addDisabled})]}),e.jsxs("div",{className:"pt-2 pb-2 border-b-2",children:[e.jsx("label",{htmlFor:"description",className:"flex flex-row justify-start text-xl font-semibold",children:"Description:"}),e.jsxs("span",{className:"flex flex-row justify-start text-sm mb-2",children:["(",1e4-this.state.description.length," characters remaining)"]}),e.jsx("textarea",{className:"border w-full rounded my-2 h-16 py-1 px-2 focus:outline-none focus:ring-2 disabled:opacity-50 focus:ring-gray-400",value:this.state.description,name:"description",onChange:this.onInputChange,autoComplete:"",disabled:this.state.addDisabled,maxLength:1e4})]}),e.jsx("div",{className:"pt-2 pb-2 border-b-2 flex flex-row justify-start",children:e.jsx("button",{className:"px-4 py-1 rounded bg-green-900 text-white w-auto font-semibold focus:outline-none focus:ring-2 focus:ring-gray-400 disabled:opacity-50",disabled:this.state.addDisabled||!this.canCreateDebt(),onClick:this.createDebt,children:"Create Debt"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-left font-semibold text-2xl",children:"Existing Debt"}),e.jsxs("p",{className:"py-1 font-semibold text-lg text-left",children:["Total outstanding: £",this.state.total.toFixed(2)]}),e.jsxs("table",{className:"mx-auto border-2 text-left border-red-900 w-full",children:[e.jsx("thead",{className:"bg-red-900 text-white",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-2 font-semibold",children:"Name"}),e.jsx("th",{className:"p-2 font-semibold",children:"Username"}),e.jsx("th",{className:"p-2 font-semibold",children:"Email"}),e.jsx("th",{className:"p-2 font-semibold",children:"Last Login"}),e.jsx("th",{className:"p-2 font-semibold",children:"Description"}),e.jsx("th",{className:"p-2 font-semibold",children:"Amount (£)"}),e.jsx("th",{className:"p-2 font-semibold",children:"Remove"})]})}),e.jsx("tbody",{children:this.state.debts.map((t,r)=>e.jsx(b,{debt:t,onDelete:s=>this.onRowDelete(s)},`${Math.random()}`))})]})]})]})}):this.state.status!==200&&this.state.status!==0?e.jsx(g,{to:`/errors/${this.state.status}`}):e.jsx(j,{})}}export{C as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.