import{q as u,n as e}from"./vendor-react-Br0ZiotI.js";import{br as v,aC as m,aB as n,bA as b,D as y,by as N,ct as t,bX as S}from"./index-DHmWpjgK.js";import"./vendor-dayjs-CbzZgysf.js";import{f as C}from"./formApi-D3lNIbKs.js";import{u as q}from"./vendor-i18n-C54Hc0CQ.js";function A({formType:d,submitLabel:p,source:i,note:c,accentText:x}){const{t:s}=q(),[a,h]=u.useState({name:"",phone:"",email:"",message:""}),[f,g]=u.useState(!1),r=(l,o)=>h(F=>({...F,[l]:o})),j=async l=>{if(l.preventDefault(),!a.name.trim()||!a.phone.trim()){t.error(s("holding.leadForm.required","Укажите имя и телефон"));return}g(!0);try{const o=await C.submit({formType:d,name:a.name.trim(),phone:a.phone.trim(),email:a.email.trim(),message:a.message.trim()?`${a.message.trim()}
Рсточник: ${i}`:`Заявка СЃРѕ страницы: ${i}`});o.success?(S("brand_lead_submitted",{formType:d,source:i}),t.success(s("holding.leadForm.success","Заявка отправлена — менеджер свяжется СЃ вами")),h({name:"",phone:"",email:"",message:""})):t.error(o.error||s("holding.leadForm.error","РќРµ удалось отправить заявку"))}catch{t.error(s("holding.leadForm.error","РќРµ удалось отправить заявку"))}finally{g(!1)}};return e.jsx("form",{onSubmit:j,children:e.jsxs(v,{gap:3,children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(m,{htmlFor:"lead-name",children:s("holding.leadForm.name","РРјСЏ *")}),e.jsx(n,{id:"lead-name",value:a.name,onChange:l=>r("name",l.target.value),placeholder:s("holding.leadForm.namePlaceholder","Как Рє вам обращаться"),required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(m,{htmlFor:"lead-phone",children:s("holding.leadForm.phone","Телефон *")}),e.jsx(n,{id:"lead-phone",type:"tel",value:a.phone,onChange:l=>r("phone",l.target.value),placeholder:"+7 900 000-00-00",required:!0})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(m,{htmlFor:"lead-email",children:s("holding.leadForm.email","Email")}),e.jsx(n,{id:"lead-email",type:"email",value:a.email,onChange:l=>r("email",l.target.value),placeholder:"you@company.ru"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(m,{htmlFor:"lead-message",children:s("holding.leadForm.message","Комментарий")}),e.jsx(b,{id:"lead-message",value:a.message,onChange:l=>r("message",l.target.value),placeholder:s("holding.leadForm.messagePlaceholder","Коротко Рѕ задаче: товар, объём, направление"),rows:3})]}),e.jsx(y,{type:"submit",size:"lg",loading:f,className:"w-full sm:w-auto",children:p}),c?e.jsx(N,{variant:"muted",className:`text-xs ${x??""}`,children:c}):null]})})}export{A as B};