import{a as S,j as e,r as o,u as v,B as n,T as d}from"./render-D1ZqzUbP.js";import{W as _}from"./WorkspacePremium-oZlDKw5g.js";import{C}from"./Container-vcG9JMyV.js";import{T as k}from"./TextField-B6uk33js.js";import{A as u}from"./Alert-M7jUzTjE.js";import{B as x}from"./Button-DJ_uYab0.js";import"./Select-Ht3nAO4Q.js";import"./formControlState-C1XOL3mQ.js";import"./isMuiElement-BcEQvMml.js";const T=()=>{const[s,f]=o.useState(""),[m,i]=o.useState(""),[p,h]=o.useState(!1),{localeMessages:t,apiEndpoint:j,token:l,csrfToken:y}=v(),[c,b]=o.useState(""),g=a=>{if(a.preventDefault(),!s.trim()){i(t.full_name_required);return}i(""),fetch(`${j}?token=${l}`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":y},body:JSON.stringify({token:l,name:s})}).then(r=>{if(!r.ok)throw new Error(t.error_sending_data);return r.json()}).then(r=>{b(r.certificate_url)}).then(()=>{h(!0)}).catch(r=>{i(r.message)})};return e.jsx(n,{sx:{minHeight:"100vh",display:"flex",alignItems:"flex-start",justifyContent:"center",pt:"22vh",px:2,bgcolor:"background.main"},children:e.jsxs(C,{maxWidth:"sm",sx:{mt:0,py:4,px:{xs:3,sm:4},border:"1px solid",borderColor:"divider",borderRadius:3,boxShadow:2,bgcolor:"background.paper"},children:[e.jsxs(n,{display:"flex",alignItems:"center",my:4,justifyContent:"center",children:[e.jsx(_,{color:"secondary",sx:{fontSize:50,mr:1}}),e.jsx(d,{variant:"h4",component:"h1",children:t.form_title})]}),e.jsx(d,{variant:"body1",gutterBottom:!0,children:t.form_intro}),p?e.jsx(u,{severity:"success",sx:{mt:2},children:t.form_submission_success}):e.jsxs(n,{component:"form",method:"POST",action:"",sx:{mt:2},onSubmit:g,children:[e.jsx(k,{fullWidth:!0,label:t.full_name,name:"full_name",required:!0,margin:"normal",value:s,onChange:a=>f(a.target.value)}),m&&e.jsx(u,{severity:"error",children:m}),e.jsx(x,{type:"submit",variant:"contained",color:"secondary",sx:{mt:3,mx:"auto",display:"block",px:4,fontSize:"1.1rem"},children:t.submit})]}),c&&e.jsx(n,{sx:{mt:2,mx:"auto",display:"flex",justifyContent:"center"},children:e.jsx(x,{variant:"contained",color:"secondary",href:c,target:"_blank",rel:"noopener noreferrer",sx:{px:4,fontSize:"1.1rem"},children:t.view_certificate})})]})})};S({children:e.jsx(T,{})});
//# sourceMappingURL=certtificate_form-5xL3AlGn.js.map
