(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[965],{89919:function(e,t,s){Promise.resolve().then(s.bind(s,19936))},19936:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return d}});var i=s(57437),n=s(2265),a=s(66369),r=s(19206),l=s(93291),c=s(34036);function d(){let[e,t]=n.useState(""),[s,d]=n.useState([]),[o,h]=n.useState(""),[u,x]=n.useState("success"),[y,j]=n.useState("");async function p(e){let t=await fetch("/api/api-keys",{method:"DELETE",body:JSON.stringify({hashedKey:e})}),s=await t.json();x("success"),h("Key successfully deleted"),d(s)}return n.useEffect(()=>{(async()=>{let e=await fetch("/api/api-keys");d(await e.json())})()},[]),(0,i.jsxs)("div",{style:{padding:"20px"},children:[(0,i.jsx)("h1",{children:"API Keys"}),(0,i.jsx)(a.Z,{open:!!o,autoHideDuration:5e3,anchorOrigin:{vertical:"top",horizontal:"center"},onClose:(e,t)=>h(""),children:(0,i.jsx)(r.Z,{onClose:()=>h(""),severity:u,variant:"filled",sx:{width:"100%"},children:o})}),(0,i.jsx)(l.Z,{label:"Description",value:e,onChange:e=>t(e.target.value)}),(0,i.jsx)(c.Z,{onClick:async()=>{let s=await fetch("/api/api-keys",{method:"POST",body:JSON.stringify({description:e}),headers:{"Content-Type":"application/json"}});if(200!==s.status){console.error("Failed to create key",s.status),x("error"),h("Failed to create key");return}x("success"),h("Key created and copied to clipboard"),t("");let i=await s.json();await navigator.clipboard.writeText(i.key),j(i.key),d(i.keys)},children:"Create"}),(0,i.jsx)("p",{}),(0,i.jsxs)("table",{children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{style:{textAlign:"left"},children:"Created"}),(0,i.jsx)("th",{style:{textAlign:"left"},children:"Description"}),(0,i.jsx)("th",{style:{textAlign:"left"},children:"Key"}),(0,i.jsx)("th",{style:{textAlign:"left"},children:"Expires"}),(0,i.jsx)("th",{})]})}),(0,i.jsx)("tbody",{children:s.map(e=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:e.created}),(0,i.jsx)("td",{children:e.description}),(0,i.jsxs)("td",{children:[e.partialKey,"..."]}),(0,i.jsx)("td",{children:e.expires}),(0,i.jsx)("td",{children:(0,i.jsx)(c.Z,{onClick:()=>p(e.hashedKey),children:"delete"})})]}))})]})]})}}},function(e){e.O(0,[50,36,543,971,117,744],function(){return e(e.s=89919)}),_N_E=e.O()}]);