"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5763],{35763:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(81862),a=n(89290),o=n(5163),i=n(52322),u=n(63756),l=n(98317),c=n(2784),d=n(78222),s=n(80843),p=n(69198),y=n(90379);function g(){var e=(0,l.getGraphQLClient)();return(0,i.jsx)(s.Z,{entityCategory:u.EDBEntity.ProductCategory,entityListRoute:y.ZE.route,entityBaseRoute:y.t9.baseRoute,listLabel:"Categories",entityLabel:"Category",defaultPageName:"category",getById:e.getProductCategoryById,update:e.updateProductCategory,create:e.createProductCategory,deleteOne:e.deleteProductCategory,fields:[{key:"name",type:"Simple text",label:"Name",required:!0},{key:"parent",type:"custom",customGraphQlProperty:{parent:{id:!0,slug:!0}},saveValue:function(e){return{parentId:null==e?void 0:e.id}},component:function(t){var n,u,l=t.onChange,s=t.entity,p=(0,a._)((0,c.useState)(null),2),y=p[0],g=p[1],f=(n=(0,r._)(function(t,n){return(0,o.__generator)(this,function(r){return[2,e.getProductCategories({filterParams:{nameSearch:t},pagedParams:n})]})}),function(e,t){return n.apply(this,arguments)}),v=function(e){e&&s&&s.id===e.id||l(null!=e?e:void 0)},m=(u=(0,r._)(function(t){var n;return(0,o.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.getProductCategoryById(t)];case 1:return(n=r.sent())&&(g(n),v(n)),[3,3];case 2:return console.error(r.sent()),[3,3];case 3:return[2]}})}),function(e){return u.apply(this,arguments)});return(0,c.useEffect)(function(){var e,t,n,r=new URLSearchParams(null===(e=window.location)||void 0===e?void 0:e.search).get("parentId");r?m(parseInt(r)):(null==s?void 0:null===(t=s.parent)||void 0===t?void 0:t.id)&&m(null==s?void 0:null===(n=s.parent)||void 0===n?void 0:n.id)},[]),(0,i.jsx)(d.Z,{loader:f,onSelect:v,getOptionLabel:function(e){var t;return"".concat(e.name," (id: ").concat(e.id).concat((null==e?void 0:null===(t=e.parent)||void 0===t?void 0:t.id)?"; parent id: ".concat(e.parent.id):"",")")},getOptionValue:function(e){return e.name},fullWidth:!0,defaultValue:y,label:"Parent category"})}},{key:"mainImage",type:"Image",label:"Image"},{key:"description",type:"Text editor",label:"Description",saveValue:p.al,getInitialValue:p.Js,customGraphQlProperty:{description:!0,descriptionDelta:!0}}]})}}}]);