import{u as T,R as e,L as j}from"./app-b4140d27.js";import{L as A,_ as b}from"./Layout-0576c2ba.js";import{l as B,a as E}from"./axios-004a8e66.js";import{A as I}from"./react-select-async.esm-8108584f.js";import{M as O,a as v}from"./files-config-44ae94a7.js";/* empty css            *//* empty css                           *//* empty css                                */import"./Header-487c2bfa.js";import"./Steps-b250558a.js";function H(){const{fair:c,exposition:a,user_id:u}=T().props,g=u&&u!=="",[s,x]=e.useState({exposition_id:"",exposition_main_image:(a==null?void 0:a.main_image)??"",exposition_name:(a==null?void 0:a.name)??"",exposition_description:(a==null?void 0:a.description)??"",exposition_start_date:(a==null?void 0:a.start_date)??"",exposition_end_date:(a==null?void 0:a.end_date)??"",fair_code:c.code}),[r,y]=e.useState({}),[w,_]=e.useState(!1),[N,C]=e.useState(s.exposition_description.length),[l,S]=e.useState(g?"":"create_exposition"),p=t=>{const n={...s,[t.target.name]:t.target.value};t.target.name==="exposition_description"&&C(n.exposition_description.length),t.target.name==="exposition_main_image"&&(n.exposition_main_image=t.target.files[0]),x(n),f(n,t.target.name)},M=t=>{x({...s,exposition_id:t.value})},k=t=>{if(t.preventDefault(),!f(s,"all")){b.error(_translations.there_are_errors_in_the_form),window.scrollTo(0,0);return}let i=new FormData;for(const[o,m]of Object.entries(s))i.append(o,m);_(!0),E({url:"/exposition_data",method:"POST",data:i,headers:{"Content-Type":"multipart/form-data"}}).then(o=>{if(_(!1),o.data.error){b(o.data.message,{duration:5e3,style:{backgroundColor:"#f89406"}});return}window.location=o.data.redirect_url}).catch(()=>{_(!1)})},h=t=>{t.preventDefault(),S(t.target.dataset.toggleMode)};let d;const D=(t,n)=>{d&&clearTimeout(d),d=setTimeout(()=>{E({url:"/get_expositions",method:"GET",params:{search:t}}).then(i=>{let o=i.data.map(m=>({value:m.id,label:m.name}));n(o)})},1e3)};function L(t,n){return t.exposition_main_image&&t.exposition_main_image.size/O>v&&(n.exposition_main_image=`La imagen debe ser menor a ${v}MB`),n}const f=(t,n)=>{let i=n!=="all"?r:{};(n==="all"||n==="exposition_main_image")&&(delete i.exposition_main_image,i=L(t,i));let o=Object.keys(i).length===0;return y(i),o};return e.createElement(A,{step:3},e.createElement("div",{className:"form mx-auto mt-3"},e.createElement("h2",{className:"fs-6 text-center py-4 m-0"},_translations.exposition_data),e.createElement("form",{onSubmit:k,autoComplete:"off",noValidate:!0},g&&e.createElement("div",{className:"col-12 mb-4"},e.createElement("p",null,_translations.exhibify_itg_account_detected_msg),e.createElement("div",{className:"row d-flex justify-content-between"},e.createElement("button",{type:"button",className:"btn "+(l==="create_exposition"?"btn-34 no-hover":"btn-34-white"),"data-toggle-mode":"create_exposition",onClick:h},_translations.create_new_exhibition),e.createElement("button",{type:"button",className:"btn "+(l==="search_exposition"?"btn-34 no-hover":"btn-34-white"),"data-toggle-mode":"search_exposition",onClick:h},_translations.use_one_on_my_account)),l==="search_exposition"&&e.createElement(I,{name:"exposition_id",className:"mb-5 mt-5",placeholder:"Busca una exposición por su nombre",isClearable:!0,loadOptions:D,onChange:M})),l==="create_exposition"&&e.createElement("div",null,e.createElement("div",{className:"col-12 mb-4"},e.createElement("label",null,_translations.exposition_name),e.createElement("input",{type:"text",name:"exposition_name",placeholder:_translations.exposition_name_placeholder,id:"exposition_name",onChange:p,value:s.exposition_name}),r.exposition_name&&e.createElement("span",{className:"text-danger"},r.exposition_name)),e.createElement("div",{className:"col-12 mb-4"},e.createElement("label",null,_translations.exposition_main_image),e.createElement("input",{type:"file",name:"exposition_main_image",onChange:p}),r.exposition_main_image&&e.createElement("span",{className:"text-danger"},r.exposition_main_image)),e.createElement("div",{className:"col-12 mb-4"},e.createElement("label",null,_translations.exposition_description),e.createElement("textarea",{name:"exposition_description",id:"exposition_description",placeholder:_translations.exposition_description_placeholder,onChange:p,value:s.exposition_description,maxLength:"4000"}),e.createElement("span",{className:"fw-light fs-7"},N,"/4000"),r.exposition_description&&e.createElement("span",{className:"text-danger"},r.exposition_description))),l!==""&&e.createElement("nav",{className:"mb-3 mt-2 d-flex justify-content-between align-items-center"},e.createElement(j,{href:"/gallery_data?c="+c.code},_translations.go_back),e.createElement("button",{type:"submit",className:"btn btn-34",id:"submit-work-data-btn"},w?e.createElement("img",{src:B,alt:"Loading...",width:"20px",height:"20px"}):_translations.next),e.createElement("input",{type:"hidden",name:"fair_code",id:"fair_code",value:c.code})))))}export{H as default};
