1import{x as q,e as z,m as E,c as u,a as l,b as c,N as G,j as v,w as x,k as a,_ as H,o as i,i as J,d as V,s as w,z as Q,g as X,t as k,C as Z,a5 as h}from"./Cny-jMUR.js";import{_ as ee}from"./B-5qM8bm.js";import{_ as te}from"./CDfksEdi.js";import{_ as se}from"./CSHkLFmR.js";import{_ as ae}from"./DmDz5m4l.js";import{_ as oe}from"./sd3vO9h1.js";import{u as re}from"./CqzOlPej.js";import"./YF0e3wke.js";import"./CXDzCsr7.js";import"./B7NayylV.js";import"./BGx-vc2c.js";import"./BRdsWsvc.js";import"./COjSgi5K.js";import"./Bhcf4Zif.js";const ne={class:"bg-gray-50"},le={class:"max-w-6xl mx-auto pt-16 pb-20 p-4 min-h-screen"},ie={class:"flex flex-row items-center gap-2 mb-8 text-brand hover:text-primary-300"},ue={class:"flex flex-row justify-between items-end mb-8 gap-4"},ce={class:"mb-6"},de={key:0,class:"flex justify-center items-center py-12"},me={key:1},fe={key:0,class:"mb-8"},be={class:"text-2xl font-semibold text-neutral-950 mb-4"},pe={key:0},ge={key:1,class:"text-sm font-normal text-gray-600"},_e={key:1,class:"text-center py-12"},xe={class:"text-gray-600"},he={key:0},ye={key:1},Ae={__name:"index",setup(ve){const g=q(),{projects:p,fetchStaffProjects:O,loading:S,error:$,resolveCustomStatusId:D}=re(),n=X(null),U=t=>{var e;return((e=t.staffAssociation)==null?void 0:e.isOwner)||!1},I=t=>{var e;return((e=t.staffAssociation)==null?void 0:e.hasTaskResponsibility)||!1},A=t=>t?new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Unknown",R=t=>{var e,o;if(console.log("getProjectStatus >> project = ",t),(e=t==null?void 0:t.project)!=null&&e.customStatusId){const s=D((o=t==null?void 0:t.project)==null?void 0:o.customStatusId);return console.log("getProjectStatus >> resolved status = ",s),s?s.name:"Unknown"}return"--"},y=t=>{var e,o;return(e=t==null?void 0:t.project)!=null&&e.customStatusId?D((o=t==null?void 0:t.project)==null?void 0:o.customStatusId):null},B=t=>{const e=[];return U(t)&&e.push("Owner"),I(t)&&e.push("Task Responsible"),e.join(", ")||"Member"},P=(t,e)=>{if(!t)return"transparent";let s={blue:"#3498db",red:"#e74c3c",green:"#2ecc71",yellow:"#f1c40f",orange:"#f39c12",gray:"#95a5a6",grey:"#95a5a6",purple:"#9b59b6",pink:"#e91e63",cyan:"#1abc9c",indigo:"#6610f2",teal:"#20c997",turquoise:"#1abc9c",darkturquoise:"#00ced1",gold:"#ffd700",darkgold:"#b8860b"}[t.toLowerCase()]||t;if(s.startsWith("#")&&(s=s.replace("#",""),s.length===3&&(s=s.split("").map(r=>r+r).join("")),s.length===6&&/^[0-9A-Fa-f]{6}$/.test(s))){const r=parseInt(s.substr(0,2),16),b=parseInt(s.substr(2,2),16),d=parseInt(s.substr(4,2),16);return`rgba(${r}, ${b}, ${d}, ${e})`}if(t.startsWith("rgb")){const r=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(r)return`rgba(${r[1]}, ${r[2]}, ${r[3]}, ${e})`}return console.warn(`Could not convert color "${t}" to rgba, using fallback`),`rgba(128, 128, 128, ${e})`},F=t=>"#374151",_=w(()=>{if(!p.value)return[{value:null,label:"All Statuses"}];const t=new Set,e=[{value:null,label:"All Statuses"}];return p.value.forEach(o=>{const s=y(o);if(s){const r=`${s.id}-${s.name}`;t.has(r)||(t.add(r),e.push({value:s.id,label:s.name,statusObj:s}))}}),e.sort((o,s)=>o.value===null?-1:s.value===null?1:o.label.localeCompare(s.label))}),f=w(()=>p.value?!n.value||n.value===null?p.value:p.value.filter(t=>{const e=y(t);return e&&e.id===n.value}):[]),M=[{accessorKey:"title",header:"Project Title",sortable:!0,class:"min-w-[200px]"},{accessorKey:"status",header:"Status",sortable:!0,class:"min-w-[120px]",cell:({row:t})=>{const e=t.original,o=y(e==null?void 0:e.original),s=t.getValue("status");return o&&o.color?h("span",{class:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium border whitespace-nowrap",style:{color:F(o.color),backgroundColor:P(o.color,.1),borderColor:P(o.color,.3)}},s):h("span",{class:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium border whitespace-nowrap bg-gray-100 text-gray-800 border-gray-300"},s)}},{accessorKey:"role",header:"Your Role",sortable:!0,class:"min-w-[140px]",cell:({row:t})=>{const e=t.getValue("role");return h("span",{class:"text-sm whitespace-nowrap"},e)}},{accessorKey:"createdDate",header:"Created",sortable:!0,class:"min-w-[100px]",cell:({row:t})=>{const e=A(t.getValue("createdDate"));return h("span",{class:"text-sm text-gray-600 whitespace-nowrap"},e)}}],K=w(()=>f.value?f.value.map(e=>({id:e.id,title:e.title,status:R(e),role:B(e),createdDate:e.createdDate,original:e})).sort((e,o)=>{const s=new Date(e.createdDate||"").getTime(),r=new Date(o.createdDate||"").getTime(),b=Number.isFinite(s),d=Number.isFinite(r);return!b&&!d?0:b?d?r-s:-1:1}):[]),Y=t=>{var e;(e=t.original)!=null&&e.id&&Z(`/dashboard/projects/${t.original.id}`)},T=()=>{var t;(t=g.value)!=null&&t.email&&O(g.value.email)};return z(async()=>{g.value&&T()}),E(g,t=>{t&&T()},{immediate:!0}),(t,e)=>
1{const o=J,s=H,r=ee,b=te,d=se,L=ae,W=oe;return i(),u("div",ne,[l("div",le,[c(s,{to:"/admin"},{default:x(()=>[l("div",ie,[c(o,{name:"i-lucide-arrow-left",class:"size-5"}),e[1]||(e[1]=l("p",null,"Admin",-1))])]),_:1}),e[6]||(e[6]=l("h1",{class:"text-4xl md:text-5xl font-bold text-neutral-950 mb-8"},"My Projects",-1)),a($)?(i(),G(r,{key:0,icon:"i-heroicons-exclamation-triangle",color:"error",variant:"soft",title:a($),class:"mb-6"},null,8,["title"])):v("",!0),c(d,null,{default:x(()=>[c(b,{class:"mt-2 mb-4"})]),_:1}),c(d,{class:"mt-8"},{default:x(()=>{var N,j,C;return[l("div",ue,[e[3]||(e[3]=l("div",null,[l("h2",{class:"text-2xl font-bold mb-2"},"Your Projects"),l("p",{class:"text-sm text-gray-600"}," Projects where you are an owner or responsible for tasks ")],-1)),c(s,{to:"/admin/wrike-test",class:"text-brand hover:underline shrink-0"},{default:x(()=>[...e[2]||(e[2]=[V("Wrike test page",-1)])]),_:1})]),l("div",ce,[c(L,{modelValue:a(n),"onUpdate:modelValue":e[0]||(e[0]=m=>Q(n)?n.value=m:null),items:a(_),placeholder:"Filter by status",class:"w-64","option-attribute":"label","value-attribute":"value",searchable:""},null,8,["modelValue","items"])]),a(S)?(i(),u("div",de,[...e[4]||(e[4]=[l("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500"},null,-1)])])):(i(),u("div",me,[a(f)&&a(f).length>0?(i(),u("div",fe,[l("h3",be,[V(k(a(f).length)+" Project",1),a(f).length>1?(i(),u("span",pe,"s")):v("",!0),a(n)&&a(n)!==null?(i(),u("span",ge," (filtered by "+k((N=a(_).find(m=>m.value===a(n)))==null?void 0:N.label)+") ",1)):v("",!0)]),c(W,{data:a(K),columns:M,class:"flex-1 cursor-pointer border border-neutral-300 rounded-lg overflow-x-auto",loading:a(S),"empty-state":{icon:"i-heroicons-folder-open",label:"No projects found",description:a(n)&&a(n)!==null?`No projects found with status '${(j=a(_).find(m=>m.value===a(n)))==null?void 0:j.label}'.`:"You are not currently associated with any active projects as an owner or task responsible person."},sort:{column:"createdDate",direction:"desc"},sticky:"",onSelect:Y},null,8,["data","loading","empty-state"])])):(i(),u("div",_e,[c(o,{name:"i-heroicons-folder-open",class:"mx-auto h-12 w-12 text-gray-400 mb-4"}),e[5]||(e[5]=l("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"No projects found",-1)),l("p",xe,[a(n)&&a(n)!==null?(i(),u("span",he," No projects found with status '"+k((C=a(_).find(m=>m.value===a(n)))==null?void 0:C.label)+"'. Try selecting a different status or clear the filter. ",1)):(i(),u("span",ye," You are not currently associated with any active projects as an owner or task responsible person. "))])]))]))]}),_:1})])])}}};export{Ae 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.