PageSourceSearch

https://www.asgardhire.ai/assets/create-jd.lazy-ByB2l6T0.js

js asgardhire.ai collected 2026-10-02 01:11:46 UTC 23,220 bytes, 1 lines download raw bytes

1import{q as Re,aC as ge,r as t,ae as N,g4 as $,j as e,fV as Ie,m as U,aU as be,x as Se,ag as ve,T as ye,X as ke,l as Ne,h7 as je,h8 as we,h9 as Ee,a5 as Ae,ad as Fe,c as Ue,gw as Le,aD as Te,aS as _e,ak as Ge}from"./index-D4_zyxsV.js";import{C as Oe}from"./Confirmation-CxIQshnW.js";import{C as $e}from"./CreateTraits-LvVqRNLv.js";import{S as Pe}from"./step-indicator-BetfHOYi.js";import{F as Be}from"./FormLayout-4iFLysSL.js";const de=a=>a&&a.charAt(0).toUpperCase()+a.slice(1);function Ce({indicators:a,onChange:i,error:x,label:P="Behavioral Indicators",highlightedKeywords:O=[]}){const[b,l]=t.useState(""),d=t.useRef(null),[c,A]=t.useState(null),[F,C]=t.useState(""),R=t.useRef(null);t.useEffect(()=>{c!==null&&R.current?.focus()},[c]);const B=()=>{const u=b.trim();if(u&&!a.includes(u)){const v=[...a,u];i(v),l(""),d.current?.focus()}},Y=u=>{u.key==="Enter"&&(u.preventDefault(),B())},h=u=>{const v=a.filter((L,p)=>p!==u);i(v),c===u&&A(null)},w=()=>{if(c===null)return;const u=F.trim();let v=[...a];if(!u){h(c);return}const L=v.filter((K,E)=>E!==c).includes(u);!(v[c]===u)&&!L&&(v[c]=u,i(v)),A(null)},y=()=>A(null);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:P}),e.jsxs("div",{className:`flex flex-wrap gap-2 min-h-[38px] border transition focus-within:ring-2 ${x?"border-destructive ring-destructive/40":"border-input bg-card hover:shadow-sm"} p-2 rounded-md`,children:[a.filter(Boolean).map((u,v)=>{const L=O.includes(u);return c===v?e.jsx("input",{ref:R,value:F,onChange:p=>C(p.target.value),onBlur:w,onKeyDown:p=>{p.key==="Enter"?w():p.key==="Escape"&&y()},className:"px-2 h-8 text-sm rounded border border-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",style:{minWidth:120}},v):e.jsxs("span",{className:Se("flex items-center gap-2 rounded-sm px-3 py-1 cursor-pointer group shadow-md transition max-w-[90%]","border border-border bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground",L&&"bg-success/20 border-success text-success"),tabIndex:0,role:"button",onClick:()=>{C(u),A(v)},children:[e.jsx("span",{className:"text-xs",children:de(u)}),e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),h(v)},className:"ml-1 text-destructive hover:border-destructive border-transparent duration-200 border-2 rounded-sm opacity-70 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",children:e.jsx(ke,{className:"h-4 w-4"})})]},u)}),e.jsx("input",{ref:d,className:"flex-1 bg-transparent border-none focus:outline-none px-1 text-sm min-w-[110px] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",placeholder:"Press Enter to add...",value:b,onChange:u=>l(u.target.value),onKeyDown:Y}),e.jsx(U,{type:"button",className:"px-2 bg-primary h-6",onClick:B,disabled:!b.trim()||a.filter(Boolean).includes(b.trim()),children:"Add"})]}),typeof x=="string"&&e.jsx("span",{className:"text-destructive text-xs mt-1",children:x})]})}function Ke({jdId:a,initialReqJobId:i,initialCatJobId:x,onRequirementsReady:P,onReturnToForm:O,onUnsavedChangesChange:b,currentRequirementsData:l,currentCategoriesData:d,onDataChange:c,onRegenerate:A}){const F=Re(),C=ge(),R=i===void 0&&x===void 0,B=i==="ERROR"?"FAILED":i?"RUNNING":"PENDING",Y=x==="ERROR"?"FAILED":x?"RUNNING":"PENDING",[h,w]=t.useState({status:B,jobId:i==="ERROR"?void 0:i,errorMessage:i==="ERROR"?"Failed to start requirements job.":void 0}),[y,u]=t.useState({status:Y,jobId:x==="ERROR"?void 0:x,errorMessage:x==="ERROR"?"Failed to start category job.":void 0}),v=t.useRef(h),L=t.useRef(y),p=t.useRef(0);t.useEffect(()=>{v.current=h},[h]),t.useEffect(()=>{L.current=y},[y]);let K;R?K="RUNNING":B==="FAILED"||Y==="FAILED"?K="FAILED":B==="RUNNING"||Y==="RUNNING"?K="RUNNING":K="PENDING";const[E,S]=t.useState(K),[ue,re]=t.useState(void 0);t.useEffect(()=>{if(i!==h.jobId||x!==y.jobId){const s=i==="ERROR"?"FAILED":i?"RUNNING":"PENDING",r=x==="ERROR"?"FAILED":x?"RUNNING":"PENDING";w({status:s,jobId:i==="ERROR"?void 0:i,errorMessage:i==="ERROR"?"Failed to start requirements job.":void 0}),u({status:r,jobId:x==="ERROR"?void 0:x,errorMessage:x==="ERROR"?"Failed to start category job.":void 0}),(s==="RUNNING"||r==="RUNNING")&&(S("RUNNING"),re(void 0))}},[i,x]);const[W,X]=t.useState(null),[z,Q]=t.useState(null),[T,ce]=t.useState(!1),[H,ae]=t.useState([]),[_,oe]=t.useState(!1),[Z,ne]=t.useState(""),[V,ee]=t.useState("");t.useEffect(()=>{E==="SUCCEEDED"&&l&&!W&&X(l),E==="SUCCEEDED"&&d&&!z&&Q(d)},[l,d,W,z,E]),t.useEffect(()=>{if(E!=="SUCCEEDED"||W===null||z===null){oe(!1),b&&b(!1);return}const s=JSON.stringify(l)!==JSON.stringify(W),r=JSON.stringify(d)!==JSON.stringify(z),n=s||r;oe(n),b&&b(n)},[l,d,W,z,b,E]);const[G,te]=t.useState(!1),le=async()=>{_&&!window.confirm("You have unsaved changes. Regenerating will discard them. Are you sure you want to proceed?")||(te(!0),X(null),Q(null),ae([]),S("RUNNING"),p.
1current=0,await A())},se=t.useCallback((s,r)=>{const n=new Set(s.filter(Boolean)),g=r.filter(Boolean).filter(o=>!n.has(o));g.length>0&&ae(o=>[...new Set([...o,...g])])},[]),me=t.useCallback(s=>{if(!window.confirm("Are you sure you want to delete this category section and all its keywords?"))return;const r=d;if(!r||!Array.isArray(r.categories))return;const n=r.categories.filter((o,f)=>f!==s),g={...r,categories:n};c(l,g),N.success("Category section deleted.")},[d,l,c]),fe=t.useCallback(s=>{if(!window.confirm(`Are you sure you want to delete the requirement group "${s}" and all its requirements?`))return;const r=l;if(!r||!Array.isArray(r.requirements))return;const n=r.requirements.filter(o=>o.requirement_type!==s),g={...r,requirements:n};c(g,d),N.success(`Requirement group "${s}" deleted.`)},[d,l,c]),m=t.useCallback((s,r)=>{const n=d;if(!n||!Array.isArray(n.categories))return;const o=n.categories[s]?.keywords?.filter(Boolean)||[];se(o,r);const f=n.categories.map((I,k)=>k===s?{...I,keywords:r.filter(Boolean)}:I),D={...n,categories:f};c(l,D)},[se,d,l,c]),j=t.useCallback(()=>{const s=Z.trim();if(!s){N.error("Category name cannot be empty.");return}const r=d||{categories:[]},n=r.categories||[];if(n.some(f=>f.category_name?.toLowerCase()===s.toLowerCase())){N.error(`Category "${s}" already exists.`);return}const o={...r,categories:[{category_name:s,keywords:[]},...n]};c(l,o),ne(""),N.success(`Category "${s}" added.`)},[Z,d,l,c]),M=t.useCallback((s,r)=>{const n=l;if(!n||!Array.isArray(n.requirements))return;const g=n.requirements.filter(k=>k.requirement_type===s).map(k=>k.requirement_text).filter(Boolean);se(g,r);const o=r.filter(Boolean).map(k=>({requirement_type:s,requirement_text:k})),f=[];let D=!1;for(const k of n.requirements)k.requirement_type===s?D||(f.push(...o),D=!0):f.push(k);D||f.push(...o);const I={...n,requirements:f};c(I,d)},[se,l,d,c]),q=t.useCallback(()=>{const s=V.trim();if(!s){N.error("Requirement type name cannot be empty.");return}const r=l||{requirements:[]},n=r.requirements||[];if(n.some(f=>f.requirement_type?.toLowerCase()===s.toLowerCase())){N.error(`Requirement type "${de(s)}" already exists.`);return}const g={requirement_type:s,requirement_text:""},o={...r,requirements:[...n,g]};c(o,d),ee(""),N.success(`Requirement type "${de(s)}" added.`)},[V,d,l,c]),J=t.useCallback(async()=>{ce(!0);let s=0,r=_;try{if(!r){N("No changes detected. Save action skipped.",{icon:"ℹ"});return}const n=d?.categories||[],g=l?.requirements||[];if(n.length>0){const o={categories:n};await $.put(`/jds/${a}/categories`,o,{headers:C}),s++}if(g.length>0){const o={requirements:g};await $.put(`/jds/${a}/requirements`,o,{headers:C}),s++}s>0?(N.success("Information saved successfully!"),X(l),Q(d),ae([])):N("No data to save. Save action skipped.",{icon:"ℹ"})}catch(n){console.error("Save failed:",n),N.error(`Failed to save: ${n instanceof Error?n.message:"Network error"}`)}finally{ce(!1),!R&&r&&s>0&&F({to:"/jd-list"})}},[a,C,l,d,_,R,F]),ie=t.useCallback(async()=>{try{const[s,r]=await Promise.all([$.get(`/jds/${a}/requirements`,{headers:C}),$.get(`/jds/${a}/categories`,{headers:C})]);c(s.data,r.data),S("SUCCEEDED"),te(!1),N.success("Final requirements and categories data fetched successfully!"),P()}catch(s){console.error("Failed to fetch final data:",s),S("FAILED"),re("Extraction jobs succeeded, but failed to fetch final data."),te(!1),N.error("Failed to load final data.")}},[a,C,P,c]);t.useEffect(()=>{R&&a&&!l&&!d&&ie()},[a]),t.useEffect(()=>{if(R){l&&d&&S("SUCCEEDED");return}G&&(h.status==="SUCCEEDED"||h.status==="FAILED")&&(y.status==="SUCCEEDED"||y.status==="FAILED")&&(h.status==="FAILED"||y.status==="FAILED")&&te(!1),h.status==="FAILED"||y.status==="FAILED"?(re(h.errorMessage||y.errorMessage||"One or both extraction jobs failed."),S("FAILED")):h.status==="SUCCEEDED"&&y.status==="SUCCEEDED"?(E!=="SUCCEEDED"&&!l&&!d&&ie(),S("SUCCEEDED")):h.status==="RUNNING"||y.status==="RUNNING"?S("RUNNING"):(h.status==="PENDING"||y.status==="PENDING")&&S("PENDING")},[h,y,ie,R,l,d,E,G]);const pe=t.useCallback(async()=>{const s=v.current,r=L.current;if(s.status==="SUCCEEDED"&&r.status==="SUCCEEDED"||s.status==="FAILED"||r.status==="FAILED")return;const n=!!(s.jobId&&s.status!=="SUCCEEDED"&&s.status!=="FAILED"),g=!!(r.jobId&&r.status!=="SUCCEEDED"&&r.status!=="FAILED");if(!(!n&&!g))try{const o=[],f=[];n&&(o.push($.get(`/jds/${a}/requirements/status/${s.jobId}`,{headers:C}
1)),f.push(w)),g&&(o.push($.get(`/jds/${a}/categories/status/${r.jobId}`,{headers:C})),f.push(u)),(await Promise.all(o)).forEach((I,k)=>{const xe=I.data;f[k](qe=>({...qe,status:xe.status,errorMessage:xe.error_message}))}),p.current=0}catch(o){throw p.current+=1,p.current>=5&&(n&&w(f=>({...f,status:"FAILED",errorMessage:"Maximum retries reached. Network error during polling."})),g&&u(f=>({...f,status:"FAILED",errorMessage:"Maximum retries reached. Network error during polling."}))),o}},[a,C]);t.useEffect(()=>{let s=null;const r=2500,n=f=>{s=setTimeout(async()=>{try{await pe();const D=v.current,I=L.current;(D.jobId&&D.status==="RUNNING"||I.jobId&&I.status==="RUNNING")&&n(r)}catch{if(p.current>=3&&p.current<5){const I=Math.pow(2,p.current-2)*2500;n(I)}else p.current<5&&n(r)}},f)},g=h.status==="SUCCEEDED"||h.status==="FAILED",o=y.status==="SUCCEEDED"||y.status==="FAILED";return(h.jobId&&!g||y.jobId&&!o)&&n(r),()=>{s&&clearTimeout(s)}},[h.status,y.status,h.jobId,y.jobId,pe]);const De=()=>{const s=l?.requirements,r=Array.isArray(s)?s.reduce((g,o)=>{const f=o.requirement_type;return g[f]||(g[f]=[]),g[f].push(o.requirement_text),g},{}):{},n=R&&E!=="SUCCEEDED"&&E!=="FAILED";switch(E){case"PENDING":case"RUNNING":return e.jsxs("div",{className:"flex flex-col items-center justify-center p-12 border rounded-lg bg-muted/50 w-full max-w-5xl mx-auto min-h-[250px] space-y-4",children:[e.jsx(ye,{size:48,variant:"current",spin:!0,title:"",className:"text-primary mb-4"}),e.jsx("div",{className:"text-xl font-semibold text-foreground text-center mb-2",children:n&&!G?"Loading data...":"Generating categories and requirements..."})]});case"SUCCEEDED":const g=d?.categories||[];return e.jsxs("div",{className:"w-full mx-auto space-y-4",children:[R&&e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs(U,{onClick:le,disabled:G||T||_,className:"bg-destructive hover:bg-destructive/90",children:[e.jsx(be,{className:Se("w-4 h-4 mr-2",{"animate-spin":G})}),G?"Regenerating...":"Regenerate categories & requirements"]})}),e.jsxs("div",{className:"p-6 border-2 border-info/25 rounded-lg w-full bg-info/10 space-y-6",children:[e.jsxs("div",{className:"p-4 border border-primary/40 rounded-md w-full bg-card shadow-md",children:[e.jsx("h3",{className:"font-semibold text-base mb-2 border-b pb-2 text-muted-foreground",children:"Category"}),e.jsxs("div",{className:"flex gap-2 mb-4 p-2 border-b border-border",children:[e.jsx("input",{type:"text",placeholder:"New Category Name",value:Z,onChange:o=>ne(o.target.value),onKeyDown:o=>o.key==="Enter"&&j(),className:"flex-1 px-3 py-2 border rounded-md text-sm"}),e.jsx(U,{onClick:j,disabled:!Z.trim()||T||G,className:"bg-primary hover:bg-primary/90 h-9",children:"Add new category"})]}),g.length===0?e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"No categories found."}):e.jsx("div",{className:"space-y-4 mt-4",children:g.map((o,f)=>e.jsxs("div",{className:"border p-3 rounded-md bg-muted/50",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:o.category_name||`Category ${f+1}`}),e.jsx(U,{variant:"ghost",size:"sm",className:"text-destructive hover:bg-destructive/10 p-1",onClick:()=>me(f),children:e.jsx(ve,{className:"h-4 w-4"})})]}),e.jsx(Ce,{indicators:o.keywords?.filter(Boolean)??[],onChange:D=>m(f,D),label:"",highlightedKeywords:H})]},f))})]}),e.jsxs("div",{className:"p-4 border border-primary/40 rounded-md w-full bg-card shadow-md",children:[e.jsx("h3",{className:"font-semibold text-base mb-2 border-b pb-2 text-muted-foreground",children:"Requirements"}),e.jsxs("div",{className:"flex gap-2 mb-4 p-2 border-b border-border",children:[e.jsx("input",{type:"text",placeholder:"New Requirement Type",value:V,onChange:o=>ee(o.target.value),onKeyDown:o=>o.key==="Enter"&&q(),className:"flex-1 px-3 py-2 border rounded-md text-sm"}),e.jsx(U,{onClick:q,disabled:!V.trim()||T||G,className:"bg-primary hover:bg-primary/90 h-9",children:"Add new requirement type"})]}),Object.keys(r).length===0?e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"No requirements found."}
1):e.jsx("div",{className:"space-y-4 mt-4",children:Object.entries(r).map(([o,f],D)=>e.jsxs("div",{className:"border p-3 rounded-md bg-muted/50",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:de(o)}),e.jsx(U,{variant:"ghost",size:"sm",className:"text-destructive hover:bg-destructive/10 p-1",onClick:()=>fe(o),children:e.jsx(ve,{className:"h-4 w-4"})})]}),e.jsx(Ce,{indicators:f,onChange:I=>M(o,I),label:"",highlightedKeywords:H})]},D))})]})]}),e.jsx("div",{className:"flex justify-end p-4",children:e.jsx(U,{onClick:J,disabled:T||!_||G,className:"w-48 bg-success hover:bg-success/90",children:T?e.jsx(ye,{size:18,variant:"current",spin:!0,title:"",className:"mr-2"}):"Save"})})]});case"FAILED":return e.jsxs("div",{className:"flex flex-col items-center space-y-6 p-12 border-2 border-destructive/25 rounded-lg bg-destructive/10 w-full max-w-5xl mx-auto text-center",children:[e.jsx(Ie,{className:"h-12 w-12 text-destructive"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-xl font-semibold text-destructive",children:"Extraction Failed"}),e.jsx("p",{className:"text-sm text-destructive max-w-md mx-auto",children:ue||"One or both extraction jobs failed to provide suggestions."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-4",children:[e.jsxs(U,{onClick:le,variant:"outline",className:"border-destructive text-destructive hover:bg-destructive/10",children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(U,{onClick:()=>{c({requirements:[]},{categories:[]}),X({requirements:[]}),Q({categories:[]}),S("SUCCEEDED")}
1,className:"bg-foreground hover:bg-foreground/90 text-background",children:"Add Manually"}),e.jsx(U,{variant:"ghost",onClick:O,className:"text-muted-foreground",children:"Go Back to Form"})]})]})}};return e.jsx("div",{className:"py-10 w-full",children:De()})}const he=a=>a?a.map(i=>`${i.name}:${i.weight??0}`).sort().join(","):"",We=a=>a.reduce((i,x)=>i+(x.weight??0),0);function Me({isEditMode:a,initialState:i,orgId:x,onDirtyChange:P,step:O,onStepChange:b}){const l=ge(),d=Re(),[c,A]=t.useState({title:"",description:""}),[F,C]=t.useState({}),[R,B]=t.useState(!1),[Y,h]=t.useState(),[w,y]=t.useState(i?.traits??[]),[u,v]=t.useState(a?i?.jd_id:void 0),[L,p]=t.useState(void 0),[K,E]=t.useState(void 0),[S,ue]=t.useState(!1),[re,W]=t.useState(""),X=he(w),z=re!==X,[Q,T]=t.useState(null),[ce,H]=t.useState(null),ae=t.useCallback((m,j)=>{T(m),H(j)},[]),_=c.title!==(i?.title??"")||c.description!==(i?.description??"")||z;t.useEffect(()=>{P?.(_)},[_,P]);const oe=m=>{A(j=>({...j,[m.target.name]:m.target.value})),C(j=>({...j,[m.target.name]:""}))};function Z(){const m={};return c.title||(m.title="Title is required"),c.description||(m.description="Description is required"),m}const ne=async m=>{v(m);let j,M,q=!0;try{const J=`/jds/${m}/requirements/extract`;j=(await $.post(J,{},{headers:l})).data.job_id}catch(J){console.error("Failed to start requirement extraction:",J),N.error("Job details saved, but failed to start requirement extraction."),j="ERROR",q=!1}try{const J=`/jds/${m}/categories/suggest`;M=(await $.post(J,{},{headers:l})).data.job_id}catch(J){console.error("Failed to start category suggestion:",J),j!=="ERROR"&&N.error("Job details saved, but failed to start category suggestion."),M="ERROR",q=!1}return T(null),H(null),p(j),E(M),q},V=()=>{h(void 0),C({});const m=Z();if(Object.keys(m).length)return C(m),!1;if(!w||!w.length)return h("Please add at least one trait before submitting."),!1;if(w&&w.length>0){for(const q of w){if(!q.name||!q.name.trim())return h("All traits must have a name."),!1;if(!q.description||!q.description.trim())return h(`Trait "${q.name}" must have a description.`),!1}if(We(w)!==100)return h("Trait weights must sum to 100."),!1}return w.filter(M=>M.is_priority).length>2?(h("You can only set up to 2 traits as priority."),!1):!0},ee=async()=>{if(V()){B(!0);try{const m={title:c.title,description:c.description,traits:w};let j;a?(await $.put(`/jds/${i?.jd_id}`,m,{headers:l}),j=i?.jd_id,v(j),W(he(w)),N.success("Job Details Updated Successfully!"),te()):(j=(await $.post("/jds",m,{headers:l})).data.jd_id,N.success("Job Created Successfully! Starting extraction..."),await ne(j)&&b(2))}catch(m){h(m.response?.data?.message??"Something went wrong")}finally{B(!1)}}},G=()=>{V()&&ee()},te=t.useCallback(m=>{m?.preventDefault(),u?(a&&(p(void 0),E(void 0)),b(2)):N.error("The job must be created before reviewing requirements.")},[u,a,b]),le=async()=>{if(!u){N.error("Cannot regenerate: Job ID is missing.");return}await ne(u),N.success("Regeneration jobs started.")};t.useEffect(()=>{const m=()=>{(_||S)&&(window.confirm("You have unsaved changes. Are you sure you want to leave this page?")?d({to:"/jd-list"}):window.history.pushState(null,"",window.location.href))};return window.history.pushState(null,"",window.location.href),window.addEventListener("popstate",m),()=>{window.removeEventListener("popstate",m)}},[_,S,d]),t.useEffect(()=>{a?(A({title:i?.title??"",description:i?.description??""}),v(i?.jd_id),p(void 0),E(void 0),T(null),H(null),b(1),W(he(i?.traits))):(A({title:i?.title??"",description:i?.description??""}),v(void 0),p(void 0),E(void 0),T(null),H(null),b(1),W(""))},[i?.title,i?.description,i?.jd_id,a,i?.traits,b]);const se=m=>{if(m===1){if(S&&!window.confirm("You have unsaved changes in the categories/requirements. Are you sure you want to discard them and go back to the form?"))return;b(1)}else if(m===2&&u){if(_&&!window.confirm("You have unsaved changes in the job details. Are you sure you want to proceed to the next step without saving?")||!a&&!(L||K))return;b(2)}},me=()=>{a||(v(void 0),p(void 0),E(void 0)),T(null),H(null),b(1)},fe=m=>e.jsx("div",{className:"max-w-5xl mx-auto p-6 pt-0",children:e.jsx("div",{className:"relative",children:e.jsxs(Ne,{className:"animate-in fade-in slide-in-from-bottom-4 duration-500",children:[e.jsx(je,{children:e.jsx(we,{children:a?"Edit categories and requirements":"Processing Job Requirements"})}),e.jsx(Ee,{children:e.jsx(Ke,{orgId:x,jdId:m,initialReqJobId:L,initialCatJobId:K,onReturnToForm:me,onRequirementsReady:()=>{console.log("Requirements and Categories extraction succeeded and is ready for display.")},initialState:void 0,currentRequirementsData:Q,currentCategoriesData:ce,onDataChange:ae,onUnsavedChangesChange:ue,onRegenerate:le})})]})})});return e.jsxs("div",{className:"max-w-5xl mx-auto p-6",children:[e.jsx(Pe,{steps:[{number:1,title:"Job Details"},{number:2,title:a?"Categories & Requirements":"Job Processing Status"}],currentStep:O,onStepClick:se,clickableMode:"all"}),O===2&&u&&fe(u),O===1&&e.jsx("div",{className:"relative",children:e.jsxs(Ne,{className:`animate-in fade-in ${!a&&"slide-in-from-bottom-4"} duration-500`,children:[e.jsx(je,{children:e.jsx(we,{children:a?"Edit job":"Create new job"})}),e.jsxs(Ee,{children:[e.jsxs("form",{className:"space-y-4",children:[e.jsx("div",{className:"flex w-full gap-3",children:e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsxs("label",{className:"font-medium text-sm",children:["Title ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Ae,{placeholder:"Job Title",name:"title",value:c.title,onChange:oe,error:F.title,autoFocus:!0})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"font-medium text-sm",children:["Description ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Fe,{placeholder:"Describe the job (responsibilities, requirements, etc)",name:"description",value:c.description,onChange:oe,error:F.description,rows:8})]}),e.jsx($e,{setTraits:y,traits:w}),Y&&e.jsx("div",{className:"text-destructive text-sm mt-2",children:Y})]}),e.jsx("div",{className:"pt-2 mt-4 border-t flex justify-end gap-3",children:a&&u?e.jsx(e.Fragment,{children:z?e.jsx(e.Fragment,{children:a&&e.jsx(Oe,{title:"Trait Weight Distribution Changed",description:e.jsxs("div",{className:"text-sm pb-4",children:[e.jsx("div",{className:"mb-4",children:e.jsx("strong",{children:"The individual trait weights have been modified from the last saved version."})}),"Are you sure you want to update the job details with this new weight distribution?"]}),acceptBtnText:"Yes, Update Details",cancelBtnText:"Cancel",onConfirm:()=>{V()&&ee()},onCancel:()=>{},btnProps:{isLoading:R,disabled:R,className:"bg-warning hover:bg-warning min-w-[200px]"},children:"Review Weight Changes and continue"})}):e.jsx(e.Fragment,{children:e.jsx(U,{type:"button",onClick:G,className:"bg-success hover:bg-success/90 min-w-[200px]",disabled:R,children:"Update job details"})})}):e.jsx(U,{type:"button",onClick:ee,className:"w-full sm:w-72",isLoading:R,children:R?"Creating job...":"Create job"})})]})]})})]})}function Je(){const a=ge(),i=Le(),[x,P]=t.useState(!1),[O,b]=t.useState(1),l=i.get("jd"),d=!!l,c=Te({queryKey:["jd"+l],queryFn:async()=>(await Ge.get("/jds/"+l,{headers:a})).data,staleTime:0,enabled:d}),A=F=>
1{if(O===2){F.preventDefault(),b(1);return}x&&(window.confirm("You have unsaved changes. Are you sure you want to go back?")||F.preventDefault())};return c.isLoading&&d?e.jsx(_e,{}):e.jsx(Be,{title:d?"Update Job":"Create new job",description:"Fill in all the details to create the job.",backLink:"/jd-list",onBackClick:A,children:e.jsx(Me,{isEditMode:d,initialState:c.data??[],orgId:c.data?.org_id??"",onDirtyChange:P,step:O,onStepChange:b})})}const Qe=Ue("/_admin/create-jd")({component:Je});export{Qe as Route};

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.