1import{c as Ve,r as c,h as Ue,j as a,B as ee,i as Oe,fB as ke}from"./vendor-CPFPxuAM.js";import{M as We,f as Be,u as Je,T as qe,i as $e,V as He,R as Ke,C as Ge,U as Qe,j as Ye,l as Ze,y as V,m as ze,G as Xe,t as De,J as we,W as ve,L as es,p as ss}from"./index-hOS39ZS3.js";import{H as os}from"./HotIndicator-lLZg7vcp.js";import{u as as,dp as ts,f as ls,e as ns,bu as cs,aO as ps,T as se,R as S,aN as ms,an as U}from"./landing-pages-BJ63sDjk.js";import{N as ds}from"./NoJobsPage-DizQGaok.js";const hs=({onDashboardRefresh:R})=>{var X,D;const E=Ve(),{user:o}=as(),{mutate:O}=ts(o==null?void 0:o.role),[x,oe]=c.useState(!0),N=ls(),k=Ue(),[i,T]=c.useState(""),W=c.useMemo(()=>We.CONFIRMED_INTERVIEW,[]),B=c.useMemo(()=>Be.CONFIRMED_INTERVIEW,[]),y=Je(i,500),[g,J]=c.useState({}),[ae,te]=c.useState([]),[le,ne]=c.useState([]),[ce,pe]=c.useState([]),[I,j]=c.useState({pageNo:1,perPage:9}),[me,q]=c.useState(!1),[de,P]=c.useState(!1),[ue,re]=c.useState(""),[fe,ge]=c.useState(!1),[Ie,$]=c.useState(!1),[he,M]=c.useState(!1),[f,L]=c.useState(null),[H,Se]=c.useState({}),Ne=ns(),ye=cs(),be=ps(),K=c.useCallback(()=>{typeof R=="function"?R():window.dispatchEvent(new Event("ta-dashboard-refresh")),E.invalidateQueries({queryKey:se.INTERVIEWS.CONFIRMED}),E.invalidateQueries({queryKey:se.INTERVIEWS.PAST})},[R,E]),Ce=c.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const s={pageNo:I.pageNo,perPage:I.perPage,localTodayStart:e.toISOString()};return y!=null&&y.trim()&&(s.search=y.trim()),g.jobsRole&&(s.role=g.jobsRole),g.company&&(s.company=g.company),g.date&&(s.date=g.date),s},[y,g,I.pageNo,I.perPage]),{data:u,isLoading:A,error:G,refetch:_e}=qe(Ce,o==null?void 0:o.role),h=(u==null?void 0:u.applicants)||[],ie=((X=u==null?void 0:u.pagination)==null?void 0:X.totalPages)||1,je=((D=u==null?void 0:u.pagination)==null?void 0:D.totalRecords)||0;c.useEffect(()=>{if(u&&(u.allJobTitles&&te(u.allJobTitles),u.allOrgNames&&ne(u.allOrgNames),u.allReceivedOnDates)){const e=u.allReceivedOnDates.map(s=>new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}));pe(e)}},[u]),c.useEffect(()=>{let e=!0;return(async()=>{const n=[...new Set((h||[]).map(t=>{var l,d;return((l=t==null?void 0:t.applicant)==null?void 0:l.profileImageName)||((d=t==null?void 0:t.applicant)==null?void 0:d.displayPicName)}).filter(Boolean))];if(n.length===0)return;const r=await Promise.all(n.map(async t=>{const l=await es(t);return[t,l]}));e&&Se(t=>{const l={...t};return r.forEach(([d,p])=>{p&&(l[d]=p)}),l})})(),()=>{e=!1}},[h]);const Re=e=>{T(e.target.value),j(s=>({...s,pageNo:1}))},Ee=e=>{e.key==="Escape"&&i&&T("")},xe=e=>{j(s=>({...s,pageNo:e}))},Te=()=>a.jsxs("button",{className:"text-slate-600 px-4 text-sm py-1.5 rounded-md flex items-center gap-2 whitespace-nowrap hover:bg-opacity-90 transition-colors",onClick:()=>N(S.PAST_CONFIRMED_INTERVIEWS),children:[a.jsx(Oe,{icon:ke}),"Past Interviews"]}),Pe=e=>ss(e||"confirmed","sm"),Me=(h||[]).map(e=>{var t,l,d,p,m,b,C,_;const s=((t=e==null?void 0:e.status)==null?void 0:t.toLowerCase())||"";let n=s;s==="selected"?n="selected":s==="hired"||s==="started"?n="started":s==="offer extended"&&(n="offered");const r=H[((l=e==null?void 0:e.applicant)==null?void 0:l.profileImageName)||((d=e==null?void 0:e.applicant)==null?void 0:d.displayPicName)]||"";return{...e,applicant:{...e==null?void 0:e.applicant,profileImageUrl:r},id:(p=e==null?void 0:e.applicant)==null?void 0:p._id,applicant_name:((m=e==null?void 0:e.applicant)==null?void 0:m.fullname)||((b=e==null?void 0:e.applicant)==null?void 0:b.name),role:e==null?void 0:e.job_title,date_of_interview:((C=e==null?void 0:e.confirmedInterviewSlots)==null?void 0:C.dateSlot)||"N/A",postedByName:(e==null?void 0:e.postedByName)||"N/A",status:n,statusStyle:Pe(n),resume:(_=e==null?void 0:e.applicant)==null?void 0:_.resume,notes:e==null?void 0:e.notes,job_id:e==null?void 0:e.job_id,profileImageUrl:r,menuOptions:W,statusOptions:B}}),Le=()=>{T(""),J({}),j(e=>({...e,pageNo:1}))},Ae=e=>{j(s=>({...s,pageNo:1})),J(e)},Q=async(e,s)=>{var p,m;let n=e,r=s;e&&e.data&&e.newStatus&&(n=e.data,r=e.newStatus);const t=n.job_id,l=(p=n.applicant)==null?void 0:p._id,d=n.availDate||((m=n.confirmedInterviewSlots)==null?void 0:m.start_date)||new Date().toISOString();if(!t||!l){console.error("Missing required fields:",{job_id:t,applicantId:l}),U("Missing required fields for status update");return}Ne.mutate({job_id:t,applicantId:l,status:r,startDate:d,role:o==null?void 0:o.role},{onSuccess:()=>{O({entityType:"applicant",entityId:l}),K()}})},Y=async e=>
1{await V({resumeFileName:e,setLoadingResume:ge,setResumeUrl:re,setShowResumePopup:P,setIframeLoaded:$,user:o})},Z=async e=>{var n,r,t;if(!((n=e==null?void 0:e.applicant)!=null&&n._id)||!(e!=null&&e.job_id)){U("Missing interview details. Cannot join interview.");return}let s;(o==null?void 0:o.role)==="member"?s={roomInfo:{roomId:`interview_${e.job_id}_${e.applicant._id}`,interviewTime:((r=e.confirmedInterviewSlots)==null?void 0:r.start_date)||new Date().toISOString(),platform:"Zoom"}}:s={username:((o==null?void 0:o.fullname)||"Interviewer").replace(/\s+/g,"_").toLowerCase()||"interviewer",roomname:`Interview-Room-${e.job_id}-${e.applicant._id}`,customername:((t=e.applicant)==null?void 0:t.companyName)||"Company",customerkey:`key_${e.job_id}_${Date.now()}`},ye.mutate({payload:s,role:o==null?void 0:o.role},{onSuccess:l=>{var d;if(l){const p=(d=e.confirmedInterviewSlots)==null?void 0:d.meetingLink;p?window.open(p,"_blank","noopener,noreferrer"):console.log("Interview room info:",l.roomInfo)}}})},z=async e=>{L(e),M(!0)},Fe=async e=>{var s;if(!((s=f==null?void 0:f.applicant)!=null&&s._id)||!(f!=null&&f.job_id)){U("Missing interview details. Cannot cancel interview.");return}
1be.mutate({job_id:f.job_id,applicantId:f.applicant._id,status:"cancel",reason:e||"Interview has been cancelled by the employer.",role:o==null?void 0:o.role},{onSuccess:()=>{K(),M(!1),L(null)}})},F=()=>{P(!1),setTimeout(()=>{q(!0)},300)};return a.jsx(a.Fragment,{children:a.jsxs("div",{className:"p-4 lg:px-24 md:px-12 px-6 h-screen",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[k.pathname===S.TALENT_DASHBOARD&&a.jsx("h3",{className:"text-lg font-semibold",children:"Confirmed Interviews"}),a.jsx($e,{value:i,onChange:Re,onKeyDown:Ee,placeholder:"Search",className:"w-60",isLoading:A,ariaLabel:"Search"}),k.pathname===S.CONFIRMED_INTERVIEWS&&a.jsx(He,{isGridView:x,setIsGridView:oe})]}),a.jsx("div",{className:"mb-4",children:a.jsx(Ke,{type:"confirmedInterviews",onReset:Le,onFilter:Ae,endButton:a.jsx(Te,{}),jobsRole:ae,company:le,jobLocation:ce})}),a.jsx(Ge,{isGridView:x,loading:A,error:G,showErrorRetry:!0,containerClassName:"px-0",errorRetryAction:()=>_e(),isEmpty:h.length===0,emptyMessage:"No interviews found.",emptySubMessage:"There are no interviews to display at the moment.",customEmptyComponent:a.jsx(ds,{isResultEmpty:h.length===0&&i,navigate:N,title:"No Confirmed Interviews",description:"There are no confirmed interviews scheduled at this time. Schedule interviews to see them here.",showButton:!1,buttonText:"Schedule Interview",buttonPath:"/schedule-interview",emptyTitle:"No interviews found!",emptyDescription:"No interviews found matching your search"}),customLoadingComponent:a.jsx(ze,{isPaddingTrue:!1}),children:x?a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map((e,s)=>{var l,d;const n=((l=e==null?void 0:e.applicant)==null?void 0:l.profileImageName)||((d=e==null?void 0:e.applicant)==null?void 0:d.displayPicName),r={...e,applicant:{...e==null?void 0:e.applicant,profileImageUrl:H[n]||""}},t=Qe(r,{type:"confirmed interviews",statusOptions:B,menuOptions:W,onMenuSelect:(p,m)=>{var b,C,_,w;if(p.label==="View Resume"&&Y((b=m==null?void 0:m.applicant)==null?void 0:b.resumeFileName),p.label==="Reschedule"&&N(S.SCHEDULE_INTERVIEW,{state:{jobId:e==null?void 0:e.job_id,applicantId:(C=e==null?void 0:e.applicant)==null?void 0:C._id,fromConfirmedInterviews:!0}}),p.label==="Join"&&Z(m),p.label==="Cancel"&&z(m),p.label==="Download Resume"){const v=(_=m==null?void 0:m.applicant)==null?void 0:_.resumeFileName;if(!v)return ee.error("No resume found");V({resumeFileName:v,isDownload:!0,downloadFileName:`${(w=m==null?void 0:m.applicant)==null?void 0:w.fullname}_Resume.pdf`,user:o})}},onStatusChange:Q,onTitleClick:()=>{var p,m;(p=e==null?void 0:e.applicant)!=null&&p._id&&O({entityType:"applicant",entityId:e.applicant._id}),N(S.APPLICANT_DETAILS,{state:{applicantId:(m=e==null?void 0:e.applicant)==null?void 0:m._id,jobId:e==null?void 0:e.job_id,fromConfirmedInterviews:!0}})}});return a.jsxs("div",{className:"relative",children:[a.jsx(os,{show:e.isHot}),a.jsx(Ye,{...t})]},s)})}):a.jsx("div",{className:"bg-white shadow-sm p-4 rounded-lg border border-gray-200",children:a.jsx(Ze,{type:"confirmed interviews",data:Me,onTitleClick:e=>{var s;return N(S.APPLICANT_DETAILS,{state:{applicantId:(s=e==null?void 0:e.applicant)==null?void 0:s._id,jobId:e==null?void 0:e.job_id,fromConfirmedInterviews:!0}})},onMenuSelect:(e,s)=>{var n,r,t,l;if(e.label==="View Resume"&&Y((n=s==null?void 0:s.applicant)==null?void 0:n.resumeFileName),e.label==="Reschedule"&&N(S.SCHEDULE_INTERVIEW,{state:{jobId:s==null?void 0:s.job_id,applicantId:(r=s==null?void 0:s.applicant)==null?void 0:r._id,fromConfirmedInterviews:!0}}),e.label==="Join"&&Z(s),e.label==="Cancel"&&z(s),e.label==="Download Resume"){const d=(t=s==null?void 0:s.applicant)==null?void 0:t.resumeFileName;if(!d)return ee.error("No resume found");V({resumeFileName:d,isDownload:!0,downloadFileName:`${(l=s==null?void 0:s.applicant)==null?void 0:l.fullname}_Resume.pdf`,user:o})}},onStatusChange:Q})})}),!A&&h.length>0&&!G&&a.jsxs("div",{className:"mt-4 flex flex-col md:flex-row justify-between items-center",children:[a.jsx(Xe,{currentPage:I.pageNo,itemsPerPage:I.perPage,totalItems:je}),a.jsx(De,{currentPage:I.pageNo,totalPages:ie,onPageChange:xe})]}),a.jsx(ms,{showResumePopup:de,closeResumePopup:()=>P(!1),resumeUrl:ue,loadingResume:fe,iframeLoaded:Ie,handleIframeLoad:()=>$(!0),onConnect:(o==null?void 0:o.role)==="member"?()=>F():void 0,onShare:(o==null?void 0:o.role)==="member"?()=>F():void 0,onRequest:(o==null?void 0:o.role)==="member"?()=>F():void 0}),a.jsx(we,{open:me,onClose:()=>q(!1)}),a.jsx(ve,{open:he,onClose:()=>{M(!1),L(null)},onConfirm:Fe})]})})};export{hs 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.