import{o as b,j as e,r as n,n as g,B as a,T as u}from"./render-BEL5IN7j.js";import{W as v}from"./WorkspacePremium-BpR8JYDX.js";import{C}from"./Container-BJA-Qv7d.js";import{T}from"./TextField-9E0h2GEt.js";import{A as f}from"./Alert-DGyy5JNc.js";import{B as d}from"./Button-CGPZXh3G.js";import"./Select-DyY0x5OK.js";import"./formControlState-YO0xWqIm.js";import"./isMuiElement-e1vpiHuY.js";const k=()=>{const[o,p]=n.useState(""),[m,s]=n.useState(""),[h,x]=n.useState(!1),{localeMessages:t,apiEndpoint:j,token:c,csrfToken:y}=g(),[l,S]=n.useState(""),_=i=>{if(i.preventDefault(),!o.trim()){s(t.full_name_required);return}s(""),fetch(`${j}?token=${c}`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":y},body:JSON.stringify({token:c,name:o})}).then(r=>{if(!r.ok)throw new Error(t.error_sending_data);return r.json()}).then(r=>{S(r.certificate_url)}).then(()=>{x(!0)}).catch(r=>{s(r.message)})};return e.jsxs(C,{maxWidth:"sm",sx:{mt:4},children:[e.jsxs(a,{display:"flex",alignItems:"center",my:4,justifyContent:"center",children:[e.jsx(v,{color:"primary",sx:{fontSize:50,mr:1}}),e.jsx(u,{variant:"h4",component:"h1",children:t.form_title})]}),e.jsx(u,{variant:"body1",gutterBottom:!0,children:t.form_intro}),h?e.jsx(f,{severity:"success",sx:{mt:2},children:t.form_submission_success}):e.jsxs(a,{component:"form",method:"POST",action:"",sx:{mt:2},onSubmit:_,children:[e.jsx(T,{fullWidth:!0,label:t.full_name,name:"full_name",required:!0,margin:"normal",value:o,onChange:i=>p(i.target.value)}),m&&e.jsx(f,{severity:"error",children:m}),e.jsx(d,{type:"submit",variant:"contained",color:"primary",sx:{mt:3},children:t.submit})]}),l&&e.jsx(a,{sx:{mt:2},children:e.jsx(d,{variant:"contained",color:"primary",href:l,target:"_blank",rel:"noopener noreferrer",children:t.view_certificate})})]})};b({children:e.jsx(k,{})});
//# sourceMappingURL=certtificate_form-V_dU5z_c.js.map
