1import{a as _,a4 as C,r as p,j as e,b as N,L as S,B as k,F as w,R as n}from"./index-5wkv-a56.js";import{P as T}from"./PageHeader-CJXW0r4l.js";import{I as i,T as E}from"./textarea-Dr8_K2tN.js";import{S as B,a as P,b as q,c as A,d as F,C as L}from"./checkbox-Cj3-G8_I.js";import{s as v}from"./client-BuTDHFhn.js";import{L as D}from"./loader-circle-ByreIsW_.js";import"./index-DviC1NIx.js";const I=5*1024*1024,Y=()=>{const{t}=_(),h=C(),[u,d]=p.useState(!1),[x,f]=p.useState(!1),[r,y]=p.useState({full_name:"",email:"",phone:"",linkedin_url:"",motivation:"",english_level:"",privacy_accepted:!1}),[o,j]=p.useState(null),s=(a,l)=>y(c=>({...c,[a]:l})),b=async a=>{if(a.preventDefault(),!r.full_name||!r.email||!r.phone){n({title:t("pages.apply.errRequired"),variant:"destructive"});return}if(!o||o.type!=="application/pdf"||o.size>I){n({title:t("pages.apply.errCv"),variant:"destructive"});return}if(!r.privacy_accepted){n({title:t("pages.apply.errPrivacy"),variant:"destructive"});return}d(!0);const l=r.full_name.replace(/[^a-zA-Z0-9-_]/g,"_").slice(0,40)||"cv",c=`junior-live-trader/${Date.now()}-${l}.pdf`,{error:m}=await v.storage.from("cvs").upload(c,o,{contentType:"application/pdf",upsert:!1});if(m){d(!1),n({title:"Error",description:m.message,variant:"destructive"});return}const{error:g}=await v.from("job_applications").insert({position:"junior-live-trader",full_name:r.full_name,email:r.email,phone:r.phone,linkedin_url:r.linkedin_url||null,motivation:r.motivation||null,english_level:r.english_level||null,cv_path:c,privacy_accepted:r.privacy_accepted});if(d(!1),g){n({title:"Error",description:g.message,variant:"destructive"});return}f(!0),n({title:t("pages.apply.success")}),setTimeout(()=>h("/oferta-laboral"),6e3)};return e.jsxs("div",{className:"min-h-screen bg-background text-foreground overflow-x-hidden",children:[e.jsx(N,{}),e.jsxs("main",{children:[e.jsx(T,{eyebrow:t("careers.eyebrow"),title:t("pages.apply.title"),desc:t("careers.roleSummary"),metaTitle:t("pages.apply.title"),canonicalPath:"/oferta-laboral/junior-live-trader/postular"}),e.jsx("section",{className:"py-12 md:py-16 px-6",children:e.jsxs("div",{className:"max-w-2xl mx-auto bg-card border border-border rounded-2xl shadow-card p-7 md:p-9",children:[e.jsx(S,{to:"/oferta-laboral",className:"text-xs text-secondary-fg hover:text-primary",children:t("careers.backToCareers")}),x?e.jsx("div",{className:"mt-6 rounded-xl bg-accent/10 border border-accent/30 p-6 text-foreground",children:e.jsx("p",{className:"leading-relaxed",children:t("pages.apply.success")})}):e.jsxs("form",{onSubmit:b,className:"mt-6 space-y-4",children:[e.jsx(i,{placeholder:t("pages.apply.fullName"),value:r.full_name,onChange:a=>s("full_name",a.target.value),required:!0}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(i,{type:"email",placeholder:t("pages.apply.email"),value:r.email,onChange:a=>s("email",a.target.value),required:!0}),e.jsx(i,{type:"tel",placeholder:t("pages.apply.phone"),value:r.phone,onChange:a=>s("phone",a.target.value),required:!0})]}),e.jsx(i,{placeholder:t("pages.apply.linkedin"),value:r.linkedin_url,onChange:a=>s("linkedin_url",a.target.value)}),e.jsxs(B,{value:r.english_level,onValueChange:a=>s("english_level",a),children:[e.jsx(P,{children:e.jsx(q,{placeholder:t("pages.apply.english")})}),e.jsx(A,{children:["A2","B1","B2","C1","C2"].map(a=>e.jsx(F,{value:a,children:a},a))})]}),e.jsx(E,{rows:4,placeholder:t("pages.apply.motivation"),value:r.motivation,onChange:a=>s("motivation",a.target.value)}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-foreground mb-2 block",children:t("pages.apply.cv")}),e.jsx(i,{type:"file",accept:"application/pdf",onChange:a=>{var l;return j(((l=a.target.files)==null?void 0:l[0])??null)}})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-secondary-fg cursor-pointer",children:[e.jsx(L,{checked:r.privacy_accepted,onCheckedChange:a=>s("privacy_accepted",!!a),className:"mt-0.5"}),e.jsx("span",{children:t("pages.apply.privacy")})]}),e.jsx(k,{type:"submit",disabled:u,className:"w-full h-12 bg-accent text-accent-foreground hover:bg-[hsl(var(--accent-hover))] rounded-lg font-semibold",children:u?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin"})," ",t("pages.apply.sending")]}):t("pages.apply.submit")})]})]})})]}),e.jsx(w,{})]})};export{Y 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.