1import{r as n,a as N,j as e}from"./index-CfXdH3Sr.js";const S=100,C={bug_report:"Bug Report",feature_request:"Feature Request",ux_feedback:"User Experience",subscription:"Subscription",other:"Other"},b=t=>C[t]||t||"Uncategorised";function E(t){if(!t)return"no date";const i=/[Z+]|-\d\d:\d\d$/.test(t.slice(10))?t:`${t}Z`,l=new Date(i);return Number.isNaN(l.getTime())?t:l.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function R(){const[t,i]=n.useState([]),[l,m]=n.useState(0),[c,h]=n.useState("loading"),[g,u]=n.useState(""),[p,y]=n.useState("all"),x=n.useCallback(async a=>{var r,o,d;try{const{data:s}=await N.get("/feedback",{params:{limit:S,offset:a}});i(f=>a===0?s.items:[...f,...s.items]),m(s.total),h("ready")}catch(s){if(((r=s==null?void 0:s.response)==null?void 0:r.status)===403){h("forbidden");return}u(((d=(o=s==null?void 0:s.response)==null?void 0:o.data)==null?void 0:d.detail)||(s==null?void 0:s.message)||"Could not load feedback."),h("error")}},[]);n.useEffect(()=>{x(0)},[x]);const k=async a=>{var d;const r=a.email||"an anonymous visitor";if(!window.confirm(`Delete this feedback from ${r}? It cannot be recovered.`))return;const o=t;u(""),i(t.filter(s=>s.id!==a.id)),m(s=>Math.max(0,s-1));try{await N.delete(`/feedback/${a.id}`)}catch(s){i(o),m(f=>f+1),u(((d=s==null?void 0:s.response)==null?void 0:d.status)===404?"That item was already deleted. Reload to refresh the list.":"Delete failed. The item is still here.")}};if(c==="forbidden")return e.jsx("main",{className:"admin-blank",children:e.jsx("p",{children:"Page not found"})});if(c==="loading")return e.jsx("main",{className:"admin-blank",children:e.jsx("p",{children:"Loading"})});const v=Array.from(new Set(t.map(a=>a.category).filter(Boolean))).sort(),j=t.filter(a=>p==="all"||a.category===p);return e.jsxs("main",{className:"admin",children:[e.jsxs("header",{className:"admin-head",children:[e.jsx("p",{className:"admin-eyebrow",children:"tailrd · internal"}),e.jsx("h1",{children:"Feedback"}),e.jsxs("p",{className:"admin-count",children:[t.length," of ",l," loaded"]})]}),e.jsx("div",{className:"admin-filters",children:e.jsxs("label",{className:"admin-filter",children:[e.jsx("span",{children:"Category"}),e.jsxs("select",{value:p,onChange:a=>y(a.target.value),children:[e.jsx("option",{value:"all",children:"All"}),v.map(a=>e.jsx("option",{value:a,children:b(a)},a))]})]})}),g&&e.jsx("p",{className:"admin-notice",children:g}),c==="error"&&t.length===0&&e.jsx("p",{className:"admin-empty",children:"Could not reach the server. Reload to try again."}),c==="ready"&&t.length===0&&e.jsx("p",{className:"admin-empty",children:"Nothing yet. Submissions from the Feedback and Interview pages land here."}),t.length>0&&j.length===0&&e.jsx("p",{className:"admin-empty",children:"No feedback matches these filters."}),e.jsx("ul",{className:"admin-list",children:j.map(a=>e.jsx("li",{className:"admin-item",children:e.jsxs("div",{className:"admin-row",children:[e.jsxs("div",{className:"admin-body",children:[e.jsxs("div",{className:"admin-meta",children:[e.jsx("span",{className:"admin-category",children:b(a.category)}),a.email?e.jsx("a",{className:"admin-who",href:`mailto:${a.email}`,children:a.email}):e.jsx("span",{className:"admin-who admin-anon",children:a.user_id?`user ${a.user_id}`:"anonymous"}),e.jsx("span",{className:"admin-when",children:E(a.created_at)})]}),e.jsx("p",{className:"admin-message",children:a.message})]}),e.jsx("button",{className:"admin-delete",type:"button",onClick:()=>k(a),children:"Delete"})]})},a.id))}),t.length<l&&e.jsx("button",{className:"admin-more",type:"button",onClick:()=>x(t.length),children:"Load more"})]})}export{R 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.