PageSourceSearch

https://dr-grader.vercel.app/assets/History-X6eXUxII.js

js dr-grader.vercel.app collected 2026-10-03 06:47:11 UTC 10,970 bytes, 10 lines download raw bytes

1import{c as K,u as O,d as U,r as n,j as e,F as I,p as L,s as g,J as W}from"./index-BAvOxkeY.js";import{u as Y,M as z}from"./useMinisurvey-DDzLInn9.js";import{C as R,s as J,f as Q,n as V,g as X,S as Z,m as ee}from"./ShareButton-MCmiCPDO.js";import{l as se}from"./share-link-OjhiQt18.js";import{m as re}from"./proxy-kSReWll0.js";import{P as te}from"./pencil-BMdScF4T.js";import{T as ae}from"./trash-2-DrFrbEej.js";import{A as oe}from"./arrow-right-CylEIJX3.js";import{C as ne}from"./chevron-up-bGadzcAP.js";import"./share-2-BtFNRM_L.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"60fec980374e736c48818a6a7d24bb8ff7f0c59d"};var i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="f6aebf69-c96b-4588-a1af-d5050c935fce",t._sentryDebugIdIdentifier="sentry-dbid-f6aebf69-c96b-4588-a1af-d5050c935fce")}catch{}})();/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const de=K("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),ie=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-2 md:gap-4 px-4 py-3 items-center animate-pulse",children:[e.jsxs("div",{className:"md:col-span-5 flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-muted shrink-0"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"h-3 bg-muted rounded w-20"})}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"h-3 bg-muted rounded w-16"})}),e.jsx("div",{className:"md:col-span-1 flex justify-end",children:e.jsx("div",{className:"h-3 bg-muted rounded w-8"})}),e.jsxs("div",{className:"md:col-span-2 flex justify-end gap-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-10"}),e.jsx("div",{className:"h-4 bg-muted rounded w-6"})]})]}),S=({label:t,sortKey:i,sort:d,onSort:m,align:p="start"})=>{const u=d.key===i;return e.jsxs("button",{type:"button",onClick:()=>{m(i)},title:`Sort by ${t.toLowerCase()}`,"aria-label":`Sort by ${t.toLowerCase()}`,"aria-sort":u?d.dir==="asc"?"ascending":"descending":"none",className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-foreground transition-colors ${p==="end"?"flex-row-reverse":""}`,children:[t,u&&(d.dir==="asc"?e.jsx(ne,{className:"w-3.5 h-3.5"}):e.jsx(W,{className:"w-3.5 h-3.5"}))]})},be=()=>{const{user:t}=O(),{toast:i}=U(),[d,m]=n.useState([]),[p,u]=n.useState(!0),[H,_]=n.useState(!1),[l,A]=n.useState(""),[x,h]=n.useState(null),[D,k]=n.useState(""),[c,P]=n.useState({key:"date",dir:"desc"}),[q,C]=n.useState(new Set),E=n.useRef(null),f=Y(),v=s=>{P(r=>r.key===s?{key:s,dir:r.dir==="asc"?"desc":"asc"}:{key:s,dir:"desc"})},M=async(s,r)=>{if(r.preventDefault(),r.stopPropagation(),!confirm("Delete this evaluation? This cannot be undone."))return;const{error:o}=await g.from("gradings").delete().eq("document_id",s);o&&console.error("History grading delete error:",o);const{error:a}=await g.from("documents").delete().eq("id",s);if(a){console.error("History document delete error:",a),i({title:"Delete failed",description:a.message,variant:"destructive"});return}m(y=>y.filter(j=>j.id!==s))},$=(s,r,o)=>{o.preventDefault(),o.stopPropagation(),h(s),k(r||""),setTimeout(()=>{var a;return(a=E.current)==null?void 0:a.focus()},0)},T=async()=>{if(!x)return;const s=D.trim();if(!s){h(null);return}m(o=>o.map(a=>a.id===x?{...a,title:s}:a)),h(null);const{error:r}=await g.from("documents").update({title:s}).eq("id",x);r&&console.error("History rename error:",r)},B=()=>{h(null)},F=n.useCallback((s,r)=>{C(o=>{if(o.has(s)===r)return o;const a=new Set(o);return r?a.add(s):a.delete(s),a})},[]);n.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}(async()=>{try{const{data:r,error:o}=await g.from("documents").select(`
7            id, title, content_type, word_count, created_at,
8            gradings ( id, overall_score, letter_grade )
9          `).eq("user_id",t.id).order("created_at",{ascending:!1}).order("created_at",{ascending:!1,referencedTable:"gradings"}).limit(100);if(o&&(console.error("History fetch error:",o.code,o.message),_(!0)),r){const a=ee(r,new Date().toISOString());m(a);const y=a.map(w=>w.grading_id).filter(w=>!!w),{sharedIds:j,error:N}=await se(y);N?console.error("History share lookup error:",N.code,N.message):C(j)}}catch(r){console.error("History fetch threw:",r),_(!0)}finally{u(!1)}})()},[t==null?void 0:t.id]);const b=l.trim()?d.filter(s=>{var r;return((r=s.title)==null?void 0:r.toLowerCase().includes(l.toLowerCase()))||(R[s.content_type]??s.content_type).toLowerCase().includes(l.toLowerCase())}):d,G=n.useMemo(()=>J(b,c.key,c.dir),[b,c]);return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"container mx-auto px-4 py-8 md:py-12",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(re.div,{initial:{opacity:0,y:16}
9,animate:{opacity:1,y:0},className:"mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-serif text-foreground mb-2",children:"Document History"}),e.jsx("p",{className:"text-muted-foreground",children:"All your past evaluations in one place."})]}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx(de,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx("input",{type:"text",value:l,onChange:s=>{A(s.target.value)},placeholder:"Search by title or type...",className:"w-full pl-10 pr-4 py-2.5 rounded-lg border border-border bg-card text-foreground text-sm placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/30"})]}),p?e.jsxs("div",{className:"rounded-xl border border-border bg-card shadow-card overflow-hidden",children:[e.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-4 px-4 py-2.5 bg-muted/50 border-b border-border text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[e.jsx("div",{className:"col-span-5",children:"Document"}),e.jsx("div",{className:"col-span-2",children:"Type"}),e.jsx("div",{className:"col-span-2",children:"Date"}),e.jsx("div",{className:"col-span-1 text-right",children:"Words"}),e.jsx("div",{className:"col-span-2 text-right",children:"Score"})]}),e.jsx("div",{className:"divide-y divide-border",children:[1,2,3,4,5].map(s=>e.jsx(ie,{},s))})]}):H&&d.length===0?e.jsxs("div",{className:"rounded-xl border border-border bg-card p-8 text-center shadow-card",children:[e.jsx("span",{className:"text-2xl mb-3 block",children:"😕"}),e.jsx("p",{className:"text-base font-medium text-foreground mb-1",children:"Couldn't load your history right now"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"This is usually temporary. Give it another try."}),e.jsx("button",{onClick:()=>{window.location.reload()},className:"text-sm text-primary hover:underline",children:"Refresh page"})]}):b.length===0?e.jsxs("div",{className:"rounded-xl border border-border bg-card p-8 text-center shadow-card",children:[e.jsx(I,{className:"w-8 h-8 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-base font-medium text-foreground mb-1",children:l?"No matching documents found.":"No evaluations yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:l?"Try a different search term.":"Head to Evaluate to grade your first communication."}),!l&&e.jsx(L,{to:"/evaluate",className:"text-sm text-primary hover:underline",children:"Start your first evaluation"})]}):e.jsxs("div",{className:"rounded-xl border border-border bg-card shadow-card overflow-hidden",children:[e.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-4 px-4 py-2.5 bg-muted/50 border-b border-border text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[e.jsx("div",{className:"col-span-5",children:"Document"}),e.jsx("div",{className:"col-span-2",children:"Type"}),e.jsx("div",{className:"col-span-2",children:e.jsx(S,{label:"Date",sortKey:"date",sort:c,onSort:v})}),e.jsx("div",{className:"col-span-1 flex justify-end",children:e.jsx(S,{label:"Words",sortKey:"words",sort:c,onSort:v,align:"end"})}),e.jsx("div",{className:"col-span-2 flex justify-end",children:e.jsx(S,{label:"Score",sortKey:"score",sort:c,onSort:v,align:"end"})})]}),e.jsx("div",{className:"divide-y divide-border",children:G.map(s=>e.jsxs(L,{to:`/evaluate/${s.id}`,className:"group/row grid grid-cols-1 md:grid-cols-12 gap-2 md:gap-4 px-4 py-3 hover:bg-muted/30 transition-colors items-center",children:[e.jsxs("div",{className:"md:col-span-5 flex items-center gap-2 min-w-0",children:[e.jsx(I,{className:"w-4 h-4 text-muted-foreground shrink-0"}),x===s.id?e.jsx("input",{ref:E,value:D,onChange:r=>{k(r.target.value)},onKeyDown:r=>{r.key==="Enter"&&T(),r.key==="Escape"&&B()},onBlur:()=>void T(),onClick:r=>{r.preventDefault()},className:"flex-1 min-w-0 px-2 py-0.5 rounded border border-primary/40 bg-card text-sm font-medium text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"}):e.jsx("span",{className:"text-sm font-medium text-foreground truncate group-hover/row:pr-6 relative",children:s.title??"Untitled"}),x!==s.id&&e.jsx("button",{onClick:r=>{$(s.id,s.title??"",r)}
9,className:"p-1 rounded text-muted-foreground/0 hover:text-muted-foreground hover:bg-muted/50 group-hover/row:text-muted-foreground/40 transition-colors shrink-0",title:"Rename",children:e.jsx(te,{className:"w-3 h-3"})})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:R[s.content_type]??s.content_type})}),e.jsx("div",{className:"md:col-span-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:Q(s.created_at)})}),e.jsx("div",{className:"md:col-span-1 text-right",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:s.word_count!=null?String(s.word_count):"—"})}),e.jsxs("div",{className:"md:col-span-2 flex items-center justify-end gap-2",children:[s.overall_score!=null&&e.jsxs("span",{className:`text-sm font-bold ${X(s.overall_score)}`,children:[Math.round(V(s.overall_score)),"/10"]}),s.letter_grade&&e.jsx("span",{className:"text-sm font-serif text-foreground",children:s.letter_grade}),s.grading_id&&(t==null?void 0:t.id)&&e.jsx(Z,{gradingId:s.grading_id,userId:t.id,iconOnly:!0,isShared:q.has(s.grading_id),onSharedChange:F}),e.jsx("button",{onClick:r=>void M(s.id,r),className:"p-1 rounded text-muted-foreground/40 hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete evaluation",children:e.jsx(ae,{className:"w-3.5 h-3.5"})}),e.jsx(oe,{className:"w-3.5 h-3.5 text-muted-foreground"})]})]},s.id))})]})]})}),e.jsx(z,{open:f.shouldShow,onSkip:f.skip,onDismissPermanently:f.dismissPermanently,onSubmit:f.submit})]})};export{be as default};
10//# sourceMappingURL=History-X6eXUxII.js.map

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.