1import{r as l,b as S,s as j,c as E,j as e,G as L,F as T,L as _,C as $,au as M,h as O}from"./index-DocTL6Xp.js";import{A as B,b as U,c as R,d as W,e as q,f as G,g as I,h as V}from"./alert-dialog-BL-rbCI7.js";import{A as H}from"./arrow-up-down-BTf0brX3.js";import{D as Y}from"./download-Bljni_8c.js";import{T as z}from"./trash-2-Bcoczq4e.js";const J=d=>{const[w,y]=l.useState([]),[N,p]=l.useState(!0),{toast:m}=S(),g=async i=>{try{const{data:r,error:o}=await j.from("user_appraisal_history").select("id, domain, appraisal_value, appraisal_source, appraised_at, notes").eq("user_id",i.id).order("appraised_at",{ascending:!1});if(o)throw o;const h=(r||[]).map(n=>({id:n.id,domain:n.domain,value:n.appraisal_value,source:n.appraisal_source,created_at:n.appraised_at,notes:n.notes||""})).filter((n,k,f)=>f.findIndex(D=>D.domain===n.domain)===k);y(h)}catch(r){m({title:"Error loading appraisals",description:r.message,variant:"destructive"})}},C=async i=>{try{const{error:r}=await j.from("user_appraisal_history").delete().eq("id",i.id);if(r)throw r;y(o=>o.filter(x=>x.id!==i.id)),m({title:"Appraisal deleted",description:`${i.domain} has been removed from your saved appraisals.`})}catch(r){m({title:"Error deleting appraisal",description:r.message,variant:"destructive"})}};return l.useEffect(()=>{d&&(g(d),p(!1))},[d==null?void 0:d.id]),{appraisals:w,isLoading:N,deleteAppraisal:C,updateAppraisalNote:async(i,r)=>{try{const{error:o}=await j.from("user_appraisal_history").update({notes:r}).eq("id",i.id);if(o)throw o;y(x=>x.map(h=>h.id===i.id?{...h,notes:r}:h)),m({title:"Note updated",description:`Note for ${i.domain} has been updated.`})}catch(o){m({title:"Error updating note",description:o.message,variant:"destructive"})}},refetchAppraisals:()=>d&&g(d)}},a={bg:"#FAF9F5",surface:"#FFFFFF",ink:"#1A1A1A",inkMuted:"#6B6B68",accent:"#C96442",border:"#E8E5DD",borderStrong:"#D8D3C5"};function ee(){var A;const[d,w]=l.useState(null),[y,N]=l.useState(!0),[p,m]=l.useState(""),[g,C]=l.useState("date"),[b,i]=l.useState("desc"),[r,o]=l.useState({open:!1,appraisal:null}),x=E(),{toast:h}=S(),{appraisals:n,deleteAppraisal:k}=J(d);l.useEffect(()=>{document.title="Saved Appraisals - GoExpired.com"},[]),l.useEffect(()=>{(async()=>{const{data:{user:s}}=await j.auth.getUser();if(!s){x("/auth");return}w(s),N(!1)})()},[x]);const f=l.useMemo(()=>{const t=n.filter(s=>s.domain.toLowerCase().includes(p.toLowerCase()));return t.sort((s,v)=>{let c,u;switch(g){case"value":c=s.value,u=v.value;break;case"domain":c=s.domain.toLowerCase(),u=v.domain.toLowerCase();break;default:c=new Date(s.created_at).getTime(),u=new Date(v.created_at).getTime()}return c<u?b==="asc"?-1:1:c>u?b==="asc"?1:-1:0}),t},[n,p,g,b]),D=async()=>{r.appraisal&&(await k(r.appraisal),o({open:!1,appraisal:null}))},F=()=>{const t=["Domain,Appraisal Value (USD),Notes",...f.map(u=>`"${u.domain}",${u.value},"${(u.notes||"").replace(/"/g,'""')}"`)].join(` 2`),s=new Blob([t],{type:"text/csv;charset=utf-8;"}),v=URL.createObjectURL(s),c=document.createElement("a");c.href=v,c.download=`saved-appraisals-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(c),c.click(),document.body.removeChild(c),h({title:"Export complete",description:`Exported ${f.length} appraisals.`})};return y?e.jsx("div",{style:{backgroundColor:a.bg,color:a.inkMuted},className:"min-h-screen flex items-center justify-center",children:"Loadingâ¦"}):e.jsxs("div",{style:{backgroundColor:a.bg,color:a.ink,fontFamily:"'Inter', system-ui, sans-serif"},className:"min-h-screen",children:[e.jsx(L,{activeLink:"resources"}),e.jsxs("main",{children:[e.jsxs("section",{className:"max-w-6xl mx-auto px-6 md:px-8 pt-16 md:pt-20 pb-10",children:[e.jsx("h1",{className:"text-5xl md:text-6xl leading-[1.05] tracking-tight mb-4",style:{fontFamily:"'Cormorant', serif",fontWeight:600},children:"Saved appraisals"}),e.jsx("p",{className:"text-lg max-w-2xl",style:{color:a.inkMuted,fontFamily:"'Cormorant', serif",fontWeight:500},children:"Your complete history of domain valuations - searchable, sortable, exportable."})]}),e.jsxs("section",{className:"max-w-6xl mx-auto px-6 md:px-8 pb-24",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-full flex-1 min-w-[240px]",style:{backgroundColor:a.surface,border:`1px solid ${a.border}`},children:[e.jsx(T,{className:"w-4 h-4",style:{color:a.inkMuted}}),e.jsx("input",{type:"text",value:p,onChange:t=>m(t.target.value),placeholder:"Search by domainâ¦",className:"bg-transparent outline-none text-sm flex-1",style:{color:a.ink}})]}),e.jsxs("select",{value:g,onChange:t=>C(t.target.value),className:"px-4 py-2.5 rounded-full text-sm outline-none cursor-pointer",style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,color:a.ink},children:[e.jsx("option",{value:"date",children:"Sort: Date"}),e.jsx("option",{value:"value",children:"Sort: Value"}),e.jsx("option",{value:"domain",children:"Sort: Domain"})]}),e.jsxs("button",{onClick:()=>i(b==="asc"?"desc":"asc"),className:"px-4 py-2.5 rounded-full text-sm inline-flex items-center gap-2 transition-colors",style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,color:a.ink},title:"Toggle sort order",children:[e.jsx(H,{className:"w-4 h-4"}),b==="asc"?"Asc":"Desc"]}),e.jsxs("button",{onClick:F,disabled:f.length===0,className:"px-4 py-2.5 rounded-full text-sm inline-flex items-center gap-2 transition-all hover:-translate-y-[1px] disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0",style:{backgroundColor:"#2563EB",color:"#FFFFFF",boxShadow:"0 4px 14px -4px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255,255,255,0.25)"},children:[e.jsx(Y,{className:"w-4 h-4"}),"Export CSV"]})]}),f.length===0?e.jsxs("div",{className:"text-center py-20 rounded-2xl",style:{backgroundColor:a.surface,border:`1px solid ${a.border}`},children:[e.jsx("h3",{className:"text-2xl mb-2",style:{fontFamily:"'Cormorant', serif",fontWeight:600},children:p?"No matching appraisals":"No appraisals yet"}),e.jsx("p",{className:"text-sm mb-6",style:{color:a.inkMuted},children:p?`Nothing found for "${p}".`:"Once you appraise a domain it will show up here."}),!p&&e.jsx(_,{to:"/appraise-your-domain",children:e.jsx("button",{className:"px-6 py-3 rounded-full text-sm font-medium transition-all hover:-translate-y-[1px]",style:{backgroundColor:"#2563EB",color:"#FFFFFF",boxShadow:"0 4px 14px -4px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255,255,255,0.25)"},children:"Appraise a domain"})})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:f.map(t=>e.jsxs("article",{className:"rounded-2xl p-6 transition-all hover:-translate-y-[2px] flex flex-col",style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,boxShadow:"0 1px 2px rgba(26,26,26,0.04)"},onMouseEnter:s=>s.currentTarget.style.boxShadow="0 12px 32px -12px rgba(26,26,26,0.15), 0 2px 6px rgba(26,26,26,0.05)",onMouseLeave:s=>s.currentTarget.style.boxShadow="0 1px 2px rgba(26,26,26,0.04)",children:[e.jsx("h3",{className:"text-2xl tracking-tight truncate mb-2",style:{fontFamily:"'Cormorant', serif",fontWeight:600},title:t.domain,children:t.domain.toLowerCase()}),e.jsxs("div",{className:"text-3xl mb-4",style:{fontFamily:"'Cormorant', serif",fontWeight:600,color:a.accent}
2,children:["$",t.value.toLocaleString()]}),t.notes&&e.jsx("p",{className:"text-sm mb-4 line-clamp-3",style:{color:a.inkMuted},children:t.notes}),e.jsxs("div",{className:"mt-auto pt-4 flex items-center justify-between text-xs",style:{color:a.inkMuted,borderTop:`1px solid ${a.border}`},children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx($,{className:"w-3 h-3"}),M(new Date(t.created_at),{addSuffix:!0})]}),e.jsx("button",{onClick:()=>o({open:!0,appraisal:t}),className:"p-1.5 rounded-full transition-colors",style:{color:a.inkMuted},onMouseEnter:s=>s.currentTarget.style.color=a.accent,onMouseLeave:s=>s.currentTarget.style.color=a.inkMuted,"aria-label":"Delete appraisal",children:e.jsx(z,{className:"w-4 h-4"})})]})]},t.id))})]})]}),e.jsx(O,{}),e.jsx(B,{open:r.open,onOpenChange:t=>o({open:t,appraisal:t?r.appraisal:null}),children:e.jsxs(U,{children:[e.jsxs(R,{children:[e.jsx(W,{children:"Delete appraisal?"}),e.jsxs(q,{children:["This will permanently remove"," ",e.jsx("span",{className:"font-medium",children:(A=r.appraisal)==null?void 0:A.domain})," from your saved appraisals."]})]}),e.jsxs(G,{children:[e.jsx(I,{children:"Cancel"}),e.jsx(V,{onClick:D,children:"Delete"})]})]})})]})}export{ee 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.