1import{e,B as n,F as j,ac as T}from"./ui-vendor-CaFOqX7E.js";import{r as d,u as w}from"./react-vendor-Diu8YNKx.js";import{a5 as h,al as B,am as F,g as S,C as v,an as z,ao as R,o as _,aa as M,e as O,ap as $,Y as G,ac as U,q as Y}from"./index-MMViGgmL.js";import{S as V}from"./simple-page-size-select.component-vyC9Cb1N.js";import{e as f,u as H}from"./redux-vendor-kFPYml90.js";import{S as W}from"./trash-icon-Cl48LPg6.js";import"./firebase-vendor-DpNCE-dN.js";import"./form-vendor-D7Pc5Nza.js";import"./chart-vendor-DSC_euA_.js";const p={textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},q=u=>{const r=w(),c=f(),o=d.useCallback(a=>{c({type:"SET_LIVE_FUNDRAISE_LOADING",payload:{loading:!0,success:!1,error:null}}),r(`/live-fundraise/create-new-live/${a}`)},[r]),l=(a,s)=>a.pageLink||`${window.location.origin}/live-fundraise/${a.id}`;return d.useMemo(()=>[{id:"name",title:"Fundraise Live name",key:"name",sortable:!0,headerClass:"header-cell flex-container",className:"normal-height normal-padding no-wrap flex-container",render:a=>e.jsx(n,{sx:{width:"160px",...p,cursor:"pointer",textDecoration:"underline"},onClick:()=>o(a.id),children:a.name})},{id:"targetAmount",title:"Target amount",key:"targetAmount",sortable:!0,headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>e.jsxs(n,{sx:{width:"110px",...p},children:["$",(a.targetAmount||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})},{id:"linkedCampaign",title:"Linked campaign",key:"linkedCampaign",headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>{var s;return e.jsx(n,{sx:{width:"160px",...p},children:a.linkedCampaignName||((s=a.linkedCampaign)==null?void 0:s.label)||"-"})}},{id:"linkedPledgeGroup",title:"Linked pledge group",key:"linkedPledgeGroup",headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>{var s;return e.jsx(n,{sx:{width:"160px",...p},children:a.linkedPledgeGroupName||((s=a.linkedPledgeGroup)==null?void 0:s.label)||"-"})}},{id:"updatedAt",title:"Updated at",key:"updatedAt",sortable:!0,headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>e.jsx(n,{sx:{width:"100px",...p},children:a.updatedAt?S(parseInt(a.updatedAt)):"-"})},{id:"createdAt",title:"Created at",key:"createdAt",sortable:!0,headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>e.jsx(n,{sx:{width:"100px",...p},children:a.createdAt?S(parseInt(a.createdAt)):"-"})},{id:"createdBy",title:"Created by",key:"createdBy",headerClass:"header-cell",className:"normal-height normal-padding no-wrap",render:a=>e.jsx(n,{sx:{width:"150px",...p},children:a.createdBy||"-"})},{id:"actions",title:"Action",key:"actions",headerClass:"header-cell",className:"normal-height normal-padding",render:(a,s)=>e.jsxs(j,{direction:"row",width:70,spacing:1,justifyContent:"center",alignItems:"center",onClick:m=>{m.stopPropagation()},children:[e.jsx(v,{title:"Copy page link",placement:"top",children:e.jsx(z,{text:l(a),index:s,size:"large",copyText:"Copy page link",copiedText:"Page link copied!",icon:e.jsx(R,{fill:"white",stroke:"#667085"})})}),e.jsx(v,{title:"Delete",placement:"top",children:e.jsx(n,{width:24,sx:{cursor:"pointer"},onClick:()=>u("delete",a),children:e.jsx(W,{color:"#667085"})})})]})}],[u,o])},J=u=>{const r=f();return{handleAction:d.useCallback(async(o,l)=>{try{if(o==="copy")try{const t=l.pageLink||`${window.location.origin}/live-fundraise/${l.id}`;await navigator.clipboard.writeText(t),h.success("Page link copied successfully.")}catch{h.error("Failed to copy page link.")}else o==="delete"&&r(B(l.id,t=>{t.success?(h.success(t.message||"Fundraiser deleted successfully."),r(F({isDeleted:!1}))):h.error(t.message||"Failed to delete fundraiser.")}))}catch(t){console.error("Action failed:",t),h.error("An error occurred. Please try again.")}},[r])}},re=()=>{const u=w(),r=f(),[c,o]=d.useState(""),[l,t]=d.useState(0),[a,s]=d.useState(10),{liveFundraises:m,liveFundraisesLoading:A,liveFundraisesTotalCount:C}=H(i=>i.liveFundraise);d.useEffect(()=>{r(F({isDeleted:!1,page:l+1,pageSize:a}))},[r,l,a]);const x=m,k=d.useMemo(()=>c.trim()?x.filter(i=>i.name.toLowerCase().includes(c.toLowerCase())):x,[c,x]),L=k,g=typeof C=="number"?C:k.length,b=(i,y)=>{o(i),t(0)},N=i=>{t(i-1)},I=({target:i})=>{s(Number(i.value)),t(0)},{handleAction:P}=J(),D=q(P),E=i=>{i.id&&(r({type:"SET_LIVE_FUNDRAISE_LOADING",payload:{loading:!0,success:!1,error:null}}),u(`/live-fundraise/create-new-live/${i.id}`))};return e.jsxs("div",{className:"live-fundraiser-wrapper",children:[e.jsx(_,{crumbs:["Fundraising","Fundraiser Live"],onCrumbClick:()=>{}}),e.jsx("div",{className:"live-fundraiser-header",children:e.jsxs("div",{className:"title-container",children:[e.jsx(M,{children:"Fundraiser Live"}),e.jsx(O,{id:"Actionbuttoncreate",size:"large",weight:"700",onClick:()=>{r($()),u("/live-fundraise/create-new-live")},children:"Create new"})]})}),e.jsx("span",{className:"divider"}),e.jsxs("div",{className:"table-container",children:[e.jsx(n,{sx:{pb:2,pl:2,pt:2},children:e.jsx(G,{searchValue:c,setSearchValue:o,onSearchChange:b})}),e.jsx(T,{sx:{borderColor:"#EAECF0",borderBottomWidth:1}}),e.jsx(j,{direction:"row",alignItems:"center",sx:{position:"relative",px:2,py:"12px"},children:g>0?e.jsxs(n,{sx:{fontSize:"12px",color:"#334054",padding:"2px 8px",fontFamily:"Inter",fontWeight:500},children:[g," ",g===1?"fundraiser":"fundraisers"]}):e.jsx(n,{sx:{fontSize:"12px",color:"#334054",padding:"2px 8px",fontFamily:"Inter",fontWeight:500,height:22}})}),e.jsx(U,{columns:D,data:L,stickyHeader:!0,loading:A.loading,totalSize:g,onRowClick:E,stickyActions:!0,paginationComponent:e.jsxs(n,{display:"flex",gap:2,alignItems:"center",justifyContent:"flex-end",children:[e.jsx(V,{pageSize:a,onPageSizeChange:({value:i})=>I({target:{value:i}}),options:[10,30,50,100]}),e.jsx(Y,{count:g||0,page:l+1,rowsPerPage:a,onPageChange:(i,y)=>N(y)})]}),tableStyles:{borderRadius:"8px",border:"1px solid #EAECF0",maxHeight:"600px"}})]})]})};export{re 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.