(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3468],{82105:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/staff-members/create",function(){return s(58259)}])},58259:function(e,n,s){"use strict";s.r(n);var l=s(85893),i=s(67294),t=s(9473),r=s(55220),a=s(39332),u=s(86886),c=s(21737),d=s(92401),o=s(68269),h=s(15861),x=s(69417);s(41664);var f=s(44267),m=s(50135),j=s(5616),p=s(66242);n.default=function(e){let n=(0,t.I0)(),{push:s}=(0,a.useRouter)(),Z=(0,t.v9)(r.V_),v=(0,t.v9)(r.R0),b=(0,t.v9)(r.Vp),[g,_]=(0,i.useState)(null),[P,S]=(0,i.useState)(""),[w,E]=(0,i.useState)(null),[N,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{n((0,r.xM)(!1))},[b]),(0,i.useEffect)(()=>{!Z&&b&&(_("Staff-member added successfully!"),setTimeout(()=>{s("/staff-members")},500))},[b,Z]);let fileValidation=()=>{let e=[];return null===P&&e.push("Name is required!"),null===N&&e.push("Image is required!"),null===w&&e.push("Description 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)(h.Z,{variant:"h5",children:"Create Staff Member"})}),(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(p.Z,{children:(0,l.jsxs)(f.Z,{children:[g?(0,l.jsxs)(c.Z,{severity:"success",sx:{mb:4},children:[(0,l.jsx)(d.Z,{children:"Success"}),(0,l.jsx)(j.Z,{component:"strong",sx:{display:"block"},children:g})]}):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)(j.Z,{component:"strong",sx:{display:"block"},children:e},n))]}):null,(0,l.jsx)("form",{onSubmit:e=>{e.preventDefault(),!Z&&fileValidation()&&n((0,r.Nl)({name:P,description:w,image:N}))},children:(0,l.jsxs)(u.ZP,{row:!0,children:[(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(m.Z,{fullWidth:!0,label:"Name",value:P,onChange:e=>S(e.target.value)})}),(0,l.jsx)(u.ZP,{item:!0,xs:12,children:(0,l.jsx)(m.Z,{fullWidth:!0,label:"Description",value:w,onChange:e=>E(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)(x.Z,{variant:"contained",component:"label",children:["Upload Image",(0,l.jsx)("input",{type:"file",hidden:!0,onChange:e=>{var n,s;y(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)(x.Z,{type:"submit",variant:"contained",disabled:Z,children:Z?"Saving":"Save"})})]})})]})})})]})}}},function(e){e.O(0,[2657,315,341,6015,9774,2888,179],function(){return e(e.s=82105)}),_N_E=e.O()}]);