(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7164],{14287:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/categories/create",function(){return n(53776)}])},53776:function(e,s,n){"use strict";n.r(s);var t=n(85893),l=n(67294),i=n(9473),r=n(10315),a=n(18972),c=n(94054),u=n(19736),d=n(39332),o=n(86886),h=n(21737),x=n(92401),j=n(68269),Z=n(15861),f=n(69417),m=n(44267),v=n(50135),g=n(5616),p=n(66242);s.default=function(e){let[s,n]=(0,l.useState)(!1),_=(0,i.I0)(),{push:b}=(0,d.useRouter)(),S=(0,i.v9)(u.V_),C=(0,i.v9)(u.R0),E=(0,i.v9)(u.Vp),P=(0,i.v9)(u.bd),[w,y]=(0,l.useState)(null),[N,k]=(0,l.useState)(""),[T,W]=(0,l.useState)(""),[O,R]=(0,l.useState)(""),[V,X]=(0,l.useState)(1);return(0,l.useEffect)(()=>{y(null)},[]),(0,l.useEffect)(()=>{_((0,u.CP)({page:V}))},[V]),(0,l.useEffect)(()=>{!S&&E&&s&&(y("Category added successfully!"),setTimeout(()=>{y(null)},500),setTimeout(()=>{b("/categories")},500))},[E,S,s]),(0,t.jsxs)(o.ZP,{container:!0,spacing:6,children:[(0,t.jsx)(o.ZP,{item:!0,xs:12,children:(0,t.jsx)(Z.Z,{variant:"h5",children:"Create Category"})}),(0,t.jsx)(o.ZP,{item:!0,xs:12,children:(0,t.jsx)(p.Z,{children:(0,t.jsxs)(m.Z,{children:[w?(0,t.jsxs)(h.Z,{severity:"success",sx:{mb:4},children:[(0,t.jsx)(x.Z,{children:"Success"}),(0,t.jsx)(g.Z,{component:"strong",sx:{display:"block"},children:w})]}):null,C&&C.length>0?(0,t.jsxs)(h.Z,{severity:"error",sx:{mb:4},children:[(0,t.jsx)(x.Z,{children:"Errors"}),C.map((e,s)=>(0,t.jsx)(g.Z,{component:"strong",sx:{display:"block"},children:e},s))]}):null,(0,t.jsx)("form",{onSubmit:e=>{e.preventDefault(),S||(_((0,u.i8)({name:N,name_ar:T,parent_id:O})),n(!0))},children:(0,t.jsxs)(o.ZP,{row:!0,children:[(0,t.jsx)(o.ZP,{item:!0,xs:12,children:(0,t.jsxs)(j.Z,{direction:"row",gap:5,children:[(0,t.jsx)(v.Z,{fullWidth:!0,label:"Name",value:N,onChange:e=>k(e.target.value)}),(0,t.jsx)(v.Z,{fullWidth:!0,label:"Name Arabic",value:T,onChange:e=>W(e.target.value)}),(0,t.jsx)(c.Z,{fullWidth:!0,children:(0,t.jsx)(r.Z,{label:"Select",value:O,onChange:e=>R(e.target.value),children:P.map(e=>(0,t.jsx)(a.Z,{value:e.id,children:e.name},e.id))})})]})}),(0,t.jsx)(o.ZP,{item:!0,xs:12,sx:{mt:5},children:(0,t.jsx)(f.Z,{type:"submit",variant:"contained",disabled:S,children:S?"Saving":"Save"})})]})})]})})})]})}}},function(e){e.O(0,[2657,315,341,8589,9774,2888,179],function(){return e(e.s=14287)}),_N_E=e.O()}]);