PageSourceSearch

https://solaroptics.co/assets/admin.feedback-DfQSOH_u.js

js solaroptics.co collected 2026-10-08 12:25:44 UTC 4,180 bytes, 1 lines download raw bytes

1import{r as a,v as b,j as e}from"./index-5Z_GU5Ug.js";import{l as f}from"./feedback.functions-5jAVbz1V.js";import"./auth-middleware-jO1zGgbM.js";const p={email_1:"Email 1 — shopping",email_2:"Email 2 — product",product_review:"Product review (site)",site_feedback:"Site feedback"};function N(){const[t,r]=a.useState(null),[o,d]=a.useState(!0),[c,i]=a.useState(null),[n,h]=a.useState("all");a.useEffect(()=>{(async()=>{const{data:s,error:u}=await b.auth.getUser();if(u||!s.user){i("You must be signed in with an admin account to view this page."),d(!1);return}await m()})()},[]);async function m(){d(!0),i(null);try{r(await f())}catch(s){i(s instanceof Error&&/forbidden/i.test(s.message)?"Your account does not have admin access.":"Failed to load feedback."),r(null)}finally{d(!1)}}const x=(t?.rows??[]).filter(s=>n==="all"||s.path===n);return e.jsx("div",{className:"min-h-screen bg-background p-6 md:p-10",children:e.jsxs("div",{className:"mx-auto max-w-6xl",children:[e.jsx("h1",{className:"font-display text-3xl mb-2",children:"Customer feedback"}),e.jsx("p",{className:"text-muted-foreground mb-6 text-sm",children:"Every response from all three paths: the two timed emails, on-site product reviews (email-verified against real orders), and anonymous site feedback."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{onClick:()=>m(),disabled:o,className:"rounded-lg bg-primary text-primary-foreground px-4 py-2 text-sm font-semibold disabled:opacity-60",children:o?"Loading…":"Refresh"}),["all","email_1","email_2","product_review","site_feedback"].map(s=>e.jsx("button",{onClick:()=>h(s),className:`rounded-lg border px-3 py-2 text-sm ${n===s?"border-primary bg-primary/10":"border-border"}`,children:s==="all"?"All":p[s]},s))]}),c&&e.jsxs("p",{className:"text-sm text-destructive mb-4",children:[c," ",e.jsx("a",{href:"/auth",className:"underline font-semibold",children:"Go to sign in"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-8",children:[e.jsx(l,{label:"Total responses",value:t.totals.all}),e.jsx(l,{label:"Avg shopping (email 1)",value:t.totals.avgShopping??"—"}),e.jsx(l,{label:"Avg product",value:t.totals.avgProduct??"—"}),e.jsx(l,{label:"Avg site feedback",value:t.totals.avgSite??"—"})]}),e.jsx("div",{className:"rounded-lg border border-border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-3 py-2",children:"Date"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Source"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Order"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Email"}),e.jsx("th",{className:"text-right px-3 py-2",children:"Rating"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Yes/No"}),e.jsx("th",{className:"text-left px-3 py-2",children:"Comment"})]})}),e.jsxs("tbody",{children:[x.map(s=>e.jsxs("tr",{className:"border-t border-border align-top",children:[e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:new Date(s.created_at).toISOString().replace("T"," ").slice(0,16)}),e.jsx("td",{className:"px-3 py-2",children:p[s.path]??s.path}),e.jsx("td",{className:"px-3 py-2 font-mono",children:s.order_number??"—"}),e.jsxs("td",{className:"px-3 py-2",children:[s.email??"anonymous",s.verified_order&&e.jsx("span",{className:"ml-1 text-xs text-primary",children:"✓"})]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:[s.rating??"—","★"]}),e.jsx("td",{className:"px-3 py-2",children:s.binary_answer===null?"—":s.binary_answer?"Yes":"No"}),e.jsx("td",{className:"px-3 py-2 max-w-md",children:s.comment??""})]},s.id)),x.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-3 py-6 text-center text-muted-foreground",children:"No responses yet."})})]})]})})]})]})})}function l({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg border border-border p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"font-display text-2xl",children:r})]})}
1export{N as component};

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.