import{r as h,S as j,j as e}from"./app-BZJf8lgN.js";import{C as v}from"./CustomCKEditor-BpmNiC9B.js";import{F as y}from"./fileupload.esm-CWt4e-Qk.js";import{I as l}from"./inputtext.esm-B1lZn37a.js";import{D as b}from"./dropdown.esm-HqLoOpxI.js";import{B as N}from"./button.esm-D_cwsnQR.js";import{I as w}from"./image.esm-DhzuK4QZ.js";import{I as m}from"./InputLabel-Dd3VnoK3.js";import{M as a}from"./message.esm-Do6SkgWF.js";import"./hooks.esm-UVLztt_0.js";import"./index.esm-Ckth6fI3.js";import"./index.esm-hRnQzR_k.js";import"./csstransition.esm-BNRxTMOa.js";import"./CSSTransition-DBuKQJwM.js";import"./index.esm-CygY3Qsw.js";import"./index.esm-B5zYYMSp.js";import"./overlayservice.esm-B-BnP5c1.js";const K=({categorias:n,toast:d,setVisibleNewNews:p})=>{const[s,u]=h.useState(null),{data:i,setData:r,post:c,errors:o,reset:x}=j({titulo:null,pie:null,texto:"",imagenFile:null,category_id:null}),g=t=>{t.preventDefault(),c(route("novedades.store"),{onSuccess:()=>{d.current.show({severity:"success",summary:"Exito",detail:"Novedad Agregada",life:3e3}),x(),p(!1)}})},f=t=>{u(t.files[0].objectURL),r("imagenFile",t.files[0])};return e.jsxs("form",{onSubmit:g,children:[e.jsx(l,{className:"w-full mb-2",placeholder:"Titulo",name:"titulo",onChange:t=>r("titulo",t.target.value)}),o.titulo&&e.jsx(a,{severity:"error",text:o.titulo}),e.jsx(l,{className:"w-full mb-2",placeholder:"Pie de foto",name:"pie",onChange:t=>r("pie",t.target.value)}),o.pie&&e.jsx(a,{severity:"error",text:o.pie}),e.jsx(m,{children:"Texto"}),e.jsx(v,{data:i.texto,onChange:t=>r("texto",t)}),o.texto&&e.jsx(a,{severity:"error",text:o.texto}),s&&e.jsx(w,{src:s,className:"w-6rem shadow-2 border-round",height:"200px"}),e.jsx(y,{mode:"basic",name:"img",className:"mt-3",accept:"image/*",chooseLabel:"Subir Imagen",required:!0,onSelect:f}),e.jsx(m,{children:"Resolucion Recomendada 808px * 457px"}),o.imagenFile&&e.jsx(a,{severity:"error",text:o.imagenFile}),e.jsx(b,{value:i.category_id,onChange:t=>r("category_id",t.value),options:n,optionValue:"id",optionLabel:"titulo",placeholder:"Seleccionar categoria",className:"w-full mt-3"}),o.category_id&&e.jsx(a,{severity:"error",text:o.category_id}),e.jsx(N,{type:"submit",className:"mt-5",style:{display:"block",margin:"auto"},children:"Agregar Novedad"})]})};export{K as default};
//# sourceMappingURL=AddFormNovedad-LZ0zjq6K.js.map
