(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6415],{20683:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/speakers/create",function(){return s(22558)}])},22558:function(e,n,s){"use strict";s.r(n);var l=s(85893),t=s(67294),i=s(9473),r=s(16473),a=s(39332),u=s(86886),c=s(21737),d=s(92401),o=s(68269),x=s(15861),h=s(69417);s(41664);var j=s(44267),p=s(50135),Z=s(5616),f=s(66242);n.default=function(e){let n=(0,i.I0)(),{push:s}=(0,a.useRouter)(),m=(0,i.v9)(r.V_),v=(0,i.v9)(r.R0),g=(0,i.v9)(r.Vp),[b,_]=(0,t.useState)(null),[P,S]=(0,t.useState)(""),[k,w]=(0,t.useState)(""),[E,y]=(0,t.useState)(""),[C,N]=(0,t.useState)(null);(0,t.useEffect)(()=>{n((0,r.xM)(!1))},[g]),(0,t.useEffect)(()=>{!m&&g&&(_("Speaker added successfully!"),setTimeout(()=>{s("/speakers")},500))},[g,m]);let fileValidation=()=>{let e=[];return console.log("img",C),null===C&&e.push("Image is required!"),e.length>0&&n((0,r.B$)(e)),e.length<1};return(0,l.jsxs)(u.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(x.Z,{variant:"h5",children:"Create Speaker"})}),(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(f.Z,{children:(0,l.jsxs)(j.Z,{children:[b?(0,l.jsxs)(c.Z,{severity:"success",sx:{mb:4},children:[(0,l.jsx)(d.Z,{children:"Success"}),(0,l.jsx)(Z.Z,{component:"strong",sx:{display:"block"},children:b})]}):null,v&&v.length>0?(0,l.jsxs)(c.Z,{severity:"error",sx:{mb:4},children:[(0,l.jsx)(d.Z,{children:"Errors"}),v.map((e,n)=>(0,l.jsx)(Z.Z,{component:"strong",sx:{display:"block"},children:e},n))]}):null,(0,l.jsx)("form",{onSubmit:e=>{e.preventDefault(),!m&&fileValidation()&&n((0,r.GA)({name:P,designation:k,description:E,image:C}))},children:(0,l.jsxs)(u.ZP,{row:!0,children:[(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(p.Z,{fullWidth:!0,label:"Name",value:P,onChange:e=>S(e.target.value)})}),(0,l.jsx)("br",{}),(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(p.Z,{fullWidth:!0,label:"Designation",value:k,onChange:e=>w(e.target.value)})}),(0,l.jsx)("br",{}),(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(p.Z,{fullWidth:!0,label:"Description",value:E,onChange:e=>y(e.target.value)})}),(0,l.jsx)(u.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,l.jsx)(o.Z,{direction:"row",gap:2,children:(0,l.jsxs)(h.Z,{variant:"contained",component:"label",children:["Upload Image",(0,l.jsx)("input",{type:"file",hidden:!0,onChange:e=>{var n,s;N(null!==(s=null===(n=e.target)||void 0===n?void 0:n.files[0])&&void 0!==s?s:null)}})]})})}),(0,l.jsx)(u.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,l.jsx)(h.Z,{type:"submit",variant:"contained",disabled:m,children:m?"Saving":"Save"})})]})})]})})})]})}}},function(e){e.O(0,[2657,315,341,4270,9774,2888,179],function(){return e(e.s=20683)}),_N_E=e.O()}]);