1import{j as e}from"./motion-DjGABStX.js";import{r as i,j as je}from"./react-vendor-BHrJ9XZd.js";import{s as w,ae as u,B as g,ad as ve,I as Ne}from"./index-BJvU1pXf.js";import{C as G,d as U,a as be,b as ye}from"./card-BofCVqIC.js";import{S as W,a as X,b as Q,c as Z,d as V}from"./select-D2e7SFHs.js";import{B as j}from"./badge-D702LoTh.js";import{aX as ce,aY as J,aZ as we,g as k,h as ee,E as F,G as _e,F as ke,at as Se,au as $,a7 as Ce,p as le,O as oe,X as Ee,T as Ae,Q as Me}from"./icons-DVToBswu.js";import{f as P}from"./date-cwXK75ha.js";import{a as Te}from"./transcriptSource-8GAC86iK.js";import{s as q}from"./untypedTables-h-Ou-SUK.js";import"./query-DbGnfXKt.js";import"./supabase-92svyh75.js";import"./index-DMYv7eXw.js";import"./index-DW8DErID.js";const me=["new","reviewed","invited","passed"],ae={new:"Yeni",reviewed:"İncelendi",invited:"Davet Edildi",passed:"Geçildi"},Le=["general","invite_sent","interview","decision"],de={general:"Genel",invite_sent:"Davet gönderildi",interview:"GörüÅme",decision:"Karar"},ue={awaiting_reply:"Yanıt bekleniyor",proposal_ready:"Taslak hazır",sent:"Gönderildi",cancelled:"İptal",needs_human:"Manuel inceleme"},se={awaiting_reply:"#B45309",proposal_ready:"#15803D",sent:"#1D4ED8",cancelled:"#6B7280",needs_human:"#B91C1C"};function De({app:t,selected:o,noteCount:p,proposalStatus:n,onSelect:v}){return e.jsx(G,{className:`cursor-pointer transition-colors ${o?"border-orange":"hover:border-muted-foreground/30"}`,onClick:v,children:e.jsxs(U,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:t.contact_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.contact_email})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx(j,{variant:t.status==="new"?"default":"secondary",className:t.status==="new"?"bg-orange text-background":"",children:ae[t.status]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",title:"Otomatik skor devre dıÅı â insan deÄerlendirmesi gerekli",children:"İnsan deÄerlendirmesi"}),p>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ce,{className:"w-3 h-3"})," ",p]}),n&&e.jsx("div",{className:"flex items-center gap-1 text-xs",style:{color:se[n]},title:`Mülakat: ${ue[n]}`,children:e.jsx(J,{className:"w-3 h-3"})})]})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:P(new Date(t.created_at),"dd MMM yyyy HH:mm")})]})})}const ze={K1:"K1 · İletiÅim ve sentez",K2:"K2 · AraÅtırma ve öÄrenme",K3:"K3 · Organizasyon ve sahiplenme",K4:"K4 · İŠbirliÄi ve geri bildirim",K5:"K5 · Mesleki muhakeme"},Be={covered:"Kanıt var",partially_covered:"Kısmi kanıt",not_covered:"Kanıt yok"},Pe={COMPLETED:"Tamamlandı",PARTIAL:"Kısmi",PAUSED:"Duraklatıldı",WITHDRAWN:"Aday geri çekildi",TECHNICAL_INTERRUPTION:"Teknik kesinti",PRIVACY_HOLD:"Mahremiyet beklemede"};function qe({conversationId:t}){var N,T,f,L,h;const[o,p]=i.useState("idle"),[n,v]=i.useState(null);return i.useEffect(()=>{if(!t){v(null),p("idle");return}let d=!0;return p("loading"),w.from("interview_reports").select("interview_status, submission_status, language, valid, validation_errors, human_review_required, role_level, created_at, report").eq("conversation_id",t).maybeSingle().then(({data:S,error:C})=>{if(d){if(C){p("error");return}v(S??null),p("done")}}),()=>{d=!1}},[t]),t?e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-semibold mb-2 flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4"}),"YapılandırılmıŠgörüÅme raporu"]}),o==="loading"&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"})," Rapor yükleniyorâ¦"]}),o==="error"&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(ee,{className:"w-3.5 h-3.5"})," Rapor okunamadı. Sayfayı yenileyip tekrar deneyin."]}),o==="done"&&!n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bu görüÅme için henüz yapılandırılmıŠrapor üretilmedi."}),o==="done"&&n&&e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{variant:"outline",children:Pe[n.interview_status]??n.interview_status}),e.jsx(j,{variant:"outline",children:n.language.toUpperCase()}),n.role_level&&e.jsx(j,{variant:"outline",children:n.role_level}),e.jsx(j,{variant:"secondary",children:"İnsan deÄerlendirmesi zorunlu"}),!n.valid&&e.jsx(j,{variant:"destructive",children:"DoÄrulanamadı"})]}),!n.valid&&e.jsx("p",{className:"text-xs text-destructive",children:"Rapor teknik doÄrulamadan geçemedi; içerik eksik olabilir. Kararlar yalnızca görüÅme dökümü üzerinden verilmelidir."}),e.jsx("div",{className:"space-y-2",children:(((N=n.report)==null?void 0:N.evidence)??[]).map(d=>e.jsxs("div",{className:"rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:ze[d.area]??d.area}),e.jsx(j,{variant:"outline",className:"text-[10px]",children:Be[d.coverage]??d.coverage})]}),d.quote?e.jsxs("blockquote",{className:"text-xs italic text-muted-foreground border-l-2 pl-2",children:["â",d.quote,"â"]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Adayın bu alanda beyanı yok."}),d.note&&e.jsx("p",{className:"text-xs mt-1",children:d.note})]},d.area))}),e.jsx(Y,{title:"ÃalıÅma koÅulu tercihleri",items:(T=n.report)==null?void 0:T.working_conditions}),e.jsx(Y,{title:"Adayın açıklama talepleri",items:(f=n.report)==null?void 0:f.clarifications}),e.jsx(Y,{title:"İnsan görüÅmesinde sorulacaklar",items:(L=n.report)==null?void 0:L.human_interview_questions}),e.jsx(Y,{title:"Sınırlar",items:(h=n.report)==null?void 0:h.limitations}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Bu rapor puan, sıralama veya öneri içermez; yalnızca adayın kendi ifadelerinden alınan kanıtları listeler."})]})]}):null}function Y({title:t,items:o}){return!o||o.length===0?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",children:t}),e.jsx("ul",{className:"list-disc pl-5 space-y-0.5 text-xs text-muted-foreground",children:o.map((p,n)=>e.jsx("li",{children:p}
1,n))})]})}function Ke({selected:t,onStatusChange:o,onProposalStatusChange:p,onNoteCountChange:n}){const[v,N]=i.useState([]),[T,f]=i.useState("loading"),[L,h]=i.useState(!1),[d,S]=i.useState("success"),[C,I]=i.useState(null),[E,A]=i.useState([]),[M,K]=i.useState(""),[O,R]=i.useState("general"),[r,c]=i.useState(!1),[a,b]=i.useState(null),[D,z]=i.useState(!1),[m,B]=i.useState(null);async function te(){if(f("loading"),N([]),h(!1),S("success"),!t.conversation_id){f("success");return}const{data:s,error:l}=await w.from("messages").select("role, content, created_at").eq("conversation_id",t.conversation_id).order("created_at",{ascending:!0});if(l){f("error");return}if(N(s??[]),f("success"),!(s!=null&&s.length)){S("loading");const{data:x,error:_}=await w.from("conversations").select("id").eq("id",t.conversation_id).maybeSingle();if(_){S("error"),h(!1);return}S("success"),h(!x)}}i.useEffect(()=>{I(null),A([]),K(""),R("general"),b(null),(async()=>{if(await te(),t.cv_file_path){const{data:x}=await w.storage.from("cv-uploads").createSignedUrl(t.cv_file_path,3600);I((x==null?void 0:x.signedUrl)??null)}const{data:s,error:l}=await q.from("talent_application_notes").select("*").eq("application_id",t.id).order("created_at",{ascending:!1});l&&u.error(l.message),A(s??[]),await H(t.id)})()},[t.id]);const y=Te({queryState:T,messageCount:v.length,snapshot:t.transcript,hasConversationId:!!t.conversation_id,conversationMissing:L,conversationProbeState:d});async function H(s){z(!0);const{data:l}=await q.from("interview_proposals").select("*").eq("application_id",s).order("created_at",{ascending:!1}).limit(1).maybeSingle();b(l??null),z(!1)}async function xe(s){const{error:l}=await w.from("talent_applications").update({status:s}).eq("id",t.id);if(l)return u.error(l.message);o(t.id,s),u.success("Durum güncellendi")}async function re(){var _;B("request");const{data:s,error:l}=await w.functions.invoke("send-availability-request",{body:{application_ids:[t.id]}});if(B(null),l)return u.error(l.message);const x=(_=s==null?void 0:s.results)==null?void 0:_[0];if(!(x!=null&&x.ok))return u.error((x==null?void 0:x.error)??"Mail gönderilemedi");u.success("Müsaitlik maili gönderildi"),p(t.id,"awaiting_reply"),await H(t.id)}async function pe(){B("poll");const{error:s}=await w.functions.invoke("poll-interview-replies",{body:{}});if(B(null),s)return u.error(s.message);u.success("Yanıtlar kontrol edildi"),await H(t.id)}async function ne(s){if(!a||s==="cancel"&&!confirm("Taslak mail ve takvim davetiyesi silinecek. Emin misin?"))return;B(s);const{error:l}=await w.functions.invoke("confirm-interview-proposal",{body:{proposal_id:a.id,action:s}});if(B(null),l)return u.error(l.message);u.success(s==="send"?"Davet gönderildi":"Taslak iptal edildi"),p(t.id,s==="send"?"sent":"cancelled"),await H(t.id)}async function he(){var ie;const s=M.trim();if(!s)return u.error("Not boÅ olamaz");if(s.length>5e3)return u.error("Not çok uzun (maks 5000)");c(!0);const{data:l}=await w.auth.getUser(),{data:x,error:_}=await q.from("talent_application_notes").insert({application_id:t.id,body:s,kind:O,author_id:((ie=l.user)==null?void 0:ie.id)??null}).select().single();if(c(!1),_)return u.error(_.message);A(fe=>[x,...fe]),n(t.id,1),K(""),R("general"),u.success("Not eklendi")}async function ge(s){if(!confirm("Bu notu silmek istediÄine emin misin?"))return;const{error:l}=await q.from("talent_application_notes").delete().eq("id",s);if(l)return u.error(l.message);A(x=>x.filter(_=>_.id!==s)),n(t.id,-1),u.success("Not silindi")}return e.jsxs(G,{children:[e.jsx(be,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:t.contact_name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-3.5 h-3.5"})," ",t.contact_email]}),t.contact_phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"w-3.5 h-3.5"})," ",t.contact_phone]})]})]}),e.jsxs(W,{value:t.status,onValueChange:s=>xe(s),children:[e.jsx(X,{className:"w-[150px] h-9",children:e.jsx(Q,{})}),e.jsx(Z,{children:me.map(s=>e.jsx(V,{value:s,children:ae[s]},s))})]})]})}),e.jsxs(U,{className:"space-y-6",children:[C&&e.jsxs("div",{className:"flex items-center justify-between p-3 border border-border rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ke,{className:"w-4 h-4 text-orange"}),e.jsx("span",{children:t.cv_file_name??"CV"})]}),e.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(g,{size:"sm",variant:"outline",children:[e.jsx(Se,{className:"w-3.5 h-3.5 mr-1"})," İndir"]})})]}),e.jsxs("div",{className:"p-3 border border-border rounded-md bg-muted/20 text-sm",children:[e.jsx("span",{className:"font-semibold",children:"İnsan deÄerlendirmesi gerekli"}),e.jsx("span",{className:"text-muted-foreground",children:" / Manual review required"}),e.jsx("p",{className:"mt-1 mb-0 text-xs text-muted-foreground",children:"Otomatik aday skoru, öneri ve AI kullanım tahmini devre dıÅı; baÅvuru yalnızca insan tarafından deÄerlendirilir."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold",children:"Sohbet DeÅifresi"}),e.jsxs("div",{className:"flex items-center gap-2",children:[y.label&&e.jsx(j,{variant:"outline",className:"text-[10px]",children:y.label}),y.retryable&&e.jsxs(g,{size:"sm",variant:"outline",className:"h-7",onClick:te,children:[e.jsx($,{className:"w-3.5 h-3.5 mr-1"})," Tekrar dene"]})]})]}),y.source==="loading"&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"})," Sohbet kaydı yükleniyorâ¦"]}),y.notice&&e.jsxs("p",{className:`text-xs mb-2 ${y.source==="error"?"text-destructive":"text-muted-foreground"}`,children:[y.source==="error"&&e.jsx(ee,{className:"inline w-3.5 h-3.5 mr-1 -mt-0.5"}),y.notice]}),y.source==="live"&&e.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto border border-border rounded-md p-3",children:v.map((s,l)=>e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-xs uppercase text-muted-foreground",children:s.role}),e.jsx("p",{className:"whitespace-pre-wrap",children:s.content})]},l))}),y.source==="snapshot"&&e.jsx("pre",{className:"max-h-[400px] overflow-y-auto border border-border rounded-md p-3 text-sm whitespace-pre-wrap font-sans bg-muted/20",children:t.transcript})]}),e.jsx(qe,{conversationId:t.conversation_id??null}),e.jsxs("div",{className:"p-4 border border-border rounded-md bg-muted/10 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 text-orange"}),"Mülakat Süreci",a&&e.jsx(j,{variant:"outline",style:{color:se[a.status],borderColor:se[a.status]},children:ue[a.status]})]}),a&&e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>H(t.id),disabled:D,className:"h-7","aria-label":"Yenile",children:e.jsx($,{className:`w-3.5 h-3.5 ${D?"animate-spin":""}`})})]}),D&&!a&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"})," Yükleniyorâ¦"]}),!D&&!a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Adaya müsaitlik maili göndererek mülakat süre
1cini baÅlat. Yanıtı geldiÄinde otomatik taslak oluÅturulur, son onayı sen verirsin."}),e.jsxs(g,{size:"sm",onClick:re,disabled:m==="request",className:"bg-orange text-background hover:bg-orange/90",children:[m==="request"?e.jsx(k,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(F,{className:"w-3.5 h-3.5 mr-1"}),"Mülakat İste"]})]}),a&&e.jsxs("div",{className:"space-y-3 text-sm",children:[a.status==="awaiting_reply"&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground",children:["Aday yanıtı bekleniyor.",a.last_checked_at&&e.jsxs(e.Fragment,{children:[" Son kontrol: ",P(new Date(a.last_checked_at),"dd MMM HH:mm")]})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:pe,disabled:m==="poll",children:[m==="poll"?e.jsx(k,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx($,{className:"w-3.5 h-3.5 mr-1"}),"Åimdi Kontrol Et"]})]}),a.status==="proposal_ready"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 bg-background rounded border border-border space-y-1.5",children:[a.proposed_start&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-orange"}),e.jsxs("span",{className:"font-medium",children:[P(new Date(a.proposed_start),"dd MMM yyyy, EEEE HH:mm"),a.proposed_end&&` â ${P(new Date(a.proposed_end),"HH:mm")}`]})]}),a.meet_link&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("a",{href:a.meet_link,target:"_blank",rel:"noopener noreferrer",className:"text-orange hover:underline truncate",children:a.meet_link})]}),e.jsx("p",{className:"text-xs text-muted-foreground italic pt-1",children:`Taslak mail Gmail'de hazır, takvim daveti tentatif. "Gönder" dediÄinde aday daveti alacak.`})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(g,{size:"sm",onClick:()=>ne("send"),disabled:m!==null,className:"bg-orange text-background hover:bg-orange/90",children:[m==="send"?e.jsx(k,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(le,{className:"w-3.5 h-3.5 mr-1"}),"Gönder"]}),a.draft_reply_message_id&&e.jsx("a",{href:"https://mail.google.com/mail/u/0/#drafts",target:"_blank",rel:"noopener noreferrer",children:e.jsxs(g,{size:"sm",variant:"outline",children:[e.jsx(oe,{className:"w-3.5 h-3.5 mr-1"})," Gmail'de Aç"]})}),e.jsxs(g,{size:"sm",variant:"ghost",onClick:()=>ne("cancel"),disabled:m!==null,className:"text-destructive hover:text-destructive",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 mr-1"})," İptal"]})]})]}),a.status==="needs_human"&&e.jsxs("div",{className:"p-3 bg-destructive/10 border border-destructive/30 rounded space-y-2",children:[e.jsxs("p",{className:"text-destructive font-medium flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"})," Manuel inceleme gerekli"]}),a.last_error&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.last_error}),a.thread_id&&e.jsx("a",{href:`https://mail.google.com/mail/u/0/#inbox/${a.thread_id}`,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(g,{size:"sm",variant:"outline",children:[e.jsx(oe,{className:"w-3.5 h-3.5 mr-1"})," Gmail'de Aç"]})})]}),a.status==="sent"&&e.jsxs("div",{className:"p-3 bg-background border border-border rounded space-y-1.5",children:[e.jsxs("p",{className:"text-sm flex items-center gap-2 text-green-700",children:[e.jsx(le,{className:"w-4 h-4"})," Davet gönderildi"]}),a.proposed_start&&e.jsx("p",{className:"text-xs text-muted-foreground",children:P(new Date(a.proposed_start),"dd MMM yyyy, EEEE HH:mm")}),a.meet_link&&e.jsx("a",{href:a.meet_link,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-orange hover:underline",children:a.meet_link})]}),a.status==="cancelled"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ãnceki süreç iptal edildi."}),e.jsxs(g,{size:"sm",onClick:re,disabled:m==="request",className:"bg-orange text-background hover:bg-orange/90",children:[m==="request"?e.jsx(k,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(F,{className:"w-3.5 h-3.5 mr-1"}),"Yeniden Mülakat İste"]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-orange"}),"İç Notlar (CRM)",E.length>0&&e.jsx(j,{variant:"secondary",children:E.length})]}),e.jsxs("div",{className:"space-y-2 mb-3 p-3 border border-border rounded-md",children:[e.jsx(ve,{placeholder:"Not yaz⦠(ör. davet maili gönderildi, görüÅme notları, karar)",value:M,onChange:s=>K(s.target.value),maxLength:5e3,rows:3}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{value:O,onValueChange:s=>R(s),children:[e.jsx(X,{className:"w-[180px] h-9",children:e.jsx(Q,{})}),e.jsx(Z,{children:Le.map(s=>e.jsx(V,{value:s,children:de[s]},s))})]}),e.jsx(g,{size:"sm",onClick:he,disabled:r||!M.trim(),className:"bg-orange text-background hover:bg-orange/90",children:r?e.jsx(k,{className:"w-3.5 h-3.5 animate-spin"}):"Ekle"}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:[M.length,"/5000"]})]})]}),E.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"Henüz not yok."}):e.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:E.map(s=>e.jsxs("div",{className:"p-3 border border-border rounded-md text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"outline",className:"text-xs",children:de[s.kind]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:P(new Date(s.created_at),"dd MMM yyyy HH:mm")}
1)]}),e.jsx(g,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",onClick:()=>ge(s.id),"aria-label":"Notu sil",children:e.jsx(Ae,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"whitespace-pre-wrap",children:s.body})]},s.id))})]})]})]})}function Je(){const[t]=je(),[o,p]=i.useState([]),[n,v]=i.useState(!0),[N,T]=i.useState("all"),[f,L]=i.useState(""),[h,d]=i.useState(null),[S,C]=i.useState({}),[I,E]=i.useState({});async function A(){v(!0);const{data:r,error:c}=await w.from("talent_applications").select("*").order("created_at",{ascending:!1});c&&u.error(c.message),p(r??[]),v(!1);const{data:a}=await q.from("talent_application_notes").select("application_id"),b={};(a??[]).forEach(m=>{b[m.application_id]=(b[m.application_id]??0)+1}),C(b);const{data:D}=await q.from("interview_proposals").select("application_id, status, created_at").order("created_at",{ascending:!1}),z={};(D??[]).forEach(m=>{m.application_id&&!z[m.application_id]&&(z[m.application_id]=m.status)}),E(z)}i.useEffect(()=>{A()},[]),i.useEffect(()=>{const r=t.get("id");if(!r||o.length===0)return;const c=o.find(a=>a.id===r);c&&(h==null?void 0:h.id)!==r&&d(c)},[o,t]);const M=i.useMemo(()=>o.filter(r=>{if(N!=="all"&&r.status!==N)return!1;if(f){const c=f.toLowerCase();return r.contact_name.toLowerCase().includes(c)||r.contact_email.toLowerCase().includes(c)}return!0}),[o,N,f]),K=(r,c)=>{p(a=>a.map(b=>b.id===r?{...b,status:c}:b)),d(a=>a&&a.id===r?{...a,status:c}:a)},O=(r,c)=>{E(a=>({...a,[r]:c}))},R=(r,c)=>{C(a=>({...a,[r]:Math.max(0,(a[r]??0)+c)}))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:"Yetenek BaÅvuruları"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"AI ön-görüÅme sonrası gelen baÅvurular"})]}),e.jsx(g,{variant:"outline",onClick:A,children:"Yenile"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Me,{className:"absolute left-2 top-2.5 w-4 h-4 text-muted-foreground"}),e.jsx(Ne,{className:"pl-8 h-9",placeholder:"Ara: isim, e-postaâ¦",value:f,onChange:r=>L(r.target.value)})]}),e.jsxs(W,{value:N,onValueChange:r=>T(r),children:[e.jsx(X,{className:"w-[180px] h-9",children:e.jsx(Q,{})}),e.jsxs(Z,{children:[e.jsx(V,{value:"all",children:"Tüm durumlar"}),me.map(r=>e.jsx(V,{value:r,children:ae[r]},r))]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6",children:[e.jsxs("div",{className:"lg:col-span-5 space-y-2",children:[n&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(k,{className:"w-4 h-4 animate-spin"})," Yükleniyorâ¦"]}),!n&&M.length===0&&e.jsx(G,{children:e.jsx(U,{className:"py-8 text-center text-muted-foreground",children:"BaÅvuru yok"})}),M.map(r=>e.jsx(De,{app:r,selected:(h==null?void 0:h.id)===r.id,noteCount:S[r.id]??0,proposalStatus:I[r.id],onSelect:()=>d(r)},r.id))]}),e.jsx("div",{className:"lg:col-span-7",children:h?e.jsx(Ke,{selected:h,onStatusChange:K,onProposalStatusChange:O,onNoteCountChange:R}):e.jsx(G,{children:e.jsx(U,{className:"py-12 text-center text-muted-foreground",children:"Detayı görmek için bir baÅvuru seçin"})})})]})]})}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.