(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[825],{2023:(e,r,a)=>{Promise.resolve().then(a.bind(a,1721))},1721:(e,r,a)=>{"use strict";a.d(r,{default:()=>n});var o=a(5155),t=a(2115),s=a(1899),l=a(7949),d=a(7568),i=a(6046);function n(e){let{empregos:r}=e,[a,n]=(0,t.useState)(""),[c,m]=(0,t.useState)(r),[u,h]=(0,t.useState)(!1),p=(0,i.useRouter)();(0,t.useEffect)(()=>{h(!0)},[]),(0,t.useEffect)(()=>{let e=a.toLowerCase();m(r.filter(r=>Object.values(r).some(r=>r.toString().toLowerCase().includes(e))))},[a,r]);let g=async e=>{if(confirm("Tem certeza que deseja deletar este emprego?"))try{if(!(await fetch("/api/admin/empregos/".concat(e),{method:"DELETE"})).ok)throw Error("Erro ao deletar o emprego.");alert("Emprego deletado com sucesso!"),p.refresh()}catch(e){console.error(e),alert("Erro ao deletar emprego.")}},b=e=>{p.push("/admin/empregos/".concat(e,"/edit"))},x=[{name:"ID",selector:e=>e.id,sortable:!0,width:"80px"},{name:"T\xedtulo",selector:e=>e.titulo,sortable:!0},{name:"Tipo de Vaga",selector:e=>e.tipoVaga,sortable:!0},{name:"Localiza\xe7\xe3o",selector:e=>e.localizacao,sortable:!0},{name:"Ramo",selector:e=>e.ramo,sortable:!0},{name:"Criado em",selector:e=>(0,l.GP)(new Date(e.createdAt),"dd/MM/yyyy",{locale:d.F}),sortable:!0},{name:"A\xe7\xf5es",cell:e=>(0,o.jsxs)("div",{className:"flex space-x-2",children:[(0,o.jsx)("button",{onClick:()=>b(e.id),className:"px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Editar"}),(0,o.jsx)("button",{onClick:()=>g(e.id),className:"px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600",children:"Deletar"})]}),ignoreRowClick:!0}];return u?(0,o.jsxs)("div",{className:"p-8",children:[(0,o.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,o.jsx)("h1",{className:"text-2xl font-bold",children:"Lista de Empregos"}),(0,o.jsx)("button",{onClick:()=>{p.push("/admin/empregos/novo")},className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Criar Novo Emprego"})]}),(0,o.jsx)("div",{className:"mb-4",children:(0,o.jsx)("input",{type:"text",value:a,onChange:e=>n(e.target.value),placeholder:"Pesquisar...",className:"w-full px-3 py-2 border border-gray-300 rounded shadow-sm focus:ring focus:ring-blue-200"})}),(0,o.jsx)(s.Ay,{columns:x,data:c,pagination:!0,highlightOnHover:!0,striped:!0,responsive:!0,defaultSortFieldId:1,className:"shadow-lg rounded-lg border border-gray-200"})]}):(0,o.jsx)("div",{children:"Carregando..."})}}},e=>{var r=r=>e(e.s=r);e.O(0,[91,441,517,358],()=>r(2023)),_N_E=e.O()}]);