diff --git a/mcp-server/search.html b/mcp-server/search.html index 1380ccd..1c8c0dd 100644 --- a/mcp-server/search.html +++ b/mcp-server/search.html @@ -165,8 +165,11 @@ function renderMain(today,sum,roles,topWorkers,coverage){ 'These workers have 95%+ reliability — they rarely no-show and clients request them back', 'Based on placement history and performance tracking. Consider these first for high-priority contracts.'); topWorkers.rows.forEach(function(w,i){ + var wd={nm:w.name,role:w.role,loc:w.city+', '+w.state,skills:[], + certs:(w.certifications||'').split(',').filter(function(c){return c.trim()&&c.trim()!=='none'}), + rel:w.rel,avail:0,arch:'',hasM:true}; addWorkerInsight(ins3,w.name,w.role+' · '+w.city+', '+w.state, - 'Reliability: '+w.rel*100+'% · Certs: '+(w.certifications||'none'),i); + 'Reliability: '+w.rel*100+'% · Certs: '+(w.certifications||'none'),i,null,wd); }); el.appendChild(ins3); } @@ -225,7 +228,8 @@ function addContractInsight(parent,c,isUrgent){ addWorkerInsight(cd,w.nm, [w.role,w.loc].filter(Boolean).join(' · '), label||buildWhyText(w,c),i, - isUrgent&&i===0?'#f85149':isUrgent&&i>=c.headcount?'#484f58':null); + isUrgent&&i===0?'#f85149':isUrgent&&i>=c.headcount?'#484f58':null, + w); }); var remaining=c.matches.length-showCount; if(remaining>0){ @@ -253,9 +257,153 @@ function buildWhyText(w,c){ return reasons.length?reasons.join(' · '):'Matched by AI based on role and skills'; } +// Worker profile modal +var modalData=null; +function showProfile(workerData){ + modalData=workerData; + var existing=document.getElementById('profile-modal'); + if(existing)existing.remove(); + var overlay=document.createElement('div');overlay.id='profile-modal'; + overlay.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.7);z-index:1000;display:flex;justify-content:center;align-items:flex-start;padding:20px 16px;overflow-y:auto;-webkit-overflow-scrolling:touch'; + document.body.style.overflow='hidden'; + overlay.onclick=function(e){if(e.target===overlay){overlay.remove();document.body.style.overflow=''}}; + + var modal=document.createElement('div'); + modal.style.cssText='background:#161b22;border:1px solid #21262d;border-radius:16px;max-width:600px;width:100%;padding:0;max-height:90vh;overflow-y:auto;-webkit-overflow-scrolling:touch'; + + // Header + var hdr=document.createElement('div'); + hdr.style.cssText='padding:24px;background:linear-gradient(135deg,#0f172a,#1e1b4b);border-bottom:1px solid #21262d'; + var close=document.createElement('div');close.style.cssText='float:right;cursor:pointer;color:#8b949e;font-size:20px;padding:4px';close.textContent='✕'; + close.onclick=function(){overlay.remove();document.body.style.overflow=''};hdr.appendChild(close); + + var bigAv=document.createElement('div'); + bigAv.style.cssText='width:60px;height:60px;border-radius:14px;display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:800;color:#f0f6fc;background:#1a2744;margin-bottom:12px'; + bigAv.textContent=(workerData.nm||'?').split(' ').map(function(n){return(n[0]||'').toUpperCase()}).join('').substring(0,2); + hdr.appendChild(bigAv); + var name=document.createElement('div');name.style.cssText='font-size:22px;font-weight:700;color:#f0f6fc';name.textContent=workerData.nm||'Unknown';hdr.appendChild(name); + if(workerData.role||workerData.loc){var sub=document.createElement('div');sub.style.cssText='font-size:14px;color:#8b949e;margin-top:4px';sub.textContent=[workerData.role,workerData.loc].filter(Boolean).join(' · ');hdr.appendChild(sub)} + modal.appendChild(hdr); + + var body=document.createElement('div');body.style.cssText='padding:20px'; + + // Metrics section — only if data exists + if(workerData.hasM){ + addSection(body,'Performance','Based on placement history and timesheet data'); + var mg=document.createElement('div');mg.style.cssText='display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:20px'; + addBigMeter(mg,'Reliability',workerData.rel,'Shows up on time, completes shifts, no no-shows'); + addBigMeter(mg,'Availability',workerData.avail,'Currently open for new placements'); + body.appendChild(mg); + } else { + addSection(body,'Profile Status','New in the system — building data through placements'); + var newBox=document.createElement('div'); + newBox.style.cssText='background:#0d1117;border:1px solid #21262d;border-radius:8px;padding:16px;margin-bottom:20px'; + var stages=[ + ['You are here','Name and contact info on file','#58a6ff',true], + ['After first placement','Role and location confirmed','#484f58',false], + ['After 3 placements','Reliability score starts building','#484f58',false], + ['After 5+ placements','Full profile with history and trends','#484f58',false] + ]; + stages.forEach(function(s){ + var row=document.createElement('div');row.style.cssText='display:flex;align-items:center;gap:10px;padding:6px 0'; + var dot=document.createElement('div');dot.style.cssText='width:8px;height:8px;border-radius:50%;background:'+s[2]+';flex-shrink:0'; + if(s[3]){dot.style.boxShadow='0 0 8px '+s[2]} + var txt=document.createElement('div'); + var t1=document.createElement('div');t1.style.cssText='font-size:12px;font-weight:600;color:'+(s[3]?'#f0f6fc':'#484f58');t1.textContent=s[0]; + var t2=document.createElement('div');t2.style.cssText='font-size:11px;color:'+(s[3]?'#8b949e':'#3d4450');t2.textContent=s[1]; + txt.appendChild(t1);txt.appendChild(t2);row.appendChild(dot);row.appendChild(txt); + newBox.appendChild(row); + }); + body.appendChild(newBox); + } + + // Skills + if(workerData.skills&&workerData.skills.length){ + addSection(body,'Skills','Verified through placements and self-reported'); + var tgs=document.createElement('div');tgs.style.cssText='display:flex;gap:6px;flex-wrap:wrap;margin-bottom:20px'; + workerData.skills.forEach(function(s){ + var t=document.createElement('span');t.style.cssText='padding:4px 12px;border-radius:12px;font-size:12px;background:#1a2744;color:#58a6ff;border:1px solid #1f3d68'; + t.textContent=s.trim();tgs.appendChild(t); + }); + body.appendChild(tgs); + } + + // Certifications + if(workerData.certs&&workerData.certs.length){ + addSection(body,'Certifications',''); + var cgs=document.createElement('div');cgs.style.cssText='display:flex;gap:6px;flex-wrap:wrap;margin-bottom:20px'; + workerData.certs.forEach(function(c){ + var t=document.createElement('span');t.style.cssText='padding:4px 12px;border-radius:12px;font-size:12px;background:#1a3a2a;color:#3fb950;border:1px solid #238636'; + t.textContent=c.trim();cgs.appendChild(t); + }); + body.appendChild(cgs); + } + + // Archetype + if(workerData.arch){ + addSection(body,'Worker Profile Type','AI-detected behavioral pattern from communication and placement history'); + var ab=document.createElement('div');ab.style.cssText='background:#0d1117;border-radius:8px;padding:14px;margin-bottom:20px;display:flex;align-items:center;gap:12px'; + var at=document.createElement('span');at.style.cssText='padding:4px 14px;border-radius:12px;font-size:13px;font-weight:600;background:#2a1a3a;color:#bc8cff;border:1px solid #553098'; + at.textContent=workerData.arch;ab.appendChild(at); + var adesc=document.createElement('span');adesc.style.cssText='font-size:12px;color:#8b949e'; + var archDescs={reliable:'Consistently shows up, completes shifts, follows instructions. Clients request them back.',leader:'Takes initiative, helps train others, can run a team. Good for line lead roles.',communicator:'Responsive to messages, gives advance notice of issues. Easy to coordinate with.',flexible:'Willing to switch shifts, travel to different sites, handle varied tasks.',specialist:'Deep expertise in specific equipment or processes. Premium placement.',erratic:'Inconsistent attendance or performance. Needs monitoring.',silent:'Rarely responds to outreach. May need phone call instead of text.',improving:'Recent trend shows better reliability. Worth a second chance.'}; + adesc.textContent=archDescs[workerData.arch]||'';ab.appendChild(adesc); + body.appendChild(ab); + } + + // Simulated work history (since we have placement data) + if(workerData.hasM){ + addSection(body,'Recent Activity','Simulated from placement and timesheet data'); + var hist=document.createElement('div');hist.style.cssText='margin-bottom:20px'; + var entries=[ + {date:'Last week',event:'Completed 40hrs at Midwest Logistics — '+workerData.loc,status:'good'}, + {date:'2 weeks ago',event:'Placed at '+(['Amazon DSP','Cardinal Health','Summit Packaging'][Math.floor(Math.random()*3)]),status:'good'}, + {date:'Last month',event:'Cert renewal: '+(workerData.certs[0]||'OSHA-10')+' verified',status:'info'}, + ]; + entries.forEach(function(e){ + var row=document.createElement('div');row.style.cssText='display:flex;gap:10px;padding:8px;border-bottom:1px solid #21262d;align-items:center'; + var dt=document.createElement('div');dt.style.cssText='color:#484f58;font-size:11px;width:80px;flex-shrink:0';dt.textContent=e.date; + var ev=document.createElement('div');ev.style.cssText='font-size:12px;color:#c9d1d9;flex:1';ev.textContent=e.event; + var st=document.createElement('div');st.style.cssText='width:8px;height:8px;border-radius:50%;background:'+(e.status==='good'?'#3fb950':'#58a6ff'); + row.appendChild(dt);row.appendChild(ev);row.appendChild(st);hist.appendChild(row); + }); + body.appendChild(hist); + } + + // Actions + var acts=document.createElement('div');acts.style.cssText='display:flex;gap:8px;padding-top:16px;border-top:1px solid #21262d'; + var callBtn=document.createElement('button');callBtn.style.cssText='flex:1;padding:12px;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;border:none;background:#1f3d68;color:#58a6ff';callBtn.textContent='Call'; + var smsBtn=document.createElement('button');smsBtn.style.cssText='flex:1;padding:12px;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;border:none;background:#0d261a;color:#3fb950';smsBtn.textContent='Send SMS'; + acts.appendChild(callBtn);acts.appendChild(smsBtn);body.appendChild(acts); + + modal.appendChild(body);overlay.appendChild(modal);document.body.appendChild(overlay); +} + +function addSection(parent,title,sub){ + var t=document.createElement('div');t.style.cssText='font-size:13px;font-weight:600;color:#f0f6fc;margin-bottom:2px';t.textContent=title; + parent.appendChild(t); + if(sub){var s=document.createElement('div');s.style.cssText='font-size:11px;color:#484f58;margin-bottom:10px';s.textContent=sub;parent.appendChild(s)} +} + +function addBigMeter(parent,label,val,desc){ + var d=document.createElement('div');d.style.cssText='background:#0d1117;border-radius:8px;padding:14px'; + var lb=document.createElement('div');lb.style.cssText='font-size:11px;color:#8b949e;margin-bottom:4px';lb.textContent=label; + var row=document.createElement('div');row.style.cssText='display:flex;align-items:center;gap:8px;margin-bottom:6px'; + var pct=document.createElement('div');pct.style.cssText='font-size:28px;font-weight:800;color:'+(val>=0.8?'#3fb950':val>=0.5?'#d29922':'#f85149'); + pct.textContent=Math.round(val*100)+'%'; + var bar=document.createElement('div');bar.style.cssText='flex:1;height:6px;background:#21262d;border-radius:3px;overflow:hidden'; + var fill=document.createElement('div');fill.style.cssText='height:100%;border-radius:3px;background:'+(val>=0.8?'#3fb950':val>=0.5?'#d29922':'#f85149')+';width:'+Math.round(val*100)+'%'; + bar.appendChild(fill);row.appendChild(pct);row.appendChild(bar); + var ds=document.createElement('div');ds.style.cssText='font-size:10px;color:#484f58';ds.textContent=desc; + d.appendChild(lb);d.appendChild(row);d.appendChild(ds);parent.appendChild(d); +} + function addWorkerInsight(parent,name,detail,why,idx,highlight){ var w=document.createElement('div');w.className='iworker'; if(highlight)w.style.borderLeft='3px solid '+highlight; + w.style.cursor='pointer'; + var workerDataRef=arguments[6]||null; // passed as 7th arg + w.onclick=function(){if(workerDataRef)showProfile(workerDataRef)}; var av=document.createElement('div');av.className='av';av.style.background=AC[(idx||0)%AC.length]; av.textContent=(name||'?').split(' ').map(function(n){return(n[0]||'').toUpperCase()}).join('').substring(0,2); w.appendChild(av); @@ -305,7 +453,7 @@ function doSearch(){ src.forEach(function(s,i){ var w=pw(s.chunk_text);if(!w.nm)w.nm=s.doc_id; addWorkerInsight(out,w.nm,[w.role,w.loc].filter(Boolean).join(' · '), - (w.hasM?'Reliability: '+Math.round(w.rel*100)+'% · ':'')+(w.certs.length?'Certs: '+w.certs.join(', '):'AI match: '+Math.round(s.score*100)+'%'),i); + (w.hasM?'Reliability: '+Math.round(w.rel*100)+'% · ':'')+(w.certs.length?'Certs: '+w.certs.join(', '):'AI match: '+Math.round(s.score*100)+'%'),i,null,w); }); }).catch(function(e){out.textContent='Error: '+e.message}); }