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