1import{m as y,u as N,g as v,c as w,r as i,t as h,f as P,j as e,B as l,d as E}from"./index-_aijvlUq.js";import{P as M}from"./PageHeader-DCofr6qo.js";import{p as S}from"./performances-duTJPchz.js";import{m as k}from"./members-I3UAoZ9P.js";import{d as C}from"./exportCsv-CZAUSrIW.js";import{E as $}from"./EmptyState-CPGKooqj.js";import"./downscaleImage-qyGK-a3D.js";function R(){const{id:r}=y(),g=N(),u=v(),{showError:c}=w(),[d,f]=i.useState(null),[a,b]=i.useState(null),[n,p]=i.useState(1),[j,x]=i.useState(!0);i.useEffect(()=>{k.getById(r).then(s=>f(s)).catch(()=>c(h("member")))},[r]),i.useEffect(()=>{x(!0),S.memberMusicHistory(r,n).then(s=>b(s)).catch(()=>c(h("music history"))).finally(()=>x(!1))},[r,n]);const o=d?P(d):"Member";return e.jsxs("div",{children:[!u&&e.jsx(M,{title:`Music Performed â ${o}`,breadcrumbs:[{label:"Members",to:"/members"},{label:o,to:`/members/${r}`},{label:"Music History"}],actions:a?.music?.length>0?e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>{const s=[];for(const t of a.music)for(const m of t.performances)s.push([t.title,t.composers||"",t.arrangers||"",t.grade||"",t.style||"",m.date,m.title,m.ensembleName||""]);C(`music-history-${o}.csv`,["Title","Composer","Arranger","Grade","Style","Performance Date","Performance","Ensemble"],s)},children:"Export CSV"}):null,children:e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>g(`/members/${r}`),children:"Back to member"})}),e.jsx("div",{className:"p-6",children:j&&!a?e.jsx("p",{className:"text-sm text-gray-400",children:"Loadingâ¦"}):!a||a.music.length===0?e.jsx($,{card:!0,title:"No music performed yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:a.music.map(s=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-800",children:s.title}),e.jsx("p",{className:"text-sm text-gray-400",children:[s.composers,s.arrangers?`arr. ${s.arrangers}`:null,s.grade?`Grade ${s.grade}`:null,s.style].filter(Boolean).join(" · ")})]}),e.jsxs("span",{className:"shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-700",children:[s.performances.length," performance",s.performances.length!==1?"s":""]})]}),e.jsx("div",{className:"overflow-x-auto -mx-5 px-5",children:e.jsxs("table",{className:"w-full min-w-[500px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs font-medium text-gray-400 uppercase tracking-wide border-b border-gray-100",children:[e.jsx("th",{className:"pb-1.5 pr-6",children:"Date"}),e.jsx("th",{className:"pb-1.5 pr-6",children:"Performance"}),e.jsx("th",{className:"pb-1.5",children:"Ensemble"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:s.performances.map(t=>e.jsxs("tr",{className:"text-gray-700",children:[e.jsx("td",{className:"py-1.5 pr-6 whitespace-nowrap text-gray-500",children:E(t.date)}),e.jsx("td",{className:"py-1.5 pr-6 font-medium",children:t.title}),e.jsx("td",{className:"py-1.5 text-gray-500",children:t.ensembleName??"â"})]},t.performanceId))})]})})]},s.musicId))}),a.pagination.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between mt-6",children:[e.jsxs("p",{className:"text-sm text-gray-400",children:["Showing ",(a.pagination.page-1)*a.pagination.limit+1,"â",Math.min(a.pagination.page*a.pagination.limit,a.pagination.total)," of ",a.pagination.total," pieces"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{variant:"ghost",size:"sm",disabled:n<=1,onClick:()=>p(s=>s-1),children:"Previous"}),e.jsx(l,{variant:"ghost",size:"sm",disabled:n>=a.pagination.totalPages,onClick:()=>p(s=>s+1),children:"Next"})]})]})]})})]})}export{R as MemberMusicHistoryPage};
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.