1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3482],{73482:(e,s,a)=>{a.d(s,{A:()=>E});var t=a(31430),r=a(8230),l=a(90272),o=a(31572),i=a(74822),n=a(546),c=a(69220),d=a(63632),m=a(18840),u=a(85798),x=a(23874),h=a(8638),j=a(61124),p=a(50149),b=a(79941),g=a(69390),f=a(65648),N=a(59258),w=a(45428),v=a(17724),y=a(66824),C=a(22295),A=a(58121),_=a(62559),S=a(41115),k=a(57876);function E(e){let{resumeId:s,allJobs:a=[],linkedJobIds:E=[],onJobStatusChange:D,resumeType:R="base",resumeData:L,baseResumeId:J,onNavigateToNewResume:I}=e,T=(0,l.useRouter)(),$=(0,S.a)(),[O,z]=(0,r.useState)(a),[q,V]=(0,r.useState)(E),[Z,F]=(0,r.useState)(null),[H,W]=(0,r.useState)(""),[B,G]=(0,r.useState)(0===a.length),[M,P]=(0,r.useState)(!1),[U,Y]=(0,r.useState)(!1),[Q,K]=(0,r.useState)("desc");(0,r.useEffect)(()=>{0===a.length&&(async()=>{G(!0);let{data:e,error:s}=await w.supabase.from("jobs").select("*");s?console.error("Error fetching jobs:",s):z(e),G(!1)})()},[a]),(0,r.useEffect)(()=>{0===E.length&&(async()=>{let{data:e,error:a}=await w.supabase.from("resume_jobs").select("job_id").eq("resume_id",s);a?console.error("Error fetching linked jobs:",a):e&&V(e.map(e=>e.job_id))})()},[s,E]);let X={[C.A.SAVED]:{icon:(0,t.jsx)(n.A,{className:"h-4 w-4"}),label:"Saved",bgColor:"bg-blue-50",textColor:"text-blue-500"},[C.A.APPLIED]:{icon:(0,t.jsx)(c.A,{className:"h-4 w-4"}),label:"Applied",bgColor:"bg-amber-50",textColor:"text-amber-500"},[C.A.INTERVIEWING]:{icon:(0,t.jsx)(d.A,{className:"h-4 w-4"}),label:"Interviewing",bgColor:"bg-purple-50",textColor:"text-purple-500"},[C.A.OFFERED]:{icon:(0,t.jsx)(m.A,{className:"h-4 w-4"}),label:"Offered",bgColor:"bg-green-50",textColor:"text-green-500"},[C.A.REJECTED]:{icon:(0,t.jsx)(u.A,{className:"h-4 w-4"}),label:"Rejected",bgColor:"bg-red-50",textColor:"text-red-500"}},ee=e=>X[e]||X[C.A.SAVED],es=async(e,s)=>{try{let{error:a}=await w.supabase.from("jobs").update({status:s}).eq("id",e);a?(console.error("Error updating job status:",a),alert("Error updating job status: "+a.message)):z(a=>a.map(a=>a.id===e?{...a,status:s}:a))}catch(e){console.error("Error updating job status:",e),alert("An error occurred while updating the job status")}},ea=async e=>{if(q.includes(e.id))return void alert("This job is already linked to your resume.");if(q.length>=1){let e=q[0],{error:a}=await w.supabase.from("resume_jobs").delete().eq("resume_id",s).eq("job_id",e);if(a)return void alert("Error removing current job: "+a.message)}let{error:a}=await w.supabase.from("resume_jobs").insert({resume_id:s,job_id:e.id});a?alert("Error linking job: "+a.message):(V([e.id]),D&&D())},et=O.filter(e=>e.position.toLowerCase().includes(H.toLowerCase())||e.company.toLowerCase().includes(H.toLowerCase())||e.location.toLowerCase().includes(H.toLowerCase())).sort((e,s)=>{let a=new Date(e.created_at).getTime(),t=new Date(s.created_at).getTime();return"asc"===Q?a-t:t-a});Array.from({length:1},(e,s)=>{if(!(s<q.length))return"Dream Job ".concat(s+1);{let e=O.find(e=>e.id===q[s]);return e?"".concat(e.position," at ").concat(e.company):"Dream Job ".concat(s+1)}});let er=async e=>{P(!0);try{var s;let{data:{user:a}}=await w.supabase.auth.getUser();if(!a){alert("You must be logged in to add a job"),P(!1);return}let t=(null==(s=e.status)?void 0:s.toLowerCase())||"saved",{data:r,error:l}=await w.supabase.from("jobs").insert({user_id:a.id,company:e.company,position:e.position,description:e.notes||"",location:e.location,status:t,job_posting_url:e.url||null,applied_at:new Date().toISOString()}).select();l?alert("Error adding job: "+l.message):r&&(z(e=>[...e,r[0]]),Y(!1))}catch(e){console.error("Error adding job:",e),alert("An error occurred while adding the job")}finally{P(!1)}};return(0,t.jsx)("div",{className:"container mx-auto py-8",children:(0,t.jsx)("div",{className:"bg-background rounded-lg border shadow-lg",children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"border-b px-6 py-4 flex justify-between items-center",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold",children:"Job List"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!$&&(0,t.jsxs)(o.$,{type:"button",variant:"outline",className:"gap-2",onClick:()=>T.push("/jobs"),children:[(0,t.jsx)(x.A,{className:"h-4 w-4"}),"Search for Jobs"]}),(0,t.jsxs)(v.lG,{open:U,onOpenChange:Y,children:[(0,t.jsx)(v.zM,{asChild:!0,children:(0,t.jsxs)(o.$,{variant:"default",className:"gap-2",children:[(0,t.jsx)(h.A,{className:"h-4 w-4"}),"Add a Job"]})}),(0,t.jsxs)(v.Cf,{className:"max-w-2xl w-full p-0 rounded-3xl overflow-hidden bg-white dark:bg-gray-900 shadow-xl",children:[(0,t.jsx)(v.c7,{className:"sr-only",children:(0,t.jsx)(v.L3,{children:"Add New Job"})}),(0,t.jsx)("div",{className:"max-h-[85vh] overflow-y-auto p-8 sm:p-10",children:(0,t.jsx)(_.A,{onSubmit:er})})]})]})]})]}),(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Select a job to tailor your resume to"})}),(0,t.jsxs)("div",{className:"relative mb-4 flex items-center gap-2",children:[(0,t.jsx)(x.A,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(y.p,{type:"search",placeholder:"Search jobs...",value:H,onChange:e=>W(e.target.value),className:"w-full pl-10"}),(0,t.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>K(e=>"asc"===e?"desc":"asc"),title:"asc"===Q?"Sort newest first":"Sort oldest first",children:"asc"===Q?(0,t.jsx)(j.A,{className:"h-4 w-4"}):(0,t.jsx)(p.A,{className:"h-4 w-4"})})]}),(0,t.jsx)("div",{className:"space-y-6 h-[500px] overflow-y-auto pr-2",children:B?Array.from({length:3}).map((e,s)=>(0,t.jsx)(i.Zp,{className:"animate-pulse",children:(0,t.jsx)(i.aR,{className:"bg-background/50 p-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("div",{className:"h-6 bg-gray-200 rounded w-3/4"}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("div",{className:"h-4 bg-gray-200 rounded w-1/4"}),(0,t.jsx)("div",{className:"h-4 bg-gray-200 rounded w-1/4"}),(0,t.jsx)("div",{className:"h-4 bg-gray-200 rounded w-1/4"})]})]})})},"skeleton-".concat(s))):0===et.length?(0,t.jsx)("div",{className:"text-center p-6 border rounded-md overflow-auto",children:0===O.length?(0,t.jsxs)("div",{className:"space-y-4 max-w-md mx-auto",children:[(0,t.jsx)("p",{className:"text-gray-500",children:"You haven't added any jobs. Add jobs to tailor your resume to."}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:justify-center",children:[(0,t.jsxs)(o.$,{variant:"default",className:"gap-2",onClick:()=>Y(!0),children:[(0,t.jsx)(h.A,{className:"h-4 w-4"}),"Add a job manually"]}),!$&&(0,t.jsxs)(o.$,{type:"button",className:"gap-2 bg-blue-600 text-white hover:bg-blue-700",onClick:()=>T.push("/jobs"),children:[(0,t.jsx)(h.A,{className:"h-4 w-4"}),"Use our AI Job Search"]})]})]}):(0,t.jsx)("p",{className:"text-gray-500",children:"No jobs found matching your search."})}):et.map(e=>(0,t.jsxs)(i.Zp,{className:"group overflow-auto transition-all hover:shadow-md",children:[(0,t.jsx)(i.aR,{className:"bg-background/50 p-4",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:e.position}),(0,t.jsxs)("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(b.A,{className:"h-3 w-3"}),e.company]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(g.A,{className:"h-3 w-3"}),e.location]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(f.A,{className:"h-3 w-3"}),e.created_at?new Date(e.created_at).toLocaleDateString():""]}),(0,t.jsxs)(A.rI,{children:[(0,t.jsx)(A.ty,{asChild:!0,children:(0,t.jsxs)("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full cursor-pointer ".concat(ee(e.status).bgColor," ").concat(ee(e.status).textColor),children:[ee(e.status).icon,ee(e.status).label]})}),(0,t.jsx)(A.SQ,{align:"end",children:Object.entries(C.A).map(s=>{let[a,r]=s;return(0,t.jsxs)(A._2,{className:"flex items-center gap-2 cursor-pointer",onClick:()=>es(e.id,r),children:[X[r].icon,(0,t.jsx)("span",{children:X[r].label})]},a)})})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[q.includes(e.id)?(0,t.jsx)(o.$,{variant:"outline",size:"sm",disabled:!0,children:"Current Job"}):(0,t.jsx)(o.$,{onClick:()=>ea(e),variant:"outline",size:"sm",children:"Select Job"}),(0,t.jsxs)(o.$,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>F(Z===e.id?null:e.id),children:[Z===e.id?"Hide Details":"Show Description",(0,t.jsx)(j.A,{className:"h-4 w-4 transition-transform ".concat(Z===e.id?"rotate-180":"")})]})]})]})}),Z===e.id&&(0,t.jsx)(i.Wu,{className:"animate-in fade-in slide-in-from-top-1 bg-background p-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3 text-muted-foreground",children:[(0,t.jsx)(N.A,{className:"mt-1 h-4 w-4 flex-shrink-0"}),(0,t.jsxs)("div",{className:"text-sm leading-relaxed flex-1",children:[e.description?(0,t.jsx)(k.A,{initialHTML:e.description,readOnly:!0}):(0,t.jsx)("p",{className:"italic text-gray-400",children:"No description available"}),e.job_posting_url&&(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)("a",{href:e.job_posting_url,target:"_blank",className:"text-blue-500 hover:underline",children:"View original job posting"})})]})]})})]},e.id))})]})]})})})}},74822:(e,s,a)=>{a.d(s,{BT:()=>c,Wu:()=>d,ZB:()=>n,Zp:()=>o,aR:()=>i});var t=a(31430),r=a(8230),l=a(25603);let o=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",a),...r})});
1o.displayName="Card";let i=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",a),...r})});i.displayName="CardHeader";let n=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",a),...r})});n.displayName="CardTitle";let c=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("text-sm text-muted-foreground",a),...r})});c.displayName="CardDescription";let d=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("p-6 pt-0",a),...r})});d.displayName="CardContent",r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)("div",{ref:s,className:(0,l.cn)("flex items-center p-6 pt-0",a),...r})}).displayName="CardFooter"}}]);
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.