1import{e as H,f as W,r as I,g as o,s as c,j as e,S as w,I as h,B as b,L as _,J as T,K as C,i as D}from"./index-l0yqeOKG.js";import{P as U}from"./PageHeader-JIvHC6Bu.js";import{C as r,a as n,b as P,c as E,d as R}from"./card-BtTm3qbe.js";import{E as g}from"./EmptyState-DrqzA1kY.js";import{T as Q,a as X,b as f,c as y}from"./tabs-kwadB3RY.js";import{F as K}from"./file-text-CUPaF80H.js";import{U as V}from"./users-DU6v5qu6.js";import{B as A,C as F}from"./circle-x-Bqd3t4Jw.js";import{C as J}from"./clock-CVY8hIsr.js";import{C as S}from"./circle-check-Bskdbvt1.js";import{C as Y}from"./circle-alert-Cd1km154.js";import{f as p}from"./format-xGesOcNh.js";function je(){const{user:a,isLoading:q}=H(),l=W();I.useEffect(()=>{!q&&!a&&l("/auth")},[a,q,l]);const{data:d,isLoading:O}=o({queryKey:["my-projects",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("projects").select("*").eq("created_by",a.id).order("created_at",{ascending:!1});if(t)throw t;return s},enabled:!!a}),{data:m,isLoading:$}=o({queryKey:["my-partnership-interests",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("project_interests").select(` 2 *, 3 projects (id, title, status) 4 `).eq("user_id",a.id).order("created_at",{ascending:!1});if(t)throw t;return s},enabled:!!a}),{data:x,isLoading:G}=o({queryKey:["received-partnership-interests",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s}=await c.from("projects").select("id").eq("created_by",a.id);if(!s||s.length===0)return[];
4const t=s.map(v=>v.id),{data:i,error:u}=await c.from("project_interests").select(` 5 *, 6 projects (id, title) 7 `).in("project_id",t).order("created_at",{ascending:!1});if(u)throw u;return i},enabled:!!a}),{data:M,isLoading:Z}=o({queryKey:["my-registrations",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("registrations").select(` 8 *, 9 events (id, title, start_time, location, is_virtual) 10 `).eq("user_id",a.id).order("registered_at",{ascending:!1});if(t)throw t;return s},enabled:!!a}),{data:k,isLoading:ee}=o({queryKey:["my-wg-memberships",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("wg_members").select(` 11 *, 12 working_groups (id, name, theme) 13 `).eq("user_id",a.id).order("joined_at",{ascending:!1});if(t)throw t;return s},enabled:!!a}),{data:L,isLoading:se}=o({queryKey:["my-wg-requests",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("wg_join_requests").select(` 14 *, 15 working_groups (id, name) 16 `).eq("user_id",a.id).order("created_at",{ascending:!1});if(t)throw t;return s},enabled:!!a}),{data:z,isLoading:ae}=o({queryKey:["my-organizations",a==null?void 0:a.id],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await c.from("organizations").select("*").eq("created_by",a.id).order("created_at",{ascending:!1});if(t)throw t;return s},enabled:!!a});if(q)return e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(w,{className:"h-8 w-8 animate-spin text-primary"})});if(!a)return null;const j=s=>{const i={pending:{variant:"secondary",icon:e.jsx(J,{className:"h-3 w-3"})},approved:{variant:"default",icon:e.jsx(S,{className:"h-3 w-3"})},active:{variant:"default",icon:e.jsx(S,{className:"h-3 w-3"})},proposed:{variant:"outline",icon:e.jsx(Y,{className:"h-3 w-3"})},draft:{variant:"secondary",icon:e.jsx(J,{className:"h-3 w-3"})},completed:{variant:"default",icon:e.jsx(S,{className:"h-3 w-3"})},declined:{variant:"destructive",icon:e.jsx(F,{className:"h-3 w-3"})},rejected:{variant:"destructive",icon:e.jsx(F,{className:"h-3 w-3"})},suspended:{variant:"destructive",icon:e.jsx(F,{className:"h-3 w-3"})}}[s]||{variant:"secondary",icon:null};return e.jsxs(h,{variant:i.variant,className:"flex items-center gap-1",children:[i.icon,s]})},B=(m==null?void 0:m.filter(s=>s.status==="pending").length)||0,N=(x==null?void 0:x.filter(s=>s.status==="pending").length)||0;return e.jsxs("div",{children:[e.jsx(U,{title:"My Activity Dashboard",description:"Track your proposals, partnerships, and participation across the ecosystem"}),e.jsx("div",{className:"container-wide py-8",children:e.jsxs(Q,{defaultValue:"projects",className:"space-y-6",children:[e.jsxs(X,{className:"flex-wrap h-auto gap-1",children:[e.jsxs(f,{value:"projects",className:"relative",children:["My Projects",d&&d.length>0&&e.jsx(h,{variant:"secondary",className:"ml-2",children:d.length})]}),e.jsxs(f,{value:"partnerships",className:"relative",children:["Partnerships",(B>0||N>0)&&e.jsx(h,{variant:"destructive",className:"ml-2",children:B+N})]}),e.jsx(f,{value:"working-groups",children:"Working Groups"}),e.jsx(f,{value:"events",children:"Events"}),e.jsx(f,{value:"organizations",children:"Organizations"})]}),e.jsxs(y,{value:"projects",className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5 text-primary"}),"My Project Proposals"]}),e.jsx(b,{size:"sm",asChild:!0,children:e.jsx(_,{to:"/projects/new",children:"New Proposal"})})]}),O?e.jsx(r,{children:e.jsx(n,{className:"py-8 text-center",children:e.jsx(w,{className:"h-6 w-6 animate-spin mx-auto"})})}):d&&d.length>0?e.jsx("div",{className:"space-y-4",children:d.map(s=>e.jsx(r,{className:"hover:border-primary/30 transition-colors",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold",children:s.title}),j(s.status)]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Created ",p(new Date(s.created_at),"MMM d, yyyy"),s.status==="draft"&&" ⢠Awaiting admin review"]})]}),e.jsx(b,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(_,{to:`/projects/${s.id}`,children:["View ",e.jsx(T,{className:"ml-1 h-3 w-3"})]})})]})})},s.id))}):e.jsx(g,{icon:K,title:"No proposals yet",description:"Submit your first project proposal to contribute to SSE initiatives and find partners!",action:{label:"Create Proposal",onClick:()=>l("/projects/new")}})]}),e.jsxs(y,{value:"partnerships",className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2 mb-4",children:[e.jsx(C,{className:"h-5 w-5 text-primary"}),"Partnership Requests I've Sent"]}),$?e.jsx(r,{children:e.jsx(n,{className:"py-8 text-center",children:e.jsx(w,{className:"h-6 w-6 animate-spin mx-auto"})})}):m&&m.length>0?e.jsx("div",{className:"space-y-4",children:m.map(s=>{var t,i;return e.jsx(r,{className:"hover:border-primary/30 transition-colors",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold",children:(t=s.projects)==null?void 0:t.t
16itle}),j(s.status)]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.motivation}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Submitted ",p(new Date(s.created_at),"MMM d, yyyy")]})]}),((i=s.projects)==null?void 0:i.id)&&e.jsx(b,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(_,{to:`/projects/${s.projects.id}`,children:["View Project ",e.jsx(T,{className:"ml-1 h-3 w-3"})]})})]})})},s.id)})}):e.jsx(g,{icon:C,title:"No partnership requests yet",description:"Browse projects and express interest to find collaboration opportunities!",action:{label:"Browse Projects",onClick:()=>l("/projects")}})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2 mb-4",children:[e.jsx(C,{className:"h-5 w-5 text-primary"}),"Partnership Requests Received",N>0&&e.jsxs(h,{variant:"destructive",children:[N," new"]})]}),G?e.jsx(r,{children:e.jsx(n,{className:"py-8 text-center",children:e.jsx(w,{className:"h-6 w-6 animate-spin mx-auto"})})}):x&&x.length>0?e.jsx("div",{className:"space-y-4",children:x.map(s=>{var t;return e.jsx(r,{className:`hover:border-primary/30 transition-colors ${s.status==="pending"?"border-primary/50 bg-primary/5":""}`,children:e.jsx(n,{className:"pt-6",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start justify-between gap-4",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"For:"}),e.jsx("h3",{className:"font-semibold",children:(t=s.projects)==null?void 0:t.title}),j(s.status)]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"From:"})," ",s.contact_name," ",s.organization_name&&`(${s.organization_name})`]}),e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Email:"})," ",s.contact_email]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.motivation})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Received ",p(new Date(s.created_at),"MMM d, yyyy")]})]})})})},s.id)})}):e.jsx(r,{children:e.jsxs(n,{className:"py-8 text-center text-muted-foreground",children:[e.jsx(C,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No partnership requests received yet."}),e.jsx("p",{className:"text-sm",children:"Create a project to start receiving interest from potential partners!"})]})})]})]}),e.jsxs(y,{value:"working-groups",className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2 mb-4",children:[e.jsx(V,{className:"h-5 w-5 text-primary"}),"My Working Group Memberships"]}),k&&k.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:k.map(s=>{var t,i;return e.jsxs(r,{children:[e.jsxs(P,{children:[e.jsx(E,{className:"text-lg",children:(t=s.working_groups)==null?void 0:t.name}),((i=s.working_groups)==null?void 0:i.theme)&&e.jsx(R,{children:s.working_groups.theme})]}),e.jsx(n,{children:e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Joined ",p(new Date(s.joined_at),"MMM d, yyyy")]}),e.jsx(h,{variant:"outline",children:s.role})]})})]},s.id)})}):e.jsx(g,{icon:V,title:"No working group memberships",description:"Join a working group to collaborate with others!",action:{label:"View Working Groups",onClick:()=>l("/working-groups")}})]}),L&&L.length>0&&e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"My Join Requests"}),e.jsx("div",{className:"space-y-4",children:L.map(s=>{var t;return e.jsx(r,{children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:(t=s.working_groups)==null?void 0:t.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Submitted ",p(new Date(s.created_at),"MMM d, yyyy")]})]}),j(s.status)]})})},s.id)})})]})]}),e.jsxs(y,{value:"events",children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2 mb-4",children:[e.jsx(D,{className:"h-5 w-5 text-primary"}),"Event Registrations"]}),M&&M.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:M.map(s=>{var t,i,u,v;return e.jsxs(r,{children:[e.jsxs(P,{className:"pb-2",children:[e.jsx(E,{className:"text-lg",children:(t=s.events)==null?void 0:t.t
16itle}),e.jsx(R,{children:((i=s.events)==null?void 0:i.start_time)&&p(new Date(s.events.start_time),"MMM d, yyyy h:mm a")})]}),e.jsx(n,{children:e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:(u=s.events)!=null&&u.is_virtual?"Virtual Event":(v=s.events)==null?void 0:v.location}),e.jsx(h,{variant:"outline",children:s.status})]})})]},s.id)})}):e.jsx(g,{icon:D,title:"No event registrations",description:"Browse upcoming events and register to participate.",action:{label:"View Events",onClick:()=>l("/events")}})]}),e.jsxs(y,{value:"organizations",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-primary"}),"My Organizations"]}),e.jsx(b,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(_,{to:"/partners/register",children:"Register Organization"})})]}),z&&z.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:z.map(s=>e.jsxs(r,{children:[e.jsxs(P,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(E,{className:"text-lg",children:s.name}),j(s.is_approved?"approved":"pending")]}),e.jsxs(R,{children:[s.country," ⢠",s.org_type]})]}),e.jsx(n,{children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description})})]},s.id))}):e.jsx(g,{icon:A,title:"No organizations registered",description:"Register your organization to join the SSE network and access more opportunities.",action:{label:"Register Organization",onClick:()=>l("/partners/register")}})]})]})})]})}export{je 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.