HR-ATS-Portal/frontend/dist/assets/Candidates-DDm6mZmg.js

3 lines
48 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{a1 as U,d as J,r as N,a as V,s as G,v as Fe,x as Pe,j as e,E,h as je,A as K,B as H,S as ke,W as Ie,I as x,p as ie,e as pe,q as Z,P as Re,g as Ee,i as Ne,T as Ce,a2 as $e,a3 as Me,Q as Be,w as De,Z as Le,a4 as ue,a5 as he,t as Oe,Y as qe,l as ze,y as Ve,z as We,a0 as ee,X as Ke}from"./index-BTPmxtwM.js";import{u as Ae}from"./useMutation-CMO99S-s.js";import{M as ne}from"./Modal-B8aWFZt2.js";import{u as He,P as Qe}from"./DataTable-D5imKbZq.js";import{T as Ue}from"./Tabs-DVZeUemd.js";import{l as Je}from"./jobPosts-CNShlpwX.js";function Ps({search:s,limit:l,offset:o}={}){return U("/candidate/fetch",{params:{search:s,limit:l,offset:o}})}function Ye(s){return U("/candidate/fetch",{params:{user_id:s}})}function Xe(s){return Array.isArray(s==null?void 0:s.data)?s.data:s!=null&&s.data?[s.data]:[]}function Ge(s,l){return U("/candidate/update",{method:"PATCH",params:{user_id:s},body:l})}function Ze({file:s,name:l,email:o,phone:c,jobPostId:m,company:p,source:v,experience:g,stage:f,referralBy:a}){const S=new FormData;S.append("file",s);const j=(n,_)=>{const y=_==null?"":String(_).trim();y&&S.append(n,y)};return j("candidate_email",o),j("candidate_name",l),j("candidate_phone",c),j("job_post_id",m),j("current_company",p),j("platform",v),j("experience",g),j("status",f),j("referral_by",a),U("/candidate/create/candidate",{method:"POST",body:S})}function es({userId:s,note:l}){return U("/notes/create",{method:"POST",body:{user_id:s,note:l}})}function ss({inboxId:s,date:l,time:o,type:c,status:m}){return U("/interview/create",{method:"POST",body:{inbox_id:s,interview_date:l,interview_time:o,interview_type:c,interview_status:m}})}function ts({inboxId:s,review:l,score:o,note:c}){return U("/feedback/create",{method:"POST",body:{inbox_id:s,review:l,score:o,note:c}})}function as({inboxId:s,type:l,status:o,description:c}){return U("/activity/create",{method:"POST",body:{inbox_id:s,activity_type:l,activity_status:o,description:c}})}const is=["Overview","Resume","Timeline","Interview","Notes","Activity","Documents","Feedback"],ae={fontSize:12,color:"var(--text-3)",fontWeight:600,textTransform:"uppercase",marginBottom:8},le=["Strong Hire","Hire","Lean Hire","No Hire"],re=["Phone Screen","Technical","System Design","Culture Fit","Final Round"],ce=["Scheduled","Completed","Cancelled","No Show"],oe=["Call","Email","Meeting","Screening","Assessment","Note"];function Q(s,l="—"){if(!s)return l;const o=s instanceof Date?s:new Date(s);return Number.isNaN(o.getTime())?String(s):ie(o)}function Te(s){if(!s)return null;const l=new Date(s);return Number.isNaN(l.getTime())?null:l.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function we(s){const l=s instanceof Date?s:new Date(s??NaN);return Number.isNaN(l.getTime())?0:l.getTime()}function ns(s,l){if(!s)return null;const o=new Date(`${s}T${l||"00:00"}`);return Number.isNaN(o.getTime())?null:o.toISOString()}function w({label:s,val:l}){return e.jsxs("div",{className:"info-item",children:[e.jsx("div",{className:"il",children:s}),e.jsx("div",{className:"iv",children:l===0||l?l:"—"})]})}function ls(s){return V({queryKey:Z.candidates.detail(s),queryFn:async()=>Xe(await Ye(s))[0]??null,enabled:!!s})}function se({userId:s,mutationFn:l,success:o,onDone:c}){const m=pe(),{toast:p}=J();return Ae({mutationFn:l,onSuccess:async(v,g)=>{await m.invalidateQueries({queryKey:Z.candidates.detail(s)}),p(typeof o=="function"?o(g):o,"success"),c==null||c()},onError:v=>p(je(v,"Could not save. Please try again."),"error")})}function rs({candidate:s,onClose:l,onAdvance:o,onToggleFav:c,onAtsMatch:m}){var h,A,M,B,L,T,D;const{toast:p}=J(),[v,g]=N.useState("Overview"),{data:f=[]}=V(G("interviews")),{data:a=[]}=V(G("recruiters")),S=!!s.userId,j=ls(s.userId),n=j.data??null,_=N.useMemo(()=>Fe(Pe),[]),y=f.filter(u=>u.candidateId===s.id),C=(n==null?void 0:n.inbox_id)??null,F=n?!!n.favorite:s.favorite,P=se({userId:s.userId,mutationFn:u=>Ge(s.userId,{favorite:u}),success:u=>u?`${s.name} added to favorites`:"Removed from favorites"}),$=(n==null?void 0:n.job_title)||s.currentTitle,O=(n==null?void 0:n.currentCompany)||s.currentCompany,k=n&&{Interview:((h=n.interviews)==null?void 0:h.length)??0,Notes:((A=n.notes)==null?void 0:A.length)??0,Activity:((M=n.activity)==null?void 0:M.length)??0,Documents:((B=n.documents)==null?void 0:B.length)??0,Feedback:((L=n.feedback)==null?void 0:L.length)??0},i=S?j.isPending?e.jsx(E,{icon:"refresh",title:"Loading candidate…",children:"Fetching the full record."}):j.isError?e.jsx(E,{icon:"alert",title:"Could not load this candidate",children:je(j.error,"Please try again.")}):n?null:e.jsx(E,{icon:"user",title:"No record found",children:"This candidate is no longer in the pipeline."}):null;return e.jsxs(ne,{title:"Candidate Profile",subtitle:s.id,size:"modal-lg",onClose:l,footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn-ghost star-btn${F?" on":""}`,style:{marginRight:"auto"},disabled:S&&(P.isPending||!n),onClick:()=>S?P.mutate(!F):c(s),children:[e.jsx(x,{name:"star"})," ",F?"Favorited":"Favorite"]}),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>m(s),children:[e.jsx(x,{name:"target"})," ATS Match"]}),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>p("Email drafted","info"),children:[e.jsx(x,{name:"mail"})," Message"]}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>{o(s),l()},children:[e.jsx(x,{name:"check"})," Advance Stage"]})]}),children:[e.jsxs("div",{className:"profile-hero",children:[e.jsx(K,{name:s.name,initials:s.initials,color:s.color,className:"avatar-lg"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{className:"ph-name",children:(n==null?void 0:n.name)||s.name}),e.jsx("div",{className:"ph-role",children:O?`${$} at ${O}`:$}),e.jsxs("div",{className:"ph-tags",children:[e.jsx(H,{children:s.stage})," ",e.jsx(H,{className:"b-gray",children:(n==null?void 0:n.source)||s.source}),e.jsxs("span",{className:"badge b-plain b-indigo badge-plain",children:[s.experience," yrs exp"]})]})]}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx(ke,{score:s.aiScore}),e.jsx("div",{className:"cell-sub",style:{marginTop:4},children:"AI Match"})]})]}),e.jsx("div",{style:{marginTop:22},children:e.jsx(Ue,{value:v,onChange:g,tabs:is.map(u=>({key:u,label:u,count:k?k[u]:void 0}))})}),e.jsxs("div",{className:"tab-pane active",children:[v==="Overview"&&(i||(n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"info-grid",style:{marginBottom:20},children:[e.jsx(w,{label:"Email",val:n.email}),e.jsx(w,{label:"Phone",val:n.phone}),e.jsx(w,{label:"Applied For",val:n.job_title}),e.jsx(w,{label:"Current Company",val:n.currentCompany}),e.jsx(w,{label:"Experience",val:n.experience}),e.jsx(w,{label:"Education",val:n.education}),e.jsx(w,{label:"Source",val:n.source}),e.jsx(w,{label:"Recruiter",val:n.recruiter}),e.jsx(w,{label:"Applied On",val:Q(n.applied)}),e.jsx(w,{label:"Screened On",val:Q(n.matched_at)}),e.jsx(w,{label:"Rating",val:`${(n.rating??0).toFixed(1)} / 5.0`}),e.jsx(w,{label:"Applications",val:((T=n.job_posts)==null?void 0:T.length)||0})]}),(n.match_summary||n.match_reasoning)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:ae,children:"AI Screening"}),e.jsx("div",{className:"card",style:{boxShadow:"none",background:"var(--bg-sunken)",marginBottom:18},children:e.jsxs("div",{className:"card-body",children:[n.match_summary&&e.jsx("p",{style:{marginBottom:n.match_reasoning?10:0},children:n.match_summary}),n.match_reasoning&&e.jsx("p",{className:"text-muted text-sm",children:n.match_reasoning})]})})]}),n.assigned_job_post&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:ae,children:"Assigned Role"}),e.jsx("div",{className:"k-tags",style:{marginBottom:14},children:e.jsx("span",{className:"tag",style:{background:"var(--primary-soft)",color:"var(--primary-fg)"},children:n.assigned_job_post.title})})]}),((D=n.job_posts)==null?void 0:D.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:ae,children:"Suggested Roles"}),e.jsx("div",{className:"k-tags",children:n.job_posts.map(u=>e.jsx("span",{className:"tag",children:u.title},u.id))})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"info-grid",style:{marginBottom:20},children:[e.jsx(w,{label:"Email",val:s.email}),e.jsx(w,{label:"Phone",val:s.phone}),e.jsx(w,{label:"Location",val:s.location}),e.jsx(w,{label:"Applied For",val:s.jobTitle}),e.jsx(w,{label:"Current Company",val:s.currentCompany}),e.jsx(w,{label:"Experience",val:`${s.experience} years`}),e.jsx(w,{label:"Education",val:s.education}),e.jsx(w,{label:"Source",val:s.source}),e.jsx(w,{label:"Recruiter",val:s.recruiter}),e.jsx(w,{label:"Applied On",val:Q(s.applied)}),e.jsx(w,{label:"Expected Salary",val:Ie(s.salary)}),e.jsx(w,{label:"Rating",val:`${s.rating} / 5.0`})]}),e.jsx("div",{style:ae,children:"Skills"}),e.jsx("div",{className:"k-tags",children:s.skills.map(u=>e.jsx("span",{className:"tag",children:u},u))})]}))),v==="Resume"&&(i||(n?e.jsx(cs,{live:n}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"card",style:{boxShadow:"none",background:"var(--bg-sunken)"},children:e.jsxs("div",{className:"card-body",children:[e.jsx("h3",{style:{marginBottom:4},children:s.name}),e.jsxs("p",{className:"text-muted",children:[s.currentTitle," · ",s.location]}),e.jsx("div",{className:"divider"}),e.jsx("div",{className:"form-section-title",style:{marginTop:0},children:"Summary"}),e.jsxs("p",{className:"text-muted",children:["Results-driven ",s.currentTitle.toLowerCase()," with ",s.experience," years of experience across ",s.department.toLowerCase(),". Passionate about building high-quality products and collaborating with cross-functional teams."]}),e.jsx("div",{className:"form-section-title",children:"Experience"}),e.jsxs("div",{className:"info-item",children:[e.jsxs("div",{className:"iv",children:[s.currentTitle," — ",s.currentCompany]}),e.jsx("div",{className:"il",style:{textTransform:"none"},children:"2021 Present"})]}),e.jsxs("div",{className:"info-item",style:{marginTop:10},children:[e.jsxs("div",{className:"iv",children:["Associate — ",_]}),e.jsx("div",{className:"il",style:{textTransform:"none"},children:"2018 2021"})]}),e.jsx("div",{className:"form-section-title",children:"Education"}),e.jsx("div",{className:"iv",children:s.education})]})}),e.jsxs("button",{className:"btn btn-secondary",style:{marginTop:14},onClick:()=>p("Downloading resume.pdf","info"),children:[e.jsx(x,{name:"download"})," Download PDF"]})]}))),v==="Timeline"&&(i||(n?e.jsx(os,{live:n}):e.jsx("div",{className:"timeline",children:[{icon:"user-plus",title:"Application received",meta:ie(s.applied),desc:`Applied via ${s.source}`},{icon:"star",title:"AI screening completed",meta:"1 day later",desc:`Match score: ${s.aiScore}%`},{icon:"phone",title:"Recruiter screen",meta:"3 days later",desc:`Call with ${s.recruiter}`},{icon:"calendar",title:"Technical interview",meta:"1 week later",desc:"Panel of 3 interviewers"},{icon:"check",title:`Moved to ${s.stage}`,meta:"Recently",desc:"Current stage in pipeline"}].map(u=>e.jsxs("div",{className:"tl-item",children:[e.jsx("div",{className:"tl-dot",children:e.jsx(x,{name:u.icon})}),e.jsx("div",{className:"tl-title",children:u.title}),e.jsx("div",{className:"tl-meta",children:u.meta}),e.jsx("div",{className:"tl-desc",children:u.desc})]},u.title))}))),v==="Interview"&&(i||(n?e.jsx(ds,{userId:s.userId,inboxId:C,rows:n.interviews??[]}):y.length?e.jsx("div",{className:"list-tight",children:y.map(u=>e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:"kpi-icn i-blue",style:{width:38,height:38,borderRadius:10},children:e.jsx(x,{name:"calendar"})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:u.type}),e.jsxs("div",{className:"lr-sub",children:[ie(u.when)," · ",u.meeting]})]}),e.jsx("div",{className:"lr-right",children:e.jsx(H,{children:u.status})})]},u.id))}):e.jsx(E,{icon:"calendar",title:"No interviews scheduled",children:"Schedule an interview to get started."}))),v==="Notes"&&(i||(n?e.jsx(ms,{userId:s.userId,rows:n.notes??[]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Add a note"}),e.jsx("textarea",{placeholder:"Write a private note about this candidate…"})]}),e.jsxs("button",{className:"btn btn-primary btn-sm",style:{margin:"10px 0 18px"},onClick:()=>p("Note saved","success"),children:[e.jsx(x,{name:"plus"})," Add Note"]}),e.jsxs("div",{className:"list-tight",children:[e.jsxs("div",{className:"list-row",children:[e.jsx(K,{name:s.recruiter}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:s.recruiter}),e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)"},children:"Strong communication skills, great culture fit. Recommend advancing."}),e.jsx("div",{className:"lr-sub",children:"2 days ago"})]})]}),e.jsxs("div",{className:"list-row",children:[e.jsx(K,{name:"Asfand Ahmed",initials:"AA"}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:"Asfand Ahmed"}),e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)"},children:"Reviewed portfolio — impressive work. Schedule technical round."}),e.jsx("div",{className:"lr-sub",children:"4 days ago"})]})]})]})]}))),v==="Activity"&&(i||(n?e.jsx(us,{userId:s.userId,inboxId:C,rows:n.activity??[]}):e.jsx("div",{className:"list-tight",children:[{icon:"eye",tone:"i-green",text:`Profile viewed by ${s.recruiter}`,when:"1h ago"},{icon:"mail",tone:"i-blue",text:"Email sent: Interview invitation",when:"1 day ago"},{icon:"star",tone:"i-amber",text:`Assessment score updated to ${s.aiScore}%`,when:"2 days ago"},{icon:"user-plus",tone:"i-purple",text:`Applied for ${s.jobTitle}`,when:ie(s.applied)}].map(u=>e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:`kpi-icn ${u.tone}`,style:{width:34,height:34,borderRadius:9},children:e.jsx(x,{name:u.icon})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)",fontSize:13},children:u.text}),e.jsx("div",{className:"lr-sub",children:u.when})]})]},u.text))}))),v==="Documents"&&(i||(n?e.jsx(hs,{rows:n.documents??[]}):e.jsx("div",{className:"list-tight",children:[{n:"Resume.pdf",s:"284 KB"},{n:"Cover_Letter.pdf",s:"112 KB"},{n:"Portfolio.pdf",s:"4.2 MB"},{n:"References.docx",s:"48 KB"}].map(u=>e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:"kpi-icn i-red",style:{width:38,height:38,borderRadius:10},children:e.jsx(x,{name:"file"})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:u.n}),e.jsx("div",{className:"lr-sub",children:u.s})]}),e.jsx("button",{className:"act-btn",onClick:()=>p(`Downloading ${u.n}`,"info"),children:e.jsx(x,{name:"download"})})]},u.n))}))),v==="Feedback"&&(i||(n?e.jsx(xs,{userId:s.userId,inboxId:C,rows:n.feedback??[]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"list-tight",children:["Strong Hire","Hire","Lean Hire"].map((u,Y)=>{const q=a[Y];if(!q)return null;const z=["Excellent technical depth and clear communication.","Good problem solving, would benefit from more system design exposure.","Solid candidate, positive team energy."];return e.jsxs("div",{className:"list-row",children:[e.jsx(K,{name:q.name,initials:q.initials,color:q.color}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:q.name}),e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)"},children:z[Y]})]}),e.jsx("div",{className:"lr-right",children:e.jsx(H,{children:u})})]},u)})}),e.jsxs("button",{className:"btn btn-primary btn-sm",style:{marginTop:14},onClick:()=>p("Scorecard form opened","info"),children:[e.jsx(x,{name:"plus"})," Submit Scorecard"]})]})))]})]})}function cs({live:s}){var o,c;const l=(c=(o=s.documents)==null?void 0:o[0])==null?void 0:c.name;return s.resume_text?e.jsx("div",{className:"card",style:{boxShadow:"none",background:"var(--bg-sunken)"},children:e.jsxs("div",{className:"card-body",children:[e.jsx("h3",{style:{marginBottom:4},children:s.name}),e.jsx("p",{className:"text-muted",children:l?`Extracted from ${l}`:"Extracted from the application email"}),e.jsx("div",{className:"divider"}),e.jsx("div",{className:"text-sm",style:{whiteSpace:"pre-wrap",lineHeight:1.6},children:s.resume_text})]})}):e.jsx(E,{icon:"file",title:"No résumé text",children:l?`${l} is attached but has not been parsed yet — run the match to extract it.`:"This candidate applied without an attachment we could read."})}function os({live:s}){const l=N.useMemo(()=>{const o=[];s.applied&&o.push({icon:"user-plus",title:"Application received",at:s.applied,desc:s.source?`Applied via ${s.source}`:null}),s.matched_at&&o.push({icon:"sparkles",title:"AI screening completed",at:s.matched_at,desc:s.match_error||s.match_summary||s.match_status});for(const c of s.interviews??[])o.push({icon:"calendar",title:c.interview_type||"Interview",at:c.interview_date,desc:c.interview_status});for(const c of s.activity??[])o.push({icon:"zap",title:c.activity_type||"Activity",at:c.activity_date,desc:c.description||c.activity_status});for(const c of s.feedback??[])o.push({icon:"star",title:c.review?`Feedback: ${c.review}`:"Feedback submitted",at:c.created_at,desc:c.reviewed_by_name?`by ${c.reviewed_by_name}`:c.note});return o.sort((c,m)=>we(c.at)-we(m.at))},[s]);return l.length?e.jsx("div",{className:"timeline",children:l.map((o,c)=>e.jsxs("div",{className:"tl-item",children:[e.jsx("div",{className:"tl-dot",children:e.jsx(x,{name:o.icon})}),e.jsx("div",{className:"tl-title",children:o.title}),e.jsx("div",{className:"tl-meta",children:Q(o.at)}),o.desc&&e.jsx("div",{className:"tl-desc",children:o.desc})]},`${o.title}-${c}`))}):e.jsx(E,{icon:"clock",title:"Nothing recorded yet",children:"Activity appears here as the candidate moves."})}function ds({userId:s,inboxId:l,rows:o}){const{toast:c}=J(),[m,p]=N.useState({type:re[0],date:"",time:"",status:ce[0]}),v=(a,S)=>p(j=>({...j,[a]:S})),g=se({userId:s,mutationFn:a=>ss({inboxId:l,date:a,time:a,type:m.type,status:m.status}),success:"Interview scheduled",onDone:()=>p({type:re[0],date:"",time:"",status:ce[0]})});function f(){const a=ns(m.date,m.time);if(!a){c("Pick a date for the interview","warning");return}g.mutate(a)}return e.jsxs(e.Fragment,{children:[o.length?e.jsx("div",{className:"list-tight",children:o.map(a=>{const S=Te(a.interview_time);return e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:"kpi-icn i-blue",style:{width:38,height:38,borderRadius:10},children:e.jsx(x,{name:"calendar"})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:a.interview_type||"Interview"}),e.jsxs("div",{className:"lr-sub",children:[Q(a.interview_date),S?` · ${S}`:""]})]}),e.jsx("div",{className:"lr-right",children:a.interview_status?e.jsx(H,{children:a.interview_status}):null})]},a.id)})}):e.jsx(E,{icon:"calendar",title:"No interviews scheduled",children:"Schedule the first round below."}),e.jsx("div",{className:"divider"}),e.jsx("div",{className:"form-section-title",style:{marginTop:0},children:"Schedule an interview"}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:m.type,onChange:a=>v("type",a.target.value),children:re.map(a=>e.jsx("option",{children:a},a))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Status"}),e.jsx("select",{value:m.status,onChange:a=>v("status",a.target.value),children:ce.map(a=>e.jsx("option",{children:a},a))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Date"}),e.jsx("input",{type:"date",value:m.date,onChange:a=>v("date",a.target.value)})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Time"}),e.jsx("input",{type:"time",value:m.time,onChange:a=>v("time",a.target.value)})]})]}),e.jsxs("button",{className:"btn btn-primary btn-sm",style:{marginTop:10},disabled:!l||g.isPending,onClick:f,children:[e.jsx(x,{name:"plus"})," ",g.isPending?"Scheduling…":"Schedule Interview"]})]})}function ms({userId:s,rows:l}){const[o,c]=N.useState(""),m=se({userId:s,mutationFn:()=>es({userId:s,note:o.trim()}),success:"Note saved",onDone:()=>c("")});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Add a note"}),e.jsx("textarea",{value:o,onChange:p=>c(p.target.value),placeholder:"Write a private note about this candidate…"})]}),e.jsxs("button",{className:"btn btn-primary btn-sm",style:{margin:"10px 0 18px"},disabled:!o.trim()||m.isPending,onClick:()=>m.mutate(),children:[e.jsx(x,{name:"plus"})," ",m.isPending?"Saving…":"Add Note"]}),l.length?e.jsx("div",{className:"list-tight",children:l.map(p=>e.jsxs("div",{className:"list-row",children:[e.jsx(K,{name:p.created_by_name||"Unknown"}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:p.created_by_name||"Unknown author"}),e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)"},children:p.note}),e.jsx("div",{className:"lr-sub",children:Q(p.created_at)})]})]},p.id))}):e.jsx(E,{icon:"edit",title:"No notes yet",children:"The first note on this candidate goes above."})]})}function us({userId:s,inboxId:l,rows:o}){const{toast:c}=J(),[m,p]=N.useState({type:oe[0],description:""}),v=(a,S)=>p(j=>({...j,[a]:S})),g=se({userId:s,mutationFn:()=>as({inboxId:l,type:m.type,status:"Logged",description:m.description.trim()}),success:"Activity logged",onDone:()=>p({type:oe[0],description:""})});function f(){if(!m.description.trim()){c("Describe what happened","warning");return}g.mutate()}return e.jsxs(e.Fragment,{children:[o.length?e.jsx("div",{className:"list-tight",children:o.map(a=>{const S=Te(a.activity_time);return e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:"kpi-icn i-purple",style:{width:34,height:34,borderRadius:9},children:e.jsx(x,{name:"zap"})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:a.activity_type||"Activity"}),a.description&&e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)",fontSize:13},children:a.description}),e.jsxs("div",{className:"lr-sub",children:[Q(a.activity_date),S?` · ${S}`:""]})]}),e.jsx("div",{className:"lr-right",children:a.activity_status?e.jsx(H,{children:a.activity_status}):null})]},a.id)})}):e.jsx(E,{icon:"zap",title:"No activity recorded",children:"Log the first touchpoint below."}),e.jsx("div",{className:"divider"}),e.jsx("div",{className:"form-section-title",style:{marginTop:0},children:"Log activity"}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:m.type,onChange:a=>v("type",a.target.value),children:oe.map(a=>e.jsx("option",{children:a},a))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"What happened"}),e.jsx("input",{value:m.description,onChange:a=>v("description",a.target.value),placeholder:"Called to confirm availability"})]})]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",style:{marginTop:10},disabled:!l||g.isPending,onClick:f,children:[e.jsx(x,{name:"plus"})," ",g.isPending?"Logging…":"Log Activity"]})]})}function hs({rows:s}){return s.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"list-tight",children:s.map((l,o)=>e.jsxs("div",{className:"list-row",children:[e.jsx("span",{className:"kpi-icn i-red",style:{width:38,height:38,borderRadius:10},children:e.jsx(x,{name:"file"})}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:l.name}),e.jsx("div",{className:"lr-sub",children:l.path||"Stored with the application"})]})]},`${l.name}-${o}`))}),e.jsxs("p",{className:"text-muted text-sm",style:{marginTop:12},children:[e.jsx(x,{name:"info"})," Attachments are stored server-side; download is not exposed yet."]})]}):e.jsx(E,{icon:"file",title:"No documents",children:"This application arrived without attachments."})}function xs({userId:s,inboxId:l,rows:o}){const{toast:c}=J(),[m,p]=N.useState({review:le[0],score:"",note:""}),v=(a,S)=>p(j=>({...j,[a]:S})),g=se({userId:s,mutationFn:()=>ts({inboxId:l,review:m.review,score:m.score===""?0:Number(m.score),note:m.note.trim()}),success:"Scorecard submitted",onDone:()=>p({review:le[0],score:"",note:""})});function f(){const a=m.score===""?0:Number(m.score);if(!Number.isFinite(a)||a<0||a>100){c("Score must be between 0 and 100","warning");return}g.mutate()}return e.jsxs(e.Fragment,{children:[o.length?e.jsx("div",{className:"list-tight",children:o.map(a=>e.jsxs("div",{className:"list-row",children:[e.jsx(K,{name:a.reviewed_by_name||"Unknown"}),e.jsxs("div",{className:"lr-main",children:[e.jsx("div",{className:"lr-title",children:a.reviewed_by_name||"Unknown reviewer"}),a.note&&e.jsx("div",{className:"lr-sub",style:{color:"var(--text-2)"},children:a.note}),e.jsxs("div",{className:"lr-sub",children:[Q(a.created_at),a.score?` · ${a.score}/100`:""]})]}),e.jsx("div",{className:"lr-right",children:a.review?e.jsx(H,{children:a.review}):null})]},a.id))}):e.jsx(E,{icon:"award",title:"No scorecards yet",children:"Be the first to review this candidate."}),e.jsx("div",{className:"divider"}),e.jsx("div",{className:"form-section-title",style:{marginTop:0},children:"Submit a scorecard"}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Recommendation"}),e.jsx("select",{value:m.review,onChange:a=>v("review",a.target.value),children:le.map(a=>e.jsx("option",{children:a},a))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Score (0100)"}),e.jsx("input",{type:"number",min:"0",max:"100",value:m.score,onChange:a=>v("score",a.target.value),placeholder:"80"})]})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Notes"}),e.jsx("textarea",{value:m.note,onChange:a=>v("note",a.target.value),placeholder:"What stood out, and what would you probe next round?"})]}),e.jsxs("button",{className:"btn btn-primary btn-sm",style:{marginTop:10},disabled:!l||g.isPending,onClick:f,children:[e.jsx(x,{name:"plus"})," ",g.isPending?"Submitting…":"Submit Scorecard"]})]})}const X=["Applied","Screening","Assessment","Interview","Offer","Hired"],js=["0-2","3-5","6-9","10+"],ps=["85+","70-84","<70"],vs=["Not Scheduled","Scheduled","Completed"],gs=["Immediate","2 weeks","1 month","2 months","3 months"],bs=["Immediate","2 weeks","1 month","Passive"],de=10,Se=100,xe="utopiabrands.com",fs=new RegExp(`^[a-z0-9][a-z0-9._%+-]*@${xe.replace(/\./g,"\\.")}$`,"i"),me=s=>(s||"").trim().toLowerCase(),ys={job:"",skill:"",dept:"",location:"",exp:"",edu:"",recruiter:"",manager:"",source:"",ats:"",stage:"",interview:"",notice:"",availability:""};function Ns(){const{toast:s}=J(),l=pe(),o=Re(),{data:c=[]}=V(G("candidates")),{data:m=[]}=V(G("recruiters")),{data:p=[]}=V(G("managers")),{data:v=[]}=V(G("jobs")),{data:g=[]}=V({queryKey:Z.seed.recentlyViewed(),queryFn:async()=>[],staleTime:1/0,gcTime:1/0}),f=Ee("candidates"),[a,S]=N.useState(""),[j,n]=N.useState(ys),[_,y]=N.useState(!1),[C,F]=N.useState("relevance"),[P,$]=N.useState(()=>new Set),[O,k]=N.useState(null),[i,h]=N.useState(null),[A,M]=N.useState(!1),[B,L]=N.useState(!1),T=N.useCallback(t=>{const d=(Ne(t.jobId)||{}).skills||[],r=d.length?t.matchedSkills.length/d.length:.5,b=1-Math.min(1,(Ce-t.applied)/(90*864e5));return Math.round(t.aiScore*.7+r*20+b*10)},[]),D=N.useCallback(t=>{k(t),l.setQueryData(Z.seed.recentlyViewed(),(d=[])=>{const r=[t.id,...d.filter(b=>b!==t.id)].slice(0,12);return $e("tf-recent",r),r})},[l]);N.useEffect(()=>{const t=o.state;if(t&&(t.openAdd&&M(!0),t.openCandidate)){const d=c.find(r=>r.id===t.openCandidate);d&&D(d)}},[o.state,c,D]);const u=N.useMemo(()=>[...new Set(c.map(t=>t.jobTitle))],[c]),Y=N.useMemo(()=>{const t=j;let d=c.filter(r=>{if(t.job&&r.jobTitle!==t.job||t.skill&&!r.skills.includes(t.skill)||t.dept&&r.department!==t.dept||t.location&&r.location!==t.location||t.exp==="0-2"&&r.experience>2||t.exp==="3-5"&&(r.experience<3||r.experience>5)||t.exp==="6-9"&&(r.experience<6||r.experience>9)||t.exp==="10+"&&r.experience<10||t.edu&&r.education!==t.edu||t.recruiter&&r.recruiter!==t.recruiter)return!1;if(t.manager){const b=Ne(r.jobId);if(!b||b.manager!==t.manager)return!1}if(t.source&&r.source!==t.source||t.ats==="85+"&&r.aiScore<85||t.ats==="70-84"&&(r.aiScore<70||r.aiScore>84)||t.ats==="<70"&&r.aiScore>=70||t.stage&&r.stage!==t.stage||t.interview&&r.interviewStatus!==t.interview||t.notice&&r.noticePeriod!==t.notice||t.availability&&r.availability!==t.availability)return!1;if(a){const b=a.toLowerCase();if(!(r.name+r.email+r.jobTitle+r.currentCompany+r.recruiter+r.skills.join(" ")).toLowerCase().includes(b))return!1}return!0});return C==="relevance"?d=[...d].sort((r,b)=>T(b)-T(r)):C==="ats"?d=[...d].sort((r,b)=>b.aiScore-r.aiScore):C==="recent"?d=[...d].sort((r,b)=>b.applied-r.applied):C==="name"&&(d=[...d].sort((r,b)=>r.name.localeCompare(b.name))),d},[c,j,a,C,T]),q=N.useMemo(()=>[{key:"_sel",label:""},{key:"name",label:"Candidate",sortable:!0},{key:"jobTitle",label:"Applied Job",sortable:!0},{key:"experience",label:"Exp",sortable:!0,align:"center"},{key:"_rel",label:"Relevance",sortable:!0,align:"center",sortValue:T},{key:"stage",label:"Stage",sortable:!0},{key:"aiScore",label:"ATS",sortable:!0,align:"center"},{key:"availability",label:"Availability"},{key:"_a",label:"Actions",align:"right"}],[T]),z=He({columns:q,rows:Y,pageSize:10});function ve(t){$(d=>{const r=new Set(d);return r.has(t)?r.delete(t):r.add(t),r})}function ge(t){f(d=>d.map(r=>r.id===t.id?{...r,favorite:!r.favorite}:r)),k(d=>d&&d.id===t.id?{...d,favorite:!d.favorite}:d),s(t.favorite?"Removed from favorites":`${t.name} added to favorites`,"success")}function be(t){const d=X.indexOf(t.stage);if(d===-1||d>=X.length-1){s(`${t.name} cannot be advanced further`,"warning");return}const r=X[d+1];f(b=>b.map(W=>W.id===t.id?{...W,stage:r,status:r}:W)),s(`${t.name} moved to ${r}`,"success")}function te(t){const d=[...P];if(d.length){if(t==="email"){s(`Bulk email drafted to ${d.length} candidates`,"success"),$(new Set);return}if(t==="assign"){L(!0);return}t==="advance"&&(f(r=>r.map(b=>{if(!P.has(b.id))return b;const W=X.indexOf(b.stage);if(W===-1||W>=X.length-1)return b;const ye=X[W+1];return{...b,stage:ye,status:ye}})),s(`${d.length} candidates advanced`,"success")),t==="reject"&&(f(r=>r.map(b=>P.has(b.id)?{...b,stage:"Rejected",status:"Rejected"}:b)),s(`${d.length} candidates rejected`,"warning")),$(new Set)}}const fe=g.slice(0,6).map(t=>c.find(d=>d.id===t)).filter(Boolean),I=(t,d)=>n(r=>({...r,[t]:d}));return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"page-head",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Candidates"}),e.jsxs("p",{className:"page-sub",children:[Y.length," candidate",Y.length===1?"":"s"," · ranked by AI relevance"]})]}),e.jsxs("div",{className:"page-head-actions",children:[e.jsxs("button",{className:"btn btn-secondary",onClick:()=>s("Search saved","success"),children:[e.jsx(x,{name:"bookmark"})," Save Search"]}),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>s("Candidates exported","success"),children:[e.jsx(x,{name:"download"})," Export"]}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>M(!0),children:[e.jsx(x,{name:"plus"})," Add Candidate"]})]})]}),fe.length>0&&e.jsxs("div",{className:"flex items-center gap-8",style:{marginBottom:14,flexWrap:"wrap"},children:[e.jsx("span",{className:"text-muted text-sm fw-600",children:"Recently viewed:"}),fe.map(t=>e.jsxs("button",{className:"prompt-chip",style:{padding:"5px 10px"},onClick:()=>D(t),children:[e.jsx(K,{name:t.name,initials:t.initials,color:t.color})," ",t.name.split(" ")[0]]},t.id))]}),P.size>0&&e.jsxs("div",{className:"bulk-bar",style:{display:"flex"},children:[e.jsx("span",{className:"checkbox on",children:e.jsx(x,{name:"check"})}),e.jsxs("span",{className:"fw-600",children:[P.size," selected"]}),e.jsx("div",{style:{flex:1}}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>te("email"),children:[e.jsx(x,{name:"mail"})," Bulk Email"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>te("assign"),children:[e.jsx(x,{name:"users"})," Assign"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>te("advance"),children:[e.jsx(x,{name:"check"})," Advance"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>te("reject"),children:[e.jsx(x,{name:"x"})," Reject"]}),e.jsxs("button",{className:"btn btn-sm",onClick:()=>$(new Set),children:[e.jsx(x,{name:"x"})," Clear"]})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-body",style:{paddingBottom:0},children:[e.jsxs("div",{className:"toolbar",children:[e.jsxs("div",{className:"toolbar-search",children:[e.jsx(x,{name:"search"}),e.jsx("input",{value:a,onChange:t=>S(t.target.value),placeholder:"Search name, skill, company…"})]}),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>y(t=>!t),children:[e.jsx(x,{name:"filter"})," Filters"]}),e.jsx("div",{className:"spacer"}),e.jsx("label",{className:"text-muted text-sm",children:"Sort:"}),e.jsxs("select",{className:"select",value:C,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"relevance",children:"AI Relevance"}),e.jsx("option",{value:"ats",children:"ATS Score"}),e.jsx("option",{value:"recent",children:"Most Recent"}),e.jsx("option",{value:"name",children:"Name AZ"})]})]}),_&&e.jsxs("div",{className:"filter-panel",style:{display:"grid",padding:"16px 0",borderTop:"1px solid var(--border)",marginTop:12},children:[e.jsx(R,{label:"Job",value:j.job,onChange:t=>I("job",t),any:"Any Job",options:u}),e.jsx(R,{label:"Skill",value:j.skill,onChange:t=>I("skill",t),any:"Any Skill",options:Me}),e.jsx(R,{label:"Department",value:j.dept,onChange:t=>I("dept",t),any:"Any Dept",options:Be}),e.jsx(R,{label:"Location",value:j.location,onChange:t=>I("location",t),any:"Any Location",options:De}),e.jsx(R,{label:"Experience",value:j.exp,onChange:t=>I("exp",t),any:"Any Exp",options:js}),e.jsx(R,{label:"Education",value:j.edu,onChange:t=>I("edu",t),any:"Any",options:Le}),e.jsx(R,{label:"Recruiter",value:j.recruiter,onChange:t=>I("recruiter",t),any:"Any Recruiter",options:m.map(t=>t.name)}),e.jsx(R,{label:"Hiring Manager",value:j.manager,onChange:t=>I("manager",t),any:"Any Manager",options:p.map(t=>t.name)}),e.jsx(R,{label:"Source",value:j.source,onChange:t=>I("source",t),any:"Any Source",options:ue}),e.jsx(R,{label:"ATS Score",value:j.ats,onChange:t=>I("ats",t),any:"Any Score",options:ps}),e.jsx(R,{label:"Pipeline Stage",value:j.stage,onChange:t=>I("stage",t),any:"Any Stage",options:he}),e.jsx(R,{label:"Interview Status",value:j.interview,onChange:t=>I("interview",t),any:"Any",options:vs}),e.jsx(R,{label:"Notice Period",value:j.notice,onChange:t=>I("notice",t),any:"Any",options:gs}),e.jsx(R,{label:"Availability",value:j.availability,onChange:t=>I("availability",t),any:"Any",options:bs})]})]}),e.jsxs("div",{className:"dt",children:[e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{className:"data",children:[e.jsx("thead",{children:e.jsx("tr",{children:q.map(t=>{const d=z.sort.key===t.key,r=[t.sortable?"sortable":"",d?z.sort.dir===1?"sorted-asc":"sorted-desc":""].filter(Boolean).join(" ");return e.jsxs("th",{className:r,style:{textAlign:t.align||"left"},onClick:t.sortable?()=>z.toggleSort(t.key):void 0,children:[t.label,t.sortable&&e.jsx("span",{className:"sort-ind",children:d?z.sort.dir===1?"▲":"▼":"⇅"})]},t.key)})})}),e.jsx("tbody",{children:z.pageRows.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:q.length,children:e.jsx(E,{})})}):z.pageRows.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`checkbox ${P.has(t.id)?"on":""}`,onClick:()=>ve(t.id),role:"checkbox","aria-checked":P.has(t.id),tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),ve(t.id))},children:e.jsx(x,{name:"check"})})}),e.jsx("td",{children:e.jsxs("div",{className:"user-cell",children:[e.jsx(K,{name:t.name,initials:t.initials,color:t.color}),e.jsxs("div",{children:[e.jsxs("div",{className:"cell-primary",children:[t.name," ",t.favorite&&e.jsx("span",{className:"star-btn on",style:{display:"inline"},children:e.jsx(x,{name:"star"})})]}),e.jsxs("div",{className:"cell-sub",children:[t.currentTitle," · ",t.location]})]})]})}),e.jsxs("td",{children:[e.jsx("div",{className:"text-sm",children:t.jobTitle}),e.jsx("div",{className:"cell-sub",children:t.department})]}),e.jsxs("td",{style:{textAlign:"center"},children:[e.jsx("b",{children:t.experience}),"y"]}),e.jsx("td",{style:{textAlign:"center"},children:e.jsxs("span",{className:`badge ${Oe(t.recommendation)} badge-plain`,children:[T(t),"%"]})}),e.jsx("td",{children:e.jsx(H,{children:t.stage})}),e.jsx("td",{style:{textAlign:"center"},children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>h(t),children:e.jsx(ke,{score:t.aiScore})})}),e.jsxs("td",{children:[e.jsx("span",{className:"text-sm",children:t.availability}),e.jsxs("div",{className:"cell-sub",children:[t.noticePeriod," notice"]})]}),e.jsx("td",{style:{textAlign:"right"},children:e.jsxs("div",{className:"row-actions",children:[e.jsx("button",{className:`act-btn star-btn ${t.favorite?"on":""}`,"data-tip":"Favorite",onClick:()=>ge(t),children:e.jsx(x,{name:"star"})}),e.jsx("button",{className:"act-btn","data-tip":"ATS Match",onClick:()=>h(t),children:e.jsx(x,{name:"target"})}),e.jsx("button",{className:"act-btn","data-tip":"Profile",onClick:()=>D(t),children:e.jsx(x,{name:"eye"})}),e.jsx("button",{className:"act-btn","data-tip":"Advance",onClick:()=>be(t),children:e.jsx(x,{name:"check"})})]})})]},t.id))})]})}),e.jsx(Qe,{...z})]})]}),i&&e.jsx(_e,{candidate:i,onClose:()=>h(null),onProfile:t=>{h(null),D(t)}}),O&&e.jsx(rs,{candidate:c.find(t=>t.id===O.id)??O,onClose:()=>k(null),onAdvance:be,onToggleFav:ge,onAtsMatch:t=>{k(null),h(t)}}),B&&e.jsx(ws,{count:P.size,recruiters:m,onClose:()=>L(!1),onSave:t=>{f(d=>d.map(r=>P.has(r.id)?{...r,recruiter:t}:r)),L(!1),$(new Set),s("Recruiter assigned to selected candidates","success")}}),A&&e.jsx(Ss,{jobs:v,count:c.length,onClose:()=>M(!1),onSave:t=>{f(d=>[t,...d]),M(!1),s("Candidate added to pipeline","success")},onInvalid:()=>s("Please fix the highlighted fields","error")})]})}function R({label:s,value:l,onChange:o,any:c,options:m}){return e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:s}),e.jsxs("select",{value:l,onChange:p=>o(p.target.value),children:[e.jsx("option",{value:"",children:c}),m.map(p=>e.jsx("option",{children:p},p))]})]})}function _e({candidate:s,onClose:l,onProfile:o}){const c=s.subScores,m=s.recommendation==="Strong Match"?"recc-strong":s.recommendation==="Potential Match"?"recc-potential":"recc-weak",p=s.aiScore>=82?"var(--success)":s.aiScore>=65?"var(--warning)":"var(--danger)",v=({label:g,val:f})=>e.jsxs("div",{className:"flex items-center gap-12",style:{marginBottom:12},children:[e.jsx("span",{style:{width:110,fontSize:13},children:g}),e.jsx("div",{style:{flex:1},children:e.jsx(Ke,{pct:f})}),e.jsxs("b",{style:{width:42,textAlign:"right"},children:[f,"%"]})]});return e.jsxs(ne,{title:"ATS Match Analysis",subtitle:`${s.id} · ${s.jobTitle}`,size:"modal-lg",onClose:l,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:"Close"}),e.jsx("button",{className:"btn btn-primary",onClick:()=>o(s),children:"View Full Profile"})]}),children:[e.jsxs("div",{className:`recc-banner ${m}`,children:[e.jsx("span",{className:"recc-icn",children:e.jsx(x,{name:s.recommendation==="Weak Match"?"x-circle":"check-circle"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{className:"fw-600",style:{fontSize:15},children:s.recommendation}),e.jsxs("div",{style:{opacity:.85,fontSize:13},children:[s.name," for ",s.jobTitle]})]})]}),e.jsxs("div",{className:"grid g-2",style:{alignItems:"center",marginBottom:20},children:[e.jsx("div",{style:{textAlign:"center"},children:e.jsx("div",{className:"ats-ring",style:{"--pct":s.aiScore,"--c":p},children:e.jsxs("div",{className:"ats-val",children:[e.jsx("div",{className:"ats-num",children:s.aiScore}),e.jsx("div",{className:"ats-lbl",children:"ATS MATCH"})]})})}),e.jsxs("div",{children:[e.jsx(v,{label:"Skills",val:c.skills}),e.jsx(v,{label:"Experience",val:c.experience}),e.jsx(v,{label:"Education",val:c.education}),e.jsx(v,{label:"Keywords",val:c.keywords}),e.jsx(v,{label:"Location",val:c.location}),e.jsx(v,{label:"Salary",val:c.salary})]})]}),e.jsxs("div",{className:"form-section-title",style:{marginTop:0},children:["Matched Skills (",s.matchedSkills.length,")"]}),e.jsx("div",{className:"k-tags",style:{marginBottom:16},children:s.matchedSkills.length?s.matchedSkills.map(g=>e.jsxs("span",{className:"skill-pill skill-matched",children:[e.jsx(x,{name:"check"})," ",g]},g)):e.jsx("span",{className:"text-muted",children:"—"})}),e.jsxs("div",{className:"form-section-title",style:{marginTop:0},children:["Missing Skills (",s.missingSkills.length,")"]}),e.jsx("div",{className:"k-tags",children:s.missingSkills.length?s.missingSkills.map(g=>e.jsxs("span",{className:"skill-pill skill-missing",children:[e.jsx(x,{name:"x"})," ",g]},g)):e.jsx("span",{className:"text-muted",children:"None — full match"})}),e.jsx("div",{className:"divider"}),e.jsxs("p",{className:"text-muted text-sm",children:[e.jsx(x,{name:"sparkles"})," Score computed from JD keywords, resume parsing, experience, education, location and salary alignment. Connect an AI model to refine with semantic matching."]})]})}function ws({count:s,recruiters:l,onClose:o,onSave:c}){var v;const[m,p]=N.useState(((v=l[0])==null?void 0:v.name)??"");return e.jsx(ne,{title:"Bulk Assign Recruiter",subtitle:`${s} candidates`,onClose:o,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-secondary",onClick:o,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",onClick:()=>c(m),children:"Assign"})]}),children:e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Assign to"}),e.jsx("select",{value:m,onChange:g=>p(g.target.value),children:l.map(g=>e.jsx("option",{children:g.name},g.id))})]})})}function Ss({jobs:s,count:l,onClose:o,onSave:c,onInvalid:m}){const{toast:p}=J(),v=pe(),g=N.useRef(null),[f,a]=N.useState(null),[S,j]=N.useState(!1),n=V({queryKey:Z.jobPosts.list({top:Se}),queryFn:async()=>{const i=await Je({top:Se});return Array.isArray(i==null?void 0:i.data)?i.data:[]}}),_=n.data??[],y=qe({name:"",email:"",phone:"",job:"",experience:"3",company:"",source:ue[0],stage:he[0],referral:""}),C=y.values.job||(_[0]?String(_[0].id):""),F=Ae({mutationFn:i=>Ze(i),onError:i=>p(je(i,"Could not add the candidate."),"error"),onSuccess:i=>{v.invalidateQueries({queryKey:Z.candidates.all()}),c(P(i==null?void 0:i.data))}});function P(i){var D;const h=y.values,A=_.find(u=>String(u.id)===C),M=(A==null?void 0:A.title)||h.job||((D=s[0])==null?void 0:D.title)||"Unassigned",B=s.find(u=>u.title===M)||s[0]||{},L=B.skills??[],T=ze(55,95);return{id:`CAN-${5001+l}`,userId:(i==null?void 0:i.user_id)??null,manualUploadId:(i==null?void 0:i.id)??null,name:h.name,initials:We(h.name),color:Ve(h.name),email:h.email,phone:h.phone||"+1 (555) 000-0000",jobId:B.id,jobTitle:M,department:B.department,experience:Number(h.experience)||1,currentCompany:h.company||"—",currentTitle:M,location:B.location,stage:h.stage,status:h.stage,aiScore:T,source:h.source,referredBy:me(h.referral)||null,recruiter:B.recruiter,recruiterId:B.recruiterId,applied:new Date(Ce),education:"Bachelor's Degree",skills:L.slice(0,4),rating:"4.0",salary:12e4,matchedSkills:L.slice(0,3),missingSkills:L.slice(3),recommendation:T>=82?"Strong Match":T>=65?"Potential Match":"Weak Match",subScores:{skills:T,experience:80,education:80,keywords:T,location:100,salary:90},noticePeriod:"1 month",availability:"2 weeks",certifications:[],favorite:!1,interviewStatus:"Not Scheduled"}}function $(i){i&&(a(i),y.setErrors(h=>{if(!h.cv)return h;const A={...h};return delete A.cv,A}))}function O(){if(F.isPending)return;const i=y.values,h={};i.name.trim()||(h.name="Required"),/^\S+@\S+\.\S+$/.test(i.email)||(h.email="Valid email required"),_.length&&!C&&(h.job="Required"),f?/\.pdf$/i.test(f.name)?f.size>de*1024*1024&&(h.cv=`Keep the file under ${de} MB`):h.cv="Only PDF resumes can be parsed":h.cv="Attach the candidates CV";const A=me(i.referral);if(A&&!fs.test(A)&&(h.referral=`Must be a @${xe} address`),y.setErrors(h),Object.keys(h).length){m();return}F.mutate({file:f,name:i.name,email:i.email,phone:i.phone,jobPostId:C,company:i.company,source:i.source,experience:i.experience,stage:i.stage,referralBy:A})}const k=i=>({value:y.values[i],onChange:h=>y.setField(i,h.target.value)});return e.jsx(ne,{title:"Add Candidate",subtitle:"Manually add a candidate to the pipeline",onClose:o,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-secondary",onClick:o,disabled:F.isPending,children:"Cancel"}),e.jsxs("button",{className:"btn btn-primary",onClick:O,disabled:F.isPending,children:[e.jsx(x,{name:"check"})," ",F.isPending?"Adding…":"Add Candidate"]})]}),children:e.jsxs("form",{noValidate:!0,onSubmit:i=>{i.preventDefault(),O()},children:[e.jsxs("div",{className:"form-grid",children:[e.jsxs("div",{className:"form-field",children:[e.jsxs("label",{children:["Full Name ",e.jsx("span",{className:"req",children:"*"})]}),e.jsx("input",{...k("name"),className:y.errors.name?"err":"",placeholder:"Jane Doe"}),e.jsx(ee,{children:y.errors.name})]}),e.jsxs("div",{className:"form-field",children:[e.jsxs("label",{children:["Email ",e.jsx("span",{className:"req",children:"*"})]}),e.jsx("input",{type:"email",...k("email"),className:y.errors.email?"err":"",placeholder:"jane@email.com"}),e.jsx(ee,{children:y.errors.email})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Phone"}),e.jsx("input",{...k("phone"),placeholder:"+1 (555) 000-0000"})]}),e.jsxs("div",{className:"form-field",children:[e.jsxs("label",{children:["Applied Job ",e.jsx("span",{className:"req",children:"*"})]}),e.jsxs("select",{value:C,onChange:i=>y.setField("job",i.target.value),className:y.errors.job?"err":"",disabled:n.isPending||!_.length,children:[n.isPending&&e.jsx("option",{value:"",children:"Loading job posts…"}),!n.isPending&&!_.length&&e.jsx("option",{value:"",children:n.isError?"Could not load job posts":"No active job posts"}),_.map(i=>e.jsx("option",{value:String(i.id),children:i.title},i.id))]}),e.jsx(ee,{children:y.errors.job})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Experience (years)"}),e.jsx("input",{type:"number",...k("experience")})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Current Company"}),e.jsx("input",{...k("company"),placeholder:"Acme Inc."})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Source"}),e.jsx("select",{...k("source"),children:ue.map(i=>e.jsx("option",{children:i},i))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Stage"}),e.jsx("select",{...k("stage"),children:he.map(i=>e.jsx("option",{children:i},i))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{children:"Referral By"}),e.jsx("input",{type:"email",...k("referral"),onBlur:i=>y.setField("referral",me(i.target.value)),className:y.errors.referral?"err":"",placeholder:`name@${xe}`}),e.jsx(ee,{children:y.errors.referral})]})]}),e.jsxs("div",{className:"form-section-title",children:["CV / Resume ",e.jsx("span",{className:"req",style:{color:"var(--danger)"},children:"*"})]}),e.jsx("input",{ref:g,type:"file",accept:"application/pdf,.pdf",hidden:!0,onChange:i=>{var h;$((h=i.target.files)==null?void 0:h[0]),i.target.value=""}}),e.jsxs("div",{className:`dropzone${S?" drag":""}`,style:{padding:"22px 18px",cursor:F.isPending?"default":"pointer"},role:"button",tabIndex:0,onClick:()=>{var i;F.isPending||(i=g.current)==null||i.click()},onKeyDown:i=>{var h;(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),(h=g.current)==null||h.click())},onDragOver:i=>{i.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:i=>{var h;i.preventDefault(),j(!1),$((h=i.dataTransfer.files)==null?void 0:h[0])},children:[e.jsx("div",{className:"dz-icn",style:{width:44,height:44,borderRadius:13,marginBottom:10},children:e.jsx(x,{name:"upload"})}),e.jsx("h3",{style:{fontSize:15},children:"Drop the CV here or click to browse"}),e.jsxs("p",{className:"text-muted text-sm",children:["PDF only · text-based resumes · up to ",de," MB"]})]}),f&&e.jsxs("div",{className:"upload-row",children:[e.jsx("span",{className:"attach-icn",style:{width:34,height:34},children:e.jsx(x,{name:"file"})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{className:"fw-600 text-sm",children:f.name}),e.jsxs("div",{className:"cell-sub",children:[Math.max(1,Math.round(f.size/1024))," KB"]})]}),e.jsx("button",{type:"button",className:"act-btn","aria-label":"Remove file",disabled:F.isPending,onClick:()=>a(null),children:e.jsx(x,{name:"trash"})})]}),e.jsx(ee,{children:y.errors.cv})]})})}const Is=Object.freeze(Object.defineProperty({__proto__:null,AtsMatch:_e,default:Ns},Symbol.toStringTag,{value:"Module"}));export{_e as A,rs as C,Is as a,Ps as l,Xe as t};
//# sourceMappingURL=Candidates-DDm6mZmg.js.map