2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{u as h,j as e,m as j,l as S,n as x,o as g,p as u,q as n,B as m,L as w,r as k,s as C,t as _,v as G,C as P,w as D}from"./ui-library-B3AuUXkV.js";import{a as v}from"./react-vendor-DnK_KZAP.js";import{z as t,t as V,a as q}from"./index-CLjNpp6Y.js";import{R as E,a as N}from"./radio-group-CmLfoWWT.js";import{u as R}from"./use-scroll-top-DE9Ps7OH.js";const J=t.object({type:t.string(),company_name:t.string().min(3,{message:"Название компании должно быть не менее 3 символов"}),representative_name:t.string().min(3,{message:"Имя представителя должно быть не менее 3 символов"}),job_title:t.string().min(3,{message:"Должность должна быть не менее 3 символов"}),participants_number:t.string().min(1,{message:"Укажите количество участников"}),country:t.string().min(3,{message:"Название страны должно быть не менее 3 символов"}),email_address:t.string().email({message:"Укажите корректный email"}),phone_number:t.string().min(8,{message:"Номер телефона должен быть не менее 8 символов"}),website:t.string().optional(),meeting_objective:t.string().min(3,{message:"Укажите цель встречи"}),proposal_description:t.string().optional(),government_agency:t.string().optional(),sector_industry:t.string().optional(),key_services:t.string().optional(),government_experience:t.string().optional(),preferred_meeting_datetime:t.string().optional(),meeting_mode:t.string().optional(),language_preference:t.string().optional(),technical_requirements:t.string().optional(),company_profile:t.custom(r=>r instanceof File,{message:"Выберите корректный файл"}).refine(r=>r&&["image/jpeg","image/png","application/pdf"].includes(r.type),{message:"Допускаются только файлы JPG, PNG и PDF"}).optional(),proposal_presentation:t.custom(r=>r instanceof File,{message:"Выберите корректный файл"}).refine(r=>r&&["image/jpeg","image/png","application/pdf"].includes(r.type),{message:"Допускаются только файлы JPG, PNG и PDF"}).optional(),relevant_certification:t.custom(r=>r instanceof File,{message:"Выберите корректный файл"}).refine(r=>r&&["image/jpeg","image/png","application/pdf"].includes(r.type),{message:"Допускаются только файлы JPG, PNG и PDF"}).optional()}),L={type:"B2B",company_name:"",representative_name:"",job_title:"",participants_number:"",country:"",email_address:"",phone_number:"",website:"",meeting_objective:"",proposal_description:"",government_agency:"",sector_industry:"",key_services:"",government_experience:"",preferred_meeting_datetime:"",meeting_mode:"",language_preference:"",technical_requirements:""},T=({handleNext:r})=>{const{control:s,formState:a}=h();return e.jsxs(j.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:"100%",transition:{duration:.2}},className:"w-full",children:[e.jsx("h3",{className:"h2 mb-8",children:"Информация об экспоненте:"}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(S,{defaultValue:1,control:s,name:"type",render:({field:i})=>e.jsxs(x,{className:"space-y-3",children:[e.jsx(g,{className:"text-xl",children:"Тип:"}),e.jsx(u,{children:e.jsxs(E,{onValueChange:i.onChange,defaultValue:i.value,className:"flex flex-col space-y-4",children:[e.jsxs(x,{className:"flex items-center space-x-3 space-y-0",children:[e.jsx(u,{children:e.jsx(N,{value:"B2B",checked:i.value==="B2B"})}),e.jsx(g,{className:"text-base",children:"B2B"})]}),e.jsxs(x,{className:"flex items-center space-x-3 space-y-0",children:[e.jsx(u,{children:e.jsx(N,{value:"B2G",checked:i.value==="B2G"})}),e.jsx(g,{className:"text-base",children:"B2G"})]})]})})]})}),e.jsx(n,{control:s,name:"company_name",error:a.errors.company_name,placeholder:"",label:"Название компании/организации"}),e.jsx(n,{control:s,name:"representative_name",error:a.errors.representative_name,placeholder:"",label:"Имя представителя"}),e.jsx(n,{control:s,name:"job_title",error:a.errors.job_title,placeholder:"",label:"Название должности/позиция"}),e.jsx(n,{control:s,name:"participants_number",error:a.errors.participants_number,placeholder:"",label:"Количество участников"}),e.jsx(n,{control:s,name:"country",error:a.errors.country,placeholder:"",label:"Страна"}),e.jsx(n,{control:s,name:"email_address",error:a.errors.email_address,placeholder:"",label:"E-mail адрес"}),e.jsx(n,{control:s,name:"phone_number",error:a.errors.phone_number,placeholder:"",label:"Номер телефона"}),e.jsx(n,{control:s,name:"website",placeholder:"",label:"Вебсайт"})]}),e.jsx(m,{variant:"secondary",type:"button",onClick:r,className:"w-full mt-10",children:"Далее"})]})},z=({handleNext:r,handlePrev:s})=>{const{control:a,formState:i}=h();return e.jsxs(j.div,{initial:{opacity:0,y:-100},animate:{opacity:1,y:0,transition:{delay:.5,duration:.3}},exit:{opacity:0,y:100},children:[e.jsx("h3",{className:"h2 mb-8",children:"Цели встречи:"}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(n,{control:a,name:"meeting_objective",error:i.errors.meeting_objective,placeholder:"",label:"Основная цель встречи"}),e.jsx(n,{control:a,name:"proposal_description",error:i.errors.proposal_description,placeholder:"",label:"Краткое описание вашего предложения/проекта/запроса"}),e.jsx(n,{control:a,name:"government_agency",error:i.errors.government_agency,placeholder:"",label:"Соответствующее государственное учреждение/департамент"}),e.jsx("h3",{className:"h2 mt-4",children:"Информация о компании/организации:"}),e.jsx(n,{control:a,name:"sector_industry",error:i.errors.sector_industry,placeholder:"",label:"Отраслевая промышленность"}),e.jsx(n,{control:a,name:"key_services",error:i.errors.key_services,placeholder:"",label:"Ключевые услуги/продукты"}),e.jsx(n,{control:a,name:"government_experience",error:i.errors.government_experience,placeholder:"",label:"Предыдущий опыт работы с правительствами (если применимо)"})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-10",children:[e.jsx(m,{type:"button",onClick:s,variant:"outline",className:"text-on_surface",children:"Вернуться назад"}),e.jsx(m,{variant:"secondary",type:"button",onClick:r,className:"w-full",children:"Далее"})]})]})},I=({handlePrev:r})=>{const{control:s,formState:a}=h();return e.jsxs(j.div,{initial:{opacity:0,y:-100},animate:{opacity:1,y:0,transition:{delay:.5,duration:.3}},transition:{duration:1},children:[e.jsx("h3",{className:"h2 mb-8",children:"Логистика встречи:"}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(n,{control:s,name:"preferred_meeting_datetime",error:a.errors.preferred_meeting_datetime,placeholder:"",label:"Предпочтительная дата и время "}),e.jsx(n,{control:s,name:"preferred_mode",error:a.errors.preferred_mode,placeholder:"",label:"Предпочтительный способ проведения встречи (лично, виртуально (через zoom/ teams/другое), гибридный)"}),e.jsx(n,{control:s,name:"language_preference",error:a.errors.language_preference,placeholder:"",label:"Предпочитаемый язык (английский, туркменский, русский, другой)"}),e.jsx(n,{control:s,name:"additional_technical",error:a.errors.additional_technical,placeholder:"",label:"Дополнительные технические или логистические требования (например, аудио-видео оборудование, переводчики и т.д.)"})]}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{className:"",children:[e.jsx("h3",{className:"h2 mt-10",children:"Приложения:"}),e.jsx("h5",{className:"text-on_surface_v",children:"(Пожалуйста приложите следующие документы, если это необходимо)"})]}),e.jsx(n,{control:s,name:"company_profile",label:"Название компании/организации",type:"file",textDark:!0}),e.jsx(n,{control:s,name:"proposal_presentation",label:"Предложение/презентация",type:"file",textDark:!0}),e.jsx(n,{control:s,name:"relevant_certification",label:"Соответствующие сертификаты/лицензии",type:"file",textDark:!0})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-10",children:[e.jsx(m,{type:"button",onClick:r,variant:"outline",className:"text-on_surface",children:"Вернуться назад"}),e.jsx(m,{disabled:a.isSubmitting,type:"submit",className:"w-full",children:a.isSubmitting?e.jsx(w,{className:"animate-spin"}):"Отправить"})]})]})},O=({stage:r,setStage:s,success:a,setSuccess:i})=>{const d=k({resolver:V(J),defaultValues:L,mode:"onChange"}),B=o=>{switch(o){case 1:return["type","company_name","representative_name","job_title","participants_number","country","email_address","phone_number","website"];case 2:return["meeting_objective","proposal_description","government_agency","sector_industry","key_services","government_experience"];case 3:return["preferred_meeting_datetime","meeting_mode","language_preference","technical_requirements","company_profile","proposal_presentation","relevant_certification"];default:return[]}},f=async()=>{const o=B(r);await d.trigger(o)&&s(y=>y+1)},b=()=>s(o=>o-1),F=async o=>{try{const l=new FormData;Object.entries(o).forEach(([p,c])=>{c instanceof File?(console.log(`Добавляем файл: ${p}`,c),l.append(p,c)):c!==void 0&&(console.log(`Добавляем поле: ${p}`,c),l.append(p,c))}),(await q.post("https://turkmentextile.turkmenexpo.com/app/api/v1/form",l,{headers:{"Content-Type":"multipart/form-data"}})).status===201&&(console.log("Форма успешно отправлена!"),i(!0))}catch(l){console.error("Ошибка при отправке B2B формы:",l)}};return e.jsx(C,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(F),children:e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:r===1&&e.jsx(T,{handleNext:f})}),e.jsx(_,{children:r===2&&e.jsx(z,{handleNext:f,handlePrev:b})}),e.jsx(_,{children:r===3&&a===!1&&e.jsx(I,{handlePrev:b})}),a&&e.jsx(G,{})]})})})};function Q(){R();const[r,s]=v.useState(1),[a,i]=v.useState(!1);return e.jsxs("div",{className:"pb-[120px]",children:[e.jsx(P,{title:"B2B | B2G встречи"}),!a&&r!==0&&e.jsx(D,{stage:r}),e.jsx("div",{className:"max-w-[808px] md:mx-auto mx-5",children:e.jsx(O,{success:a,setSuccess:i,stage:r,setStage:s})})]})}export{Q as default};
|