(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3805],{79660:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/announcements/create",function(){return t(24749)}])},24749:function(e,n,t){"use strict";t.r(n),t.d(n,{CustomDateInput:function(){return _}});var s=t(85893),r=t(67294),l=t(9473),i=t(99141),u=t(39332),a=t(86886),c=t(21737),o=t(92401),d=t(15861),x=t(69417),h=t(44267),m=t(50135),f=t(5616),j=t(66242),p=t(9198),Z=t.n(p),v=t(48557);t(35890);var w=t(30381),D=t.n(w);let _=(0,r.forwardRef)((e,n)=>(0,s.jsx)(m.Z,{fullWidth:!0,...e,inputRef:n,label:"Date",autoComplete:"off"}));n.default=function(e){let n=(0,l.I0)(),{push:t}=(0,u.useRouter)(),p=(0,l.v9)(i.V_),w=(0,l.v9)(i.R0),b=(0,l.v9)(i.Vp),[g,P]=(0,r.useState)(null),[C,Y]=(0,r.useState)(""),[y,E]=(0,r.useState)(""),[S,k]=(0,r.useState)("");return(0,r.useEffect)(()=>{n((0,i.xM)(!1))},[b]),(0,r.useEffect)(()=>{!p&&b&&(P("Announcement added successfully!"),setTimeout(()=>{t("/announcements")},500))},[b,p]),(0,s.jsx)(v.Z,{children:(0,s.jsxs)(a.ZP,{container:!0,spacing:6,children:[(0,s.jsx)(a.ZP,{item:!0,xs:12,children:(0,s.jsx)(d.Z,{variant:"h5",children:"Create Announcement"})}),(0,s.jsx)(a.ZP,{item:!0,xs:12,children:(0,s.jsx)(j.Z,{children:(0,s.jsxs)(h.Z,{children:[g?(0,s.jsxs)(c.Z,{severity:"success",sx:{mb:4},children:[(0,s.jsx)(o.Z,{children:"Success"}),(0,s.jsx)(f.Z,{component:"strong",sx:{display:"block"},children:g})]}):null,w&&w.length>0?(0,s.jsxs)(c.Z,{severity:"error",sx:{mb:4},children:[(0,s.jsx)(o.Z,{children:"Errors"}),w.map((e,n)=>(0,s.jsx)(f.Z,{component:"strong",sx:{display:"block"},children:e},n))]}):null,(0,s.jsx)("form",{onSubmit:e=>{e.preventDefault(),p||n((0,i.vj)({title:C,description:y,date:D()(S).format("DD-MM-YYYY")}))},children:(0,s.jsxs)(a.ZP,{row:!0,children:[(0,s.jsx)(a.ZP,{item:!0,xs:12,children:(0,s.jsx)(m.Z,{fullWidth:!0,label:"Title",value:C,onChange:e=>Y(e.target.value)})}),(0,s.jsx)(a.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,s.jsx)(m.Z,{fullWidth:!0,label:"Description",value:y,multiline:!0,maxRows:4,onChange:e=>E(e.target.value)})}),(0,s.jsx)(a.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,s.jsx)(Z(),{selected:S,showYearDropdown:!0,showMonthDropdown:!0,placeholderText:"MM-DD-YYYY",todayButton:"Current Date",includeDates:[new Date],customInput:(0,s.jsx)(_,{}),id:"form-layouts-separator-date",onChange:e=>k(e)})}),(0,s.jsx)(a.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,s.jsx)(x.Z,{type:"submit",variant:"contained",disabled:p,children:p?"Saving":"Save"})})]})})]})})})]})})}}},function(e){e.O(0,[4885,2657,315,341,5551,9741,718,9774,2888,179],function(){return e(e.s=79660)}),_N_E=e.O()}]);