PageSourceSearch

https://xterns.ai/assets/AssessmentStage3-BYZgFBuW.js

js xterns.ai collected 2026-10-05 13:25:00 UTC 7,968 bytes, 1 lines download raw bytes

1import{f as X,bs as Z,u as ee,o as se,r as o,s as d,j as e,h as T,i as E,k as B,l as F,m as R,ad as v,n as $,e as D,J as ae,B as g,L as te,A as re,g as h}from"./index-DLd_kDlx.js";import{A as G,a as L}from"./alert-CyfKy7ls.js";import{a as q,d as I,e as Y,c as ne}from"./AssessmentUI-DW2eB-aa.js";import{B as w}from"./brain-pqum15ho.js";import{A as le}from"./arrow-left-BXtn7MCa.js";import{S as ce}from"./save-DnzFMk1L.js";function fe(){const{user:u}=X(),{assessmentStatus:c,updateAssessmentStage:O}=Z(),S=ee(),[U]=se(),l=U.get("retake"),[n,p]=o.useState([]),[y,m]=o.useState([]),[x,f]=o.useState([]),[N,C]=o.useState(!1),[j,_]=o.useState(!1),[k,b]=o.useState(!1);o.useEffect(()=>{l?z():H()},[c==null?void 0:c.id,l]);const z=async()=>{if(l)try{const{data:s,error:a}=await d.from("xtern_tech_assessments").select("assessment_id").eq("id",l).single();if(a)throw a;const{data:t,error:r}=await d.from("xtern_assessment_skills").select("*").eq("assessment_id",s.assessment_id).maybeSingle();if(r)throw r;if(t){p(t.selected_career_paths||[]);const i=t.skill_proficiencies||[];m(i);const Q=i.map(V=>V.name);f(Q)}}catch(s){console.error("Error loading retake data:",s)}},H=async()=>{if(c!=null&&c.id)try{const{data:s,error:a}=await d.from("xtern_assessment_skills").select("*").eq("assessment_id",c.id).maybeSingle();if(a)throw a;if(s){p(s.selected_career_paths||[]);const t=s.skill_proficiencies||[];m(t);const r=t.map(i=>i.name);f(r)}}catch(s){console.error("Error loading existing data:",s)}},J=(s,a)=>{const t=new Set(v.map(i=>i.id)),r=Array.from(new Set(n.filter(i=>t.has(i))));a?!r.includes(s)&&r.length<2&&p([...r,s]):(p(r.filter(i=>i!==s)),m([]),f([]))},A=async()=>{if(n.length!==0){C(!0);try{const{data:s,error:a}=await d.functions.invoke("generate-assessment-tech-stacks",{body:{careerPaths:n}});if(a)throw a;if(s!=null&&s.techStacks){const t=s.techStacks.map(r=>({name:typeof r=="string"?r:r.name,proficiency:0}));m(t)}}catch(s){console.error("Error generating tech stacks:",s),h.error("Failed to generate tech stacks")}finally{C(!1)}}},K=(s,a)=>{a?(f(t=>[...t,s]),m(t=>t.map(r=>r.name===s?{...r,proficiency:1}:r))):(f(t=>t.filter(r=>r!==s)),m(t=>t.map(r=>r.name===s?{...r,proficiency:0}:r)))},P=async()=>{if(!(u!=null&&u.id))return;let s;if(l){const{data:a,error:t}=await d.from("xtern_tech_assessments").select("assessment_id").eq("id",l).single();if(t)throw t;s=a.assessment_id}else s=c==null?void 0:c.id;if(s){b(!0);try{const a=y.filter(r=>x.includes(r.name)),{error:t}=await d.from("xtern_assessment_skills").upsert({assessment_id:s,selected_career_paths:n,skill_proficiencies:a},{onConflict:"assessment_id"});if(t)throw t;h.success("Progress saved successfully")}catch(a){console.error("Error saving data:",a),h.error("Failed to save progress")}finally{b(!1)}}},W=async()=>{if(n.length===0){h.error("Please select at least one professional role");return}_(!0);try{if(await P(),l)S(`/assessment/confirmation?retake=${l}`);else{await O(3,!0);const{error:s}=await d.rpc("sync_assessment_to_profile",{p_user_id:u.id});s&&console.error("Profile sync error:",s),h.success("Assessment stage completed successfully!"),S("/xtern/assessment-confirmation")}}catch(s){console.error("Error completing assessment:",s),h.error("Failed to complete assessment")}finally{_(!1)}},M=n.length>0&&x.length>0;return e.jsx("div",{className:"min-h-screen bg-gray-50 px-4 py-8 font-sans text-gray-950 sm:px-6 sm:py-12",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"mb-2 font-display text-3xl font-normal tracking-tight text-xterns-navy sm:text-4xl",children:l?"Update Skills Assessment":"Stage 3: Skills Assessment"}),e.jsx("p",{className:"text-base text-gray-500",children:l?"Update your professional roles and technical skills before retaking the assessment":"Select your professional roles and technical skills"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Stage 3 of 3"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Final Stage"})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-gray-200/70",children:e.jsx("div",{className:"h-2 w-full rounded-full bg-gradient-to-r from-xterns-blue to-xterns-teal transition-all duration-300"})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(T,{className:q,children:[e.jsxs(E,{children:[e.jsx(B,{children:"Professional Role Selection"}),e.jsx(F,{children:"Choose up to 2 professional roles that align with your interests and goals"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:v.map(s=>e.jsxs("div",{className:`${I} flex items-start space-x-3 p-4`,children:[e.jsx($,{id:s.id,checked:n.includes(s.id
1),onCheckedChange:a=>J(s.id,a===!0),disabled:!n.includes(s.id)&&n.length>=2}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:s.id,className:`cursor-pointer block font-medium ${!n.includes(s.id)&&n.length>=2?"text-muted-foreground":"text-foreground"}`,children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description})]})]},s.id))}),n.length===2&&e.jsxs(G,{className:"mt-4",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(L,{children:"You've selected the maximum of 2 professional roles. This will help us provide more targeted opportunities."})]}),n.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Selected Professional Roles:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(s=>{const a=v.find(t=>t.id===s);return e.jsx(ae,{variant:"secondary",children:a==null?void 0:a.name},s)})})]})]})]}),n.length>0&&e.jsxs(T,{className:q,children:[e.jsxs(E,{children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),"AI-Generated Tech Stacks"]}),e.jsx(F,{children:"Based on your selected career paths, we'll generate relevant technologies for you to evaluate"})]}),e.jsx(R,{children:y.length===0?e.jsxs(g,{onClick:A,disabled:N,className:"w-full",children:[e.jsx(w,{className:"w-4 h-4 mr-2"}),N?"Generating Tech Stacks...":"Generate Tech Stacks"]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select the technologies you're familiar with"}),e.jsxs(g,{variant:"outline",onClick:A,disabled:N,size:"sm",children:[e.jsx(w,{className:"w-4 h-4 mr-2"}),"Regenerate"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-foreground",children:"Select Technologies You Know"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:y.map(s=>e.jsxs("div",{className:`${I} flex items-center space-x-3 p-3`,children:[e.jsx($,{id:`tech-${s.name}`,checked:x.includes(s.name),onCheckedChange:a=>K(s.name,a)}),e.jsx("label",{htmlFor:`tech-${s.name}`,className:"flex-1 cursor-pointer font-medium text-foreground",children:s.name})]},s.name))}),x.length>0&&e.jsxs(G,{children:[e.jsx(D,{className:"h-4 w-4"}),e.jsxs(L,{children:["You've selected ",x.length," technologies."]})]})]})]})})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-3 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(te,{to:"/assessment/stage-2",children:e.jsxs(g,{variant:"outline",className:Y,disabled:j||k,children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Back"]})}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs(g,{variant:"outline",className:Y,onClick:P,disabled:j||k,children:[e.jsx(ce,{className:"mr-2 h-4 w-4"}),k?"Saving...":"Save Progress"]}),e.jsxs(g,{className:ne,onClick:W,disabled:!M||j||k,children:[j?"Completing...":l?"Continue to Assessment":"Proceed to Assessment",e.jsx(re,{className:"ml-2 h-4 w-4"})]})]})]})]})]})})}export{fe 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.