1import{D as le,bg as ne,u as ce,w as de,r as c,F as x,C as e,aI as u,bj as F,bi as $,br as oe,aJ as h,bf as me,G as b,bh as xe}from"./index-85vHsyJ2.js";import{bE as ue,u as z,af as C,C as he,aa as N,r as m,I as p,H as pe,s as je,J as G,k as ge,l as O,m as U,bL as ve,n as Z,o as W,p as d,bM as be,bN as Ne,w as fe,bO as ye,bP as _e,bQ as we,bR as Se,bS as Ae,bT as Fe,bU as Ce,e as De}from"./main-B2dcDIOH.js";import{P as Le}from"./PortalLayout-VZrXvA-1.js";import{f as Pe}from"./formatDistanceToNow-Cw4VpDXu.js";import"./constructNow-55YhTo2u.js";import"./differenceInCalendarMonths-YS4eGazC.js";import"./endOfDay-Cs57Fb6S.js";import"./endOfMonth-B2v-Xzej.js";const Be=()=>{const{softUser:f}=ue(),{user:y}=le(),{toast:o}=ne(),_=ce(),X=de(),a=(f==null?void 0:f.email)||(y==null?void 0:y.email),{data:i}=z({queryKey:["user-profile-resolve",a],queryFn:async()=>{if(!a)return null;const{data:s,error:t}=await x.from("profiles").select("id, role").ilike("email",a).maybeSingle();if(t)throw t;return s},enabled:!!a}),Y=(i==null?void 0:i.role)==="admin",[D,L]=c.useState(""),[P,k]=c.useState(""),[w,T]=c.useState(""),[E,q]=c.useState(""),[H,I]=c.useState(""),[Q,K]=c.useState(!1),[B,S]=c.useState(!1),[j,ee]=c.useState("all"),[g,se]=c.useState(""),{data:A,isLoading:te}=z({queryKey:["health-cases",a,j,g],queryFn:async()=>{if(!a)return[];const{data:s,error:t}=await x.rpc("portal_list_health_cases",{p_caller_email:a});if(t)throw t;const l=s??[],v=g?g.toLowerCase().replace(/[%_\\,]/g,"").substring(0,100):"";return l.filter(n=>j==="all"||n.status===j).filter(n=>{var J,M,R;return v?((J=n.patient_first_name)==null?void 0:J.toLowerCase().includes(v))||((M=n.patient_location)==null?void 0:M.toLowerCase().includes(v))||((R=n.condition_description)==null?void 0:R.toLowerCase().includes(v)):!0}).map(n=>({...n,user:{first_name:n.profile_first_name||n.submitter_name||"ÎÏÏÏοιÏοÏ"}}))},enabled:!!a}),r=C({mutationFn:async()=>{const s={patient_first_name:D,last_name_initial:P.charAt(0).toUpperCase()||null,patient_age:w?parseInt(w,10):null,patient_location:E,condition_description:H,is_anonymous:Q};if(!a)throw new Error("Î ÏÎÏει να είÏÏε ÏÏ
νδεδεμÎνοÏ");const{data:t,error:l}=await x.functions.invoke("graduate-portal-action",{body:{action:"create_health_case",email:a,...s}});if(l)throw l;if(t!=null&&t.error)throw new Error(t.error);return(t==null?void 0:t.health_case)??t},onSuccess:()=>{o({title:"ÎÏιÏÏ
ÏÎ®Ï Ï
Ïοβολή",description:"Το αίÏημα ÏÎ±Ï ÎºÎ±ÏαÏÏÏήθηκε ÏÏη HealthLine."}),L(""),k(""),T(""),q(""),I(""),K(!1),S(!1),_.invalidateQueries({queryKey:["health-cases"]})},onError:s=>{console.error("Error creating health case:",s),o({title:"ΣÏάλμα",description:"Îεν ήÏαν δÏ
ναÏή η Ï
Ïοβολή ÏοÏ
αιÏήμαÏοÏ.",variant:"destructive"})}}),ae=C({mutationFn:async({id:s,status:t})=>{const{error:l}=await x.from("health_cases").update({status:t}).eq("id",s);if(l)throw l},onSuccess:()=>{o({title:"ÎνημÎÏÏÏη καÏάÏÏαÏηÏ",description:"ΠκαÏάÏÏαÏη ενημεÏÏθηκε εÏιÏÏ
ÏÏÏ."}),_.invalidateQueries({queryKey:["health-cases"]})},onError:s=>{console.error("Error updating status:",s),o({title:"ΣÏάλμα",description:"Îεν ήÏαν δÏ
ναÏή η ενημÎÏÏÏη.",variant:"destructive"})}}),V=C({mutationFn:async s=>{const{error:t}=await x.from("health_cases").delete().eq("id",s);if(t)throw t},onSuccess:()=>{o({title:"ÎιαγÏαÏή εÏιÏÏ
ÏήÏ",description:"Το αίÏημα διαγÏάÏηκε."}),_.invalidateQueries({queryKey:["health-cases"]})},onError:()=>{o({title:"ΣÏάλμα",description:"Îεν ήÏαν δÏ
ναÏή η διαγÏαÏή.",variant:"destructive"})}}),ie=s=>{const t={active:"bg-green-100 text-green-800",improved:"bg-blue-100 text-blue-800",resolved:"bg-purple-100 text-purple-800",inactive:"bg-gray-100 text-gray-800"},l={active:"ÎνεÏγÏ",improved:"ÎελÏίÏÏη",resolved:"ÎÏιλÏθηκε",inactive:"ÎνενεÏγÏ"};return e.jsx(xe,{className:t[s]||t.active,children:l[s]||s})},re=s=>{var t;return s.is_anonymous?"ÎνÏνÏ
μοÏ":(t=s.user)!=null&&t.first_name?s.user.first_name:"ÎÏÏÏοιÏοÏ"};return e.jsx(Le,{activeTab:"healthline",children:e.jsxs("div",{children:[e.jsx("div",{onClick:()=>X("/graduate-portal/program"),className:"mb-6 cursor-pointer rounded-xl bg-gradient-to-r from-emerald-50 to-teal-50 border border-emerald-200 p-4 flex items-center justify-between hover:shadow-md transition-all duration-200",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{className:"h-5 w-5 text-emerald-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-emerald-900 text-sm",children:"HealthLine ΣÏ
νάνÏηÏη â Îάθε 2η ÎεÏ
ÏÎÏα, 21:00"}),e.jsx("p",{className:"text-emerald-700 text-xs",children:"ÎείÏε Ïο ÏÏÏγÏαμμα και ÏÏ
νδεθείÏε ÏÏο Zoom â"})]})]})}),e.jsxs(u,{className:"mb-8 bg-gradient-to-br from-purple-50 to-pink-50 border-purple-200",children:[e.jsx(F,{children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(N,{className:"h-8 w-8 text-purple-600"}),e.jsxs("div",{children:[e.jsx($,{className:"text-2xl text-purple-900",children:"HealthLine"}),e.jsx(oe,{className:"text-purple-700",children:"Î¥ÏοÏÏηÏίξÏε και λάβεÏε Ï
ÏοÏÏήÏιξη αÏÏ Ïην κοινÏÏηÏα Silva"})]})]})}),e.jsxs(h,{children:[e.jsx("div",{className:"bg-white/80 backdrop-blur-sm rounded-lg p-4 mb-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(me,{className:"h-5 w-5 text-purple-600 mt-0.5"}),e.jsxs("div",{className:"text-sm text-gray-700",children:[e.jsx("p",{className:"font-semibold mb-1",children:"ÎÎ´Î·Î³Î¯ÎµÏ ÏÏήÏηÏ:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[e.jsx("li",{children:"Î¥ÏοβάλεÏε αιÏήμαÏα για θεÏαÏεÏ
Ïική Ï
ÏοÏÏήÏιξη"}),e.jsx("li",{children:"ÎιαÏηÏήÏÏε Ïην εμÏιÏÏεÏ
ÏικÏÏηÏα - ÏÏηÏιμοÏοιήÏÏε μÏνο Ïο μικÏÏ Ïνομα"}),e.jsx("li",{children:"ÎνημεÏÏνεÏε Ïην καÏάÏÏαÏη Ï
1Ïαν Ï
ÏάÏÏει ÏÏÏοδοÏ"}),e.jsx("li",{children:"ΠκοινÏÏηÏα θα ÏÏείλει θεÏική ενÎÏγεια και ÏÏοÏεÏ
ÏÎÏ"})]})]})]})}),!B&&e.jsxs(b,{onClick:()=>S(!0),className:"w-full bg-purple-600 hover:bg-purple-700",children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"ÎÎο ÎίÏημα Î¥ÏοÏÏήÏιξηÏ"]})]})]}),B&&e.jsxs(u,{className:"mb-8 border-purple-200",children:[e.jsx(F,{children:e.jsx($,{className:"text-xl",children:"ÎÎο ÎίÏημα Î¥ÏοÏÏήÏιξηÏ"})}),e.jsx(h,{children:e.jsxs("form",{onSubmit:s=>{s.preventDefault(),r.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"patientFirstName",children:"Îνομα ÎÏθενοÏÏ *"}),e.jsx(p,{id:"patientFirstName",value:D,onChange:s=>L(s.target.value),placeholder:"ÎÏνο Ïο μικÏÏ Ïνομα",disabled:r.isPending})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"lastNameInitial",children:"ÎÏÏÎ¹ÎºÏ ÎÏÏνÏμοÏ
*"}),e.jsx(p,{id:"lastNameInitial",value:P,onChange:s=>k(s.target.value.charAt(0)),placeholder:"Ï.Ï. Î ",maxLength:1,disabled:r.isPending})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"patientAge",children:"Îλικία *"}),e.jsx(p,{id:"patientAge",type:"number",value:w,onChange:s=>T(s.target.value),placeholder:"Ï.Ï. 45",min:1,max:150,disabled:r.isPending})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"patientLocation",children:"ΤοÏοθεÏία *"}),e.jsx(p,{id:"patientLocation",value:E,onChange:s=>q(s.target.value),placeholder:"Î Ïλη, ΧÏÏα",disabled:r.isPending})]})]}),e.jsxs("div",{children:[e.jsx(m,{htmlFor:"conditionDescription",children:"ΠεÏιγÏαÏή ÎαÏάÏÏαÏÎ·Ï *"}),e.jsx(pe,{id:"conditionDescription",value:H,onChange:s=>I(s.target.value),placeholder:"ΠεÏιγÏάÏÏε Ïην καÏάÏÏαÏη Ï
Î³ÎµÎ¯Î±Ï ÎºÎ±Î¹ Ïο αίÏημα Ï
ÏοÏÏήÏιξηÏ...",rows:4,disabled:r.isPending})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(je,{id:"isAnonymous",checked:Q,onCheckedChange:s=>K(s),disabled:r.isPending}),e.jsx(m,{htmlFor:"isAnonymous",className:"text-sm",children:"ÎνÏνÏ
μη Ï
Ïοβολή (Ïο Ïνομά ÏÎ±Ï Î´ÎµÎ½ θα εμÏανίζεÏαι)"})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(b,{type:"submit",disabled:r.isPending,className:"bg-purple-600 hover:bg-purple-700",children:r.isPending?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}),"Î¥Ïοβολή..."]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"Î¥Ïοβολή ÎιÏήμαÏοÏ"]})}),e.jsx(b,{type:"button",variant:"outline",onClick:()=>S(!1),disabled:r.isPending,children:"ÎκÏÏÏÏη"})]})]})})]}),e.jsx(u,{className:"mb-6",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative",children:[e.jsx(ge,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(p,{placeholder:"ÎναζήÏηÏη...",value:g,onChange:s=>se(s.target.value),className:"pl-10"})]})}),e.jsxs(O,{value:j,onValueChange:ee,children:[e.jsxs(U,{className:"w-full md:w-[200px]",children:[e.jsx(ve,{className:"mr-2 h-4 w-4"}),e.jsx(Z,{placeholder:"ÎαÏάÏÏαÏη"})]}),e.jsxs(W,{children:[e.jsx(d,{value:"all",children:"ÎÎ»ÎµÏ Î¿Î¹ καÏαÏÏάÏειÏ"}),e.jsx(d,{value:"active",children:"ÎνεÏγά"}),e.jsx(d,{value:"improved",children:"ÎελÏίÏÏη"}),e.jsx(d,{value:"resolved",children:"ÎÏιλÏ
μÎνα"}),e.jsx(d,{value:"inactive",children:"ÎνενεÏγά"})]})]})]})})}),te?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(G,{className:"h-8 w-8 animate-spin text-purple-600"})}):e.jsx("div",{className:"grid gap-4",children:A&&A.length>0?A.map(s=>e.jsxs(u,{className:"hover:shadow-lg transition-shadow",children:[e.jsx(F,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-lg",children:[s.patient_first_name,s.last_name_initial?` ${s.last_name_initial}.`:"",s.patient_age?`, ${s.patient_age} εÏÏν`:""," - ",s.patient_location]}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Î¥Ïοβλήθηκε αÏÏ: ",re(s)]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:Pe(new Date(s.created_at),{addSuffix:!0,locale:De})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[ie(s.status||"active"),((i==null?void 0:i.id)&&s.user_id===i.id||a&&s.submitter_email===a)&&e.jsxs(O,{value:s.status||"active",onValueChange:t=>ae.mutate({id:s.id,status:t}),children:[e.jsx(U,{className:"w-[120px] h-8",children:e.jsx(Z,{})}),e.jsxs(W,{children:[e.jsx(d,{value:"active",children:"ÎνεÏγÏ"}),e.jsx(d,{value:"improved",children:"ÎελÏίÏÏη"}),e.jsx(d,{value:"resolved",children:"ÎÏιλÏθηκε"}),e.jsx(d,{value:"inactive",children:"ÎνενεÏγÏ"})]})]}),((i==null?void 0:i.id)&&s.user_id===i.id||a&&s.submitter_email===a||Y)&&e.jsxs(be,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-800",disabled:V.isPending,children:e.jsx(fe,{className:"h-4 w-4"})})}),e.jsxs(ye,{children:[e.jsxs(_e,{children:[e.jsx(we,{children:"ÎιαγÏαÏή αιÏήμαÏοÏ;"}),e.jsx(Se,{children:"ΠενÎÏγεια αÏ
Ïή δεν μÏοÏεί να αναιÏεθεί. Το αίÏημα θα διαγÏαÏεί οÏιÏÏικά."})]}),e.jsxs(Ae,{children:[e.jsx(Fe,{children:"ÎκÏ
Ïο"}),e.jsx(Ce,{onClick:()=>V.mutate(s.id),className:"bg-red-600 hover:bg-red-700",children:"ÎιαγÏαÏή"})]})]})]})]})]})}),e.jsxs(h,{children:[e.jsx("p",{className:"text-gray-700 whitespace-pre-wrap",children:s.condition_description}),s.outcome_feedback&&e.jsxs("div",{className:"mt-4 p-3 bg-purple-50 rounded-lg",children:[e.jsx("p",{className:"text-sm font-semibold text-purple-900 mb-1",children:"ÎνημÎÏÏÏη:"}),e.jsx("p",{className:"text-sm text-purple-700",children:s.outcome_feedback})]})]})]},s.id)):e.jsx(u,{className:"text-center py-12",children:e.jsxs(h,{children:[e.jsx(N,{className:"mx-auto h-12 w-12 text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Îεν Ï
ÏάÏÏοÏ
ν αιÏήμαÏα Ï
ÏοÏÏήÏιξηÏ."}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Î¥ÏοβάλεÏε Ïο ÏÏÏÏο αίÏημα για να λάβεÏε Ï
ÏοÏÏήÏιξη αÏÏ Ïην κοινÏÏηÏα."})]})})})]})})};export{Be 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.