(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[831],{386:(e,r,s)=>{Promise.resolve().then(s.bind(s,1240))},1240:(e,r,s)=>{"use strict";s.d(r,{default:()=>o});var a=s(5155),t=s(2615),d=s(6046);function o(e){let{admins:r}=e,s=(0,d.useRouter)();async function o(e){if(confirm("Tem certeza que deseja deletar este usu\xe1rio?"))try{if(!(await fetch("/api/admin/admins/".concat(e),{method:"DELETE"})).ok)throw Error("Erro ao deletar usu\xe1rio.");alert("Usu\xe1rio deletado com sucesso!"),s.refresh()}catch(e){console.error(e),alert("N\xe3o foi poss\xedvel deletar o usu\xe1rio.")}}return(0,a.jsxs)("div",{className:"p-8",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold",children:"Lista de Admins"}),(0,a.jsxs)("div",{className:"space-x-4",children:[(0,a.jsx)("button",{onClick:function(){s.push("/admin/admins/novo")},className:"bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700",children:"Adicionar Usu\xe1rio"}),(0,a.jsx)("button",{onClick:function(){(0,t.signOut)({callbackUrl:"/admin/login"})},className:"bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700",children:"Sair"})]})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full bg-white shadow-md rounded-lg border-collapse border border-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"text-left py-3 px-4 border-b border-gray-200 font-medium text-gray-600",children:"ID"}),(0,a.jsx)("th",{className:"text-left py-3 px-4 border-b border-gray-200 font-medium text-gray-600",children:"Username"}),(0,a.jsx)("th",{className:"text-left py-3 px-4 border-b border-gray-200 font-medium text-gray-600",children:"Email"}),(0,a.jsx)("th",{className:"text-left py-3 px-4 border-b border-gray-200 font-medium text-gray-600",children:"A\xe7\xf5es"})]})}),(0,a.jsx)("tbody",{children:r.map(e=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"py-3 px-4 border-b border-gray-200 text-gray-900",children:e.id}),(0,a.jsx)("td",{className:"py-3 px-4 border-b border-gray-200 text-gray-900",children:e.username}),(0,a.jsx)("td",{className:"py-3 px-4 border-b border-gray-200 text-gray-900",children:e.email}),(0,a.jsxs)("td",{className:"py-3 px-4 border-b border-gray-200 text-gray-900",children:[(0,a.jsx)("button",{onClick:()=>{var r;return r=e.id,void s.push("/admin/admins/".concat(r,"/edit"))},className:"bg-blue-600 text-white px-3 py-1 rounded hover:bg-blue-700 mr-2",children:"Editar"}),(0,a.jsx)("button",{onClick:()=>o(e.id),className:"bg-red-600 text-white px-3 py-1 rounded hover:bg-red-700",children:"Deletar"})]})]},e.id))})]})})]})}},6046:(e,r,s)=>{"use strict";var a=s(6658);s.o(a,"useParams")&&s.d(r,{useParams:function(){return a.useParams}}),s.o(a,"useRouter")&&s.d(r,{useRouter:function(){return a.useRouter}}),s.o(a,"useSearchParams")&&s.d(r,{useSearchParams:function(){return a.useSearchParams}})}},e=>{var r=r=>e(e.s=r);e.O(0,[615,441,517,358],()=>r(386)),_N_E=e.O()}]);