PageSourceSearch

https://ofertorio-adm.vercel.app/assets/Patrocinadores-3cUBOtBJ.js

js ofertorio-adm.vercel.app collected 2026-10-03 07:26:50 UTC 5,183 bytes, 1 lines download raw bytes

1import{j as e,h as G,u as H,r as c}from"./index-Dv5_VdR4.js";import{r as L,i as O,a as q}from"./DashboardLayout-BoiYKGPL.js";import{B as u}from"./button-BNq5u0IO.js";import{T as R,a as U,b as j,c as x,d as V,e as d}from"./table-CPf_WPBi.js";import{f as $}from"./datetime-BadLwWuy.js";import{E as M}from"./Button-BBxVbTY4.js";import{u as J,a as K}from"./useSponsorMutations-DaGX04AL.js";import{u as Q}from"./useDebounce-mBvd2nnI.js";import{D as W}from"./DomainSelect-D8JGLAIk.js";import{G as X}from"./GenericPagination-9QDAeBCH.js";import{I as Y}from"./input-DyzflNfw.js";import{C as Z}from"./create-action-button-CKwfNdJS.js";import{A as _,a as ee,b as ae,c as se,d as re,e as te,f as oe,g as ie}from"./alert-dialog-BokM4nZS.js";import"./Combination-DXGo4Ofw.js";import"./house-D9xc_JPh.js";import"./index-BlG7SVE_.js";import"./useMutation-BpEjbdkF.js";import"./useSponsorById-DipxvPy0.js";import"./select-BwBh6j7s.js";import"./useDomains-C_Ob5ODY.js";import"./domainService-B0n236lv.js";import"./pagination-DN03aN_5.js";const ne=({sponsors:t,onView:n,onEdit:m,onDelete:h})=>e.jsx("div",{className:"rounded-lg border border-gray-200 overflow-hidden bg-white",children:e.jsxs(R,{children:[e.jsx(U,{children:e.jsxs(j,{className:"bg-gray-50/50",children:[e.jsx(x,{className:"font-semibold text-gray-700",children:"Nome do Patrocinador"}),e.jsx(x,{className:"font-semibold text-gray-700",children:"Data de Cadastro"}),e.jsx(x,{className:"font-semibold text-gray-700",children:"Categoria"}),e.jsx(x,{className:"font-semibold text-gray-700 text-center",children:"Ações"})]})}),e.jsx(V,{children:t.length===0?e.jsx(j,{children:e.jsx(d,{colSpan:4,className:"text-center py-8 text-gray-500",children:"Nenhum patrocinador encontrado"})}):t.map(r=>{var o;return e.jsxs(j,{className:"hover:bg-gray-50 transition-colors",children:[e.jsx(d,{className:"font-medium",children:r.name}),e.jsx(d,{children:$(r.createdAt)}),e.jsx(d,{children:((o=r.category)==null?void 0:o.name)||"-"}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>n(r.id),className:"hover:text-[#27A697]",children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>m(r.id),className:"hover:text-[#27A697]",children:e.jsx(L,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>h(r.id),className:"hover:text-red-600",children:e.jsx(O,{className:"h-4 w-4"})})]})})]},r.id)})})]})}),le=()=>{var y,C;const t=G(),{user:n}=H(),[m,h]=c.useState(""),[r,o]=c.useState(1),[f,S]=c.useState(void 0),[w,g]=c.useState(!1),[l,b]=c.useState(null),P=(n==null?void 0:n.type)==="UserInternal",N=10,A=Q(m,500),{data:a,isLoading:v,error:D}=J({page:r,limit:N,search:A,domainId:f}),T=((y=a==null?void 0:a.pagination)==null?void 0:y.totalPages)||1,E=((C=a==null?void 0:a.pagination)==null?void 0:C.total)||0,{deleteSponsor:i}=K(),I=s=>{t(`/patrocinador/view/${s}`)},k=s=>{t(`/patrocinador/editar/${s}`)},B=s=>{const p=a==null?void 0:a.data.find(F=>F.id===s);p&&(b({id:p.id,name:p.name}),g(!0))},z=()=>{!l||i.isPending||i.mutate(l.id,{onSuccess:()=>{g(!1),b(null)}})};return e.jsxs(q,{headerTitle:"Patrocinadores",headerSubtitle:"Gerencie os patrocinadores",children:[e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsx("div",{className:"flex-1 w-full sm:w-auto",children:e.jsx("div",{className:"relative",children:e.jsx(Y,{type:"text",placeholder:"Buscar patrocinador...",value:m,onChange:s=>{h(s.target.value),o(1)},className:"pl-10"})})}),P&&e.jsx("div",{className:"w-full sm:w-auto",children:e.jsx(W,{value:f,onChange:s=>{S(s),o(1)}})}),e.jsx(Z,{onClick:()=>t("/patrocinador/novo"),className:"w-full sm:w-auto",children:"Novo Patrocinador"})]}),v&&e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-[#27A697] mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-500",children:"Carregando..."})]})}),D&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:"Erro ao carregar patrocinadores"}),!v&&!D&&a&&e.jsxs(e.Fragment,{children:[e.jsx(ne,{sponsors:a.data,onView:I,onEdit:k,onDelete:B}),e.jsx("div",{className:"mt-6",children:e.jsx(X,{currentPage:r,totalPages:T,onPageChange:o,totalItems:E,itemsPerPage:N,itemLabel:"patrocinadores"})})]})]}),e.jsx(_,{open:w,onOpenChange:s=>{i.isPending||g(s)},children:e.jsxs(ee,{children:[e.jsxs(ae,{children:[e.jsx(se,{className:"text-red-600",children:"Confirmar Exclusão"}),e.jsxs(re,{children:["Tem certeza que deseja excluir o patrocinador ",e.jsxs("strong",{children:['"',l==null?void 0:l.name,'"']}),"?",e.jsx("br",{}),e.jsx("br",{}),"Esta ação é permanente e não pode ser desfeita."]})]}),e.jsxs(te,{children:[e.jsx(oe,{disabled:i.isPending,children:"Cancelar"}),e.jsx(ie,{onClick:z,disabled:i.isPending,className:"bg-red-600 hover:bg-red-700",children:i.isPending?"Excluindo...":"Sim, excluir patrocinador"})]})]})})]})},Ie=()=>e.jsx(le,{});export{Ie 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.