PageSourceSearch

https://rolefit.org/_next/static/chunks/app/(app)/response-writer/page-8a2c4d7117d484bd.js

js rolefit.org collected 2026-10-02 02:05:59 UTC 9,586 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7269],{18215:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var a=r(54568),s=r(7620),n=r(79748),o=r(64899),i=r(84282),l=r(52609),c=r(77240),u=r(70183);let d=["form","memory","generated"];function x(){let{getIdToken:e,rolefitPlus:t}=(0,o.A)(),r=(0,i.d)(),x=(0,n.useSearchParams)(),m=x.get("jobId"),h=x.get("question"),f=(0,s.useMemo)(()=>r?.jobs??[],[r?.jobs]),[p,b]=(0,s.useState)(""),[v,w]=(0,s.useState)(""),[y,j]=(0,s.useState)(!1),[g,N]=(0,s.useState)(null),[k,S]=(0,s.useState)(m),[C,T]=(0,s.useState)([]),[E,P]=(0,s.useState)(!1),{sectionChromeProps:q}=(0,l.zx)({allowedIds:d,ready:!0});(0,s.useEffect)(()=>{h&&b(h.slice(0,500).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,""))},[h]),(0,s.useEffect)(()=>{if(m&&f.length>0&&!k){let e=!1;return queueMicrotask(()=>{e||S(m)}),()=>{e=!0}}},[m,f,k]);let _=(0,s.useCallback)(async()=>{if(!p.trim())return void T([]);let t=await e();if(t)try{let e=await fetch(`/api/answers?question=${encodeURIComponent(p.trim())}`,{headers:{Authorization:`Bearer ${t}`}});if(e.ok){let t=await e.json();T(Array.isArray(t)?t:[])}else T([])}catch{T([])}},[p,e]);(0,s.useEffect)(()=>{let e=setTimeout(()=>_(),300);return()=>clearTimeout(e)},[p,_]);let A=(0,s.useCallback)(()=>{r?.refresh()},[r]),I=async()=>{j(!0),N(null);try{let t=await e(),r=await (0,c.Jp)("/api/response-writer",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({question:p.trim(),jobId:k||void 0})},e),a=await r.json();if(!r.ok)return void N(a.error??`Error ${r.status}`);w(a.response??"")}finally{j(!1)}},R=async()=>{if(p.trim()&&v.trim()){P(!0);try{let t=await e();if(!t)return;let r=await fetch("/api/answers",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({question:p.trim(),answer:v.trim(),jobId:k||void 0})});if(r.ok)N(null),_();else{let e=await r.json();N("eeo_questions_not_stored"===e.error?"Sensitive questions are not saved to memory.":e.error??"Failed to save")}}finally{P(!1)}}};return(0,a.jsxs)("div",{className:"max-w-2xl space-y-6",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-[var(--text)]",children:"✍️ AI Response Writer"}),(0,a.jsx)("p",{className:"text-[var(--text2)] text-sm",children:'Get AI-generated answers for application questions like "Why are you a good fit?" or "Tell us about yourself." Optionally select a job for context.'}),(0,a.jsxs)("div",{id:"form",className:"rounded-lg border border-[var(--border)] bg-[var(--surface2)] p-6 space-y-4 scroll-mt-20",children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-[var(--text)] cursor-pointer",...q("form"),children:"Question & context"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"question",className:"block text-sm font-medium text-[var(--text)] mb-2",children:"Application question"}),(0,a.jsx)("textarea",{id:"question",value:p,onChange:e=>b(e.target.value),placeholder:'e.g. "Why are you interested in this role?" or "Tell us about a time you led a project."',rows:3,className:"w-full px-4 py-2 rounded border border-[var(--border)] bg-[var(--surface)] text-[var(--text)] resize-y"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-[var(--text)] mb-2",children:"Job context (optional)"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("select",{value:k??"",onChange:e=>S(e.target.value||null),className:"flex-1 px-4 py-2 rounded border border-[var(--border)] bg-[var(--surface)] text-[var(--text)]",children:[(0,a.jsx)("option",{value:"",children:"No job selected"}),f.map(e=>(0,a.jsxs)("option",{value:e.id??"",children:[e.title??"Untitled"," at ",e.company??"Unknown"]},e.id))]}),(0,a.jsx)("button",{type:"button",onClick:A,className:"text-xs py-2 px-3 rounded border border-[var(--border)] text-[var(--text2)] hover:bg-[var(--surface)]",children:"Refresh"})]})]}),(0,a.jsxs)("div",{id:"memory",className:"scroll-mt-20",children:[(0,a.jsx)("h3",{className:"text-xs font-medium text-[var(--text2)] mb-2 cursor-pointer",...q("memory"),children:"From answer memory"}),C.length>0?(0,a.jsx)("div",{className:"rounded border border-[var(--accent2)] bg-[var(--accent2-soft)] p-3 space-y-2",children:C.slice(0,3).map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{w(e.answer)},className:"text-left flex-1 text-sm text-[var(--text)] hover:underline line-clamp-2",title:e.answer,children:[e.answer.slice(0,120),e.answer.length>120?"…":""]}),(0,a.jsx)("span",{className:"text-[10px] text-[var(--text3)] shrink-0",children:"Use"})]},e.id))}):(0,a.jsx)("p",{className:"text-xs text-[var(--text3)]",children:"Type a question to see saved answers."})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("button",{onClick:I,disabled:y||!p.trim()||!(0,c.CT)(t),className:"btn-primary px-4 py-2 rounded text-sm disabled:opacity-50",children:y?"Generating…":"Generate answer"}),(0,c.CT)(t)?null:(0,a.jsx)(u.o,{})]}),g&&(0,a.jsx)("p",{className:"text-sm text-[#c62828]",children:g})]}),(0,a.jsxs)("div",{id:"generated",className:"rounded-lg border border-[var(--border)] bg-[var(--surface2)] p-6 space-y-2 scroll-mt-20",children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-[var(--text)] cursor-pointer",...q("generated"),children:"Generated response"}),v?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("textarea",{id:"response-output",readOnly:!0,value:v,rows:8,className:"w-full px-4 py-2 rounded border border-[var(--border)] bg-[var(--surface)] text-[var(--text)] resize-y"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:()=>{v&&navigator.clipboard.writeText(v)},className:"text-xs py-1.5 px-3 rounded border border-[var(--border)] text-[var(--text2)] hover:bg-[var(--surface)]",children:"Copy to clipboard"}),(0,a.jsx)("button",{onClick:R,disabled:E,className:"text-xs py-1.5 px-3 rounded border border-[var(--accent2)] text-[var(--accent2)] hover:bg-[var(--accent2-soft)] disabled:opacity-50",children:E?"Saving…":"Save to memory"})]})]}):(0,a.jsx)("p",{className:"text-sm text-[var(--text3)]",children:"Generate an answer to see it here."})]})]})}function m(){return(0,a.jsx)(s.Suspense,{fallback:(0,a.jsx)("div",{className:"text-[var(--text2)] p-4",children:"Loading…"}),children:(0,a.jsx)(x,{})})}},52609:(e,t,r)=>{"use strict";r.d(t,{SG:()=>n,zx:()=>o});var a=r(7620),s=r(79748);let n="scroll-mt-20";function o(e){let{allowedIds:t,ready:r=!0,block:n="start",focusAfterScroll:o,onSectionChange:i,scrollRetries:l=8}
1=e,c=(0,s.useRouter)(),u=(0,s.usePathname)()??"/",d=(0,s.useSearchParams)(),x=d.get("section"),m=(0,a.useRef)(i),[h,f]=(0,a.useState)(()=>window.location.hash);(0,a.useEffect)(()=>{m.current=i},[i]),(0,a.useEffect)(()=>{let e=()=>f(window.location.hash);return e(),window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);let p=(0,a.useMemo)(()=>(function(e,t,r){let a=new Set(r);if(e&&a.has(e))return e;let s=t.startsWith("#")?t.slice(1):t;return s&&a.has(s)?s:null})(x,h,t),[x,h,t]);(0,a.useEffect)(()=>{m.current?.(p)},[p]);let b=(0,a.useCallback)(e=>{let t;(t=r=>{let a=document.getElementById(e);if(a){a.scrollIntoView({behavior:"smooth",block:n}),o?.(e);return}r<=0||window.setTimeout(()=>t(r-1),50)})(l)},[n,o,l]);(0,a.useEffect)(()=>{if(!r||!p)return;let e=window.setTimeout(()=>b(p),0);return()=>window.clearTimeout(e)},[r,p,b]);let v=(0,a.useCallback)(e=>{var r;let a,s;if(!t.includes(e))return;if(x===e)return void window.setTimeout(()=>b(e),0);let n=(r=d.toString(),(a=new URLSearchParams(r.
1startsWith("?")?r.slice(1):r)).set("section",e),(s=a.toString())?`${u}?${s}`:u);c.replace(n,{scroll:!1}),window.setTimeout(()=>b(e),0)},[t,u,c,b,d,x]),w=(0,a.useCallback)((e,t,r)=>({"data-section-chrome":!0,role:"button",tabIndex:0,className:t,"aria-label":r??`Deep link to ${e.replace(/-/g," ")} section`,onClick:t=>{!function(e,t){if(!(e instanceof Element)||!(t instanceof Element))return!1;let r=e.closest('a, button, input, select, textarea, label, [role="button"]');return!!r&&r!==t&&t.contains(r)}(t.target,t.currentTarget)&&(t.stopPropagation(),v(e))},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),v(e))}}),[v]);return{section:p,setSection:v,sectionChromeProps:w}}},70183:(e,t,r)=>{"use strict";r.d(t,{o:()=>o});var a=r(54568),s=r(65587),n=r.n(s);function o({className:e,message:t}){return(0,a.jsxs)("span",{className:e??"text-sm text-[var(--text2)]",children:[t??"RoleFit+ required."," ",(0,a.jsx)(n(),{href:"/#pricing",className:"text-[var(--accent)] hover:underline",children:"See plans"})]})}},77240:(e,t,r)=>{"use strict";function a(e){return!1!==e}async function s(e,t,r){let a=await fetch(e,t);if(403!==a.status)return a;let s=a.clone(),n=await s.json().catch(()=>({}));if(403!==a.status||n?.error!=="rolefit_plus_required")return a;let o=await r(!0);if(!o)return a;let i=new Headers(t?.headers);return i.set("Authorization",`Bearer ${o}`),fetch(e,{...t,headers:i})}r.d(t,{CT:()=>a,Jp:()=>s})},79748:(e,t,r)=>{"use strict";var a=r(79796);r.o(a,"useParams")&&r.d(t,{useParams:function(){return a.useParams}}),r.o(a,"usePathname")&&r.d(t,{usePathname:function(){return a.usePathname}}),r.o(a,"useRouter")&&r.d(t,{useRouter:function(){return a.useRouter}}),r.o(a,"useSearchParams")&&r.d(t,{useSearchParams:function(){return a.useSearchParams}})},91138:(e,t,r)=>{Promise.resolve().then(r.bind(r,18215))}},e=>{e.O(0,[5414,4522,3282,5587,8002,4899,4282,587,135,7358],()=>e(e.s=91138)),_N_E=e.O()}]);

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.