(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3779],{830:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/[user_id]/su/envar",function(){return n(7597)}])},7597:(e,t,n)=>{"use strict";let s;n.r(t),n.d(t,{__N_SSP:()=>c,default:()=>p});var a=n(4848),r=n(6540),i=n(1710),l=n(9020);function o(e){let{envObject:t,envKey:n}=e,[o,d]=r.useState(!1),[u,c]=r.useState(!1),[p,m]=r.useState(t[n]),[h,x]=r.useState(!1);return(0,a.jsx)(r.Fragment,{children:(0,a.jsxs)("form",{className:"grid grid-cols-2 items-center gap2 w-full hover:bg-slate-100 py-2 px-4 relative",onSubmit:e=>{e.preventDefault(),o&&(c(!0),setTimeout(()=>{c(!1)},1e3))},children:[u&&(0,a.jsx)(i.A,{width:"20px"}),(0,a.jsx)("span",{children:n}),(0,a.jsxs)("div",{children:[(0,a.jsx)("input",{type:o?"text":"password",onFocus:e=>{"password"==e.target.type&&(e.target.type="text"),x(!0),d(!0)},onBlur:e=>{window.clearTimeout(s),s=setTimeout(()=>{"text"==e.target.type&&(e.target.type="password"),x(!1),d(!1)},2e3)},value:p,onChange:e=>{m(e.target.value)}}),h?(0,a.jsx)("div",{className:"button secondary",onClick:e=>{e.preventDefault(),o&&(c(!0),(0,l.A)("/api/admin/updateEnv",{method:"post",body:{key:n,value:p}}).then(e=>{e.success?window.location.reload():window.alert(e.error)}).finally(()=>{setTimeout(()=>{c(!1)},1e3)}))},children:"Update"}):(0,a.jsx)("div",{className:"button outlined",onClick:e=>{d(!o),x(!0)},children:"Reveal"})]})]})})}function d(e){let{data:t}=e,{envObject:n}=t,[s,i]=r.useState(n),l=Object.keys(s);return(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsx)("h2",{className:"text-2xl m-0",children:"Environment Variables"}),(0,a.jsx)("button",{onClick:e=>{let t=window.prompt("What is the new ENV name?"),n=window.prompt("ENV Value");t&&n&&i(e=>{let s={...e};return s[t]=n,s})},children:"Add Environment Variable"})]}),(0,a.jsx)("section",{className:"paper",children:l.map((e,t)=>(0,a.jsx)(o,{envObject:s,envKey:e},t))})]})}var u=n(4725),c=!0;function p(e){let{user:t,data:n}=e,s=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"Console | Datasquirel"}),(0,a.jsx)("meta",{name:"description",content:"Databases Console"})]});return(0,a.jsx)(u.A,{head:s,children:(0,a.jsx)(d,{data:n})})}}},e=>{var t=t=>e(e.s=t);e.O(0,[1335,3348,4725,636,6593,8792],()=>t(830)),_N_E=e.O()}]);