1import{d as I,r as d,j as e,L as h,E as W,f as R,e as j}from"./index-BmqYvqwm.js";import{B}from"./BrokerRequestButton-BJ8k3uq1.js";import{S as T}from"./SendMessageButton-C5e3r3os.js";import{B as w}from"./BackButton-unJOeNw1.js";const r={teal:"#014b50",sand:"#eae8e2",brown:"#563333",lightTeal:"#e8f4f4",error:"#dc2626",success:"#16a34a"};function D(){const{showToast:t}=I(),[n,a]=d.useState(null),[c,m]=d.useState(!0),[u,g]=d.useState(null),[o,v]=d.useState("all"),[S,f]=d.useState({});d.useEffect(()=>{x()},[]);const x=async()=>{try{m(!0),g(null);const s=localStorage.getItem("iha_token"),p=await fetch("/api/tribe/interests",{headers:{Authorization:`Bearer ${s}`}});if(!p.ok){const b=await p.json();throw new Error(b.error||"Failed to fetch interests")}const l=await p.json();a(l)}catch(s){g(s.message)}finally{m(!1)}},_=async(s,p)=>{try{f(z=>({...z,[s]:!0}));const l=localStorage.getItem("iha_token");if(!(await fetch(`/api/matches/${s}/interest`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({interested:p})})).ok)throw new Error("Failed to update interest");x()}catch(l){t(l.message,"error")}finally{f(l=>({...l,[s]:!1}))}},k=()=>{if(!n)return[];switch(o){case"mutual":return n.mutualInterests||[];case"pending":return n.pendingInterests||[];case"declined":return n.declinedInterests||[];default:return n.allInterests||[]}};if(c)return e.jsxs("div",{style:{maxWidth:"1000px",margin:"0 auto",padding:"1rem"},children:[e.jsx(h,{type:"header"}),e.jsxs("div",{style:{display:"flex",gap:"1rem",margin:"1.5rem 0"},children:[e.jsx(h,{type:"text",width:"80px"}),e.jsx(h,{type:"text",width:"80px"}),e.jsx(h,{type:"text",width:"80px"})]}),e.jsx(h,{type:"card",count:3})]});if(u)return e.jsx("div",{style:{maxWidth:"1000px",margin:"0 auto",padding:"1rem"},children:e.jsx(W,{type:"generic",message:u,onRetry:x})});const y=k(),i=n?.summary||{total:0,mutual:0,pending:0};return e.jsxs("div",{style:{maxWidth:"1000px",margin:"0 auto",padding:"1rem"},children:[e.jsxs("div",{style:{marginBottom:"1.5rem"},children:[e.jsx(w,{to:"/dashboard",label:"Back to Dashboard"}),e.jsx("h1",{style:{color:r.teal,margin:"1rem 0 0.5rem",fontSize:"1.5rem"},children:"Interest Inbox"}),e.jsx("p",{style:{color:r.brown,fontSize:"0.9rem"},children:"Consultants who have expressed interest in your posted needs"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"0.75rem",marginBottom:"1.5rem"},children:[e.jsxs("div",{style:{background:r.lightTeal,padding:"1rem",borderRadius:"12px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"1.5rem",fontWeight:"700",color:r.teal},children:i.total}),e.jsx("div",{style:{color:r.brown,fontSize:"0.75rem"},children:"Total Interests"})]}),e.jsxs("div",{style:{background:"#dcfce7",padding:"1rem",borderRadius:"12px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"1.5rem",fontWeight:"700",color:r.success},children:i.mutual}),e.jsx("div",{style:{color:r.brown,fontSize:"0.75rem"},children:"Mutual Matches"})]}),e.jsxs("div",{style:{background:"#fef9c3",padding:"1rem",borderRadius:"12px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"1.5rem",fontWeight:"700",color:"#ca8a04"},children:i.pending}),e.jsx("div",{style:{color:r.brown,fontSize:"0.75rem"},children:"Awaiting Your Response"})]})]}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1.5rem",flexWrap:"wrap"},children:["all","mutual","pending","declined"].map(s=>e.jsxs("button",{onClick:()=>v(s),style:{padding:"0.5rem 1rem",borderRadius:"8px",border:"none",background:o===s?r.teal:"white",color:o===s?"white":r.brown,cursor:"pointer",fontWeight:o===s?"600":"400",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",fontSize:"0.9rem"},children:[s.charAt(0).toUpperCase()+s.slice(1),s==="all"&&` (${i.total})`,s==="mutual"&&` (${i.mutual})`,s==="pending"&&` (${i.pending})`,s==="declined"&&` (${i.declined||0})`]},s))}),y.length===0?e.jsx(R,{variant:o==="mutual"?"noMatches":"noInterests",title:o==="mutual"?"No Mutual Matches Yet":"No Interests Yet",message:o==="mutual"?"When you express interest in consultants who have also expressed interest in your needs, they'll appear here.":"When consultants express interest in your posted needs, they'll appear here.",actionLabel:"Post a Need",actionLink:"/dashboard/needs/post"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:y.map(s=>e.jsx(E,{interest:s,onExpressInterest:_,loading:S[s.match_id]},s.match_id))}),e.jsx("div",{style:{display:"flex",justifyContent:"center",paddingTop:"2rem",marginTop:"2rem",borderTop:`1px solid ${r.sand}`},children:e.jsx(w,{to:"/dashboard",label:"Back to Dashboard"})})]})}function E({interest:t,onExpressInterest:n,loading:a}){const c=t.tribe_interested&&t.consultant_interested;return e.jsx("div",{style:{background:"white",borderRadius:"12px",padding:"1rem",boxShadow:"0 2px 8px rgba(0,0,0,0.08)",border:c?`2px s
1olid ${r.success}`:"1px solid #e5e7eb"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flex:"1 1 200px",minWidth:"0"},children:[t.consultant_avatar?e.jsx("img",{src:t.consultant_avatar,alt:t.consultant_name,style:{width:"40px",height:"40px",borderRadius:"50%",objectFit:"cover",flexShrink:0}}):e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"50%",background:r.lightTeal,display:"flex",alignItems:"center",justifyContent:"center",color:r.teal,fontWeight:"600",fontSize:"1rem",flexShrink:0},children:t.consultant_name?.charAt(0)||"?"}),e.jsxs("div",{style:{minWidth:"0"},children:[e.jsx(j,{to:`/consultants/${t.consultant_id}`,style:{color:r.teal,fontWeight:"600",fontSize:"1rem",textDecoration:"none",display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.consultant_name}),t.verification_status==="verified"&&e.jsx("span",{style:{background:"#dcfce7",color:r.success,padding:"0.1rem 0.4rem",borderRadius:"9999px",fontSize:"0.65rem",fontWeight:"500"},children:"â Verified Indigenous-Owned"}),t.verification_status==="self_attested"&&e.jsx("span",{style:{background:r.lightTeal,color:r.teal,padding:"0.1rem 0.4rem",borderRadius:"9999px",fontSize:"0.65rem",fontWeight:"500"},children:"Self-Attested"})]})]}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:c?e.jsx("span",{style:{background:"#dcfce7",color:r.success,padding:"0.4rem 0.75rem",borderRadius:"8px",fontWeight:"600",fontSize:"0.8rem",whiteSpace:"nowrap"},children:"â Mutual Match"}):t.tribe_interested?e.jsx("span",{style:{background:r.lightTeal,color:r.teal,padding:"0.4rem 0.75rem",borderRadius:"8px",fontWeight:"500",fontSize:"0.8rem",whiteSpace:"nowrap"},children:"Interest Expressed"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>n(t.match_id,!0),disabled:a,style:{padding:"0.4rem 0.75rem",borderRadius:"8px",border:"none",background:r.teal,color:"white",cursor:a?"not-allowed":"pointer",fontWeight:"500",opacity:a?.7:1,fontSize:"0.8rem",whiteSpace:"nowrap"},children:a?"Saving...":"Express Interest"}),e.jsx("button",{onClick:()=>n(t.match_id,!1),disabled:a,style:{padding:"0.4rem 0.75rem",borderRadius:"8px",border:`1px solid ${r.brown}`,background:"white",color:r.brown,cursor:a?"not-allowed":"pointer",fontSize:"0.8rem"},children:"Pass"})]})})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:r.brown,fontSize:"0.8rem"},children:"Interested in: "}),e.jsx(j,{to:`/opportunities/${t.need_id}`,style:{color:r.teal,fontWeight:"500",textDecoration:"none",fontSize:"0.85rem"},children:t.need_title})]}),t.match_score&&e.jsx("div",{children:e.jsxs("span",{style:{background:t.match_score>=75?"#dcfce7":t.match_score>=50?"#fef9c3":"#fee2e2",color:t.match_score>=75?r.success:t.match_score>=50?"#ca8a04":r.error,padding:"0.2rem 0.6rem",borderRadius:"9999px",fontSize:"0.8rem",fontWeight:"600"},children:[t.match_score,"% Match"]})}),t.consultant_services?.length>0&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.4rem"},children:[t.consultant_services.slice(0,3).map((m,u)=>e.jsx("span",{style:{background:r.sand,padding:"0.2rem 0.4rem",borderRadius:"4px",fontSize:"0.7rem",color:r.brown},children:m},u)),t.consultant_services.length>3&&e.jsxs("span",{style:{fontSize:"0.7rem",color:r.brown},children:["+",t.consultant_services.length-3," more"]})]}),c&&e.jsxs("div",{style:{background:"#dcfce7",padding:"0.75rem",borderRadius:"8px"},children:[e.jsx("div",{style:{fontWeight:"600",color:r.success,marginBottom:"0.5rem",fontSize:"0.85rem"},children:"â Mutual Match! Contact Information:"}),t.consultant_email&&e.jsxs("div",{style:{color:r.brown,fontSize:"0.85rem"},children:["Email: ",e.jsx("a",{href:`mailto:${t.consultant_email}`,style:{color:r.teal},children:t.consultant_email})]}),t.consultant_website&&e.jsxs("div",{style:{color:r.brown,fontSize:"0.85rem"},children:["Website: ",e.jsx("a",{href:t.consultant_website,target:"_blank",rel:"noopener noreferrer",style:{color:r.teal,wordBreak:"break-all"},children:t.consultant_website})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[t.consultant_user_id&&e.jsx(T,{recipientId:t.consultant_user_id,recipientName:t.consultant_name,variant:"secondary"}),e.jsx(B,{matchId:t.match_id,needId:t.need_id})]})]})]})})}export{D as InterestInbox,D 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.