Sindbad~EG File Manager
"use strict";(self.webpackChunk_minimal_material_kit_react=self.webpackChunk_minimal_material_kit_react||[]).push([[540],{4469:function(e,n,t){var r=t(6459),i=t(4165),o=t(5861),a=t(1243),l=t(6382),c=t(9113),u=localStorage.getItem("userToken");(0,l.hg)("products/create",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var r,o;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.rejectWithValue,e.prev=1,o={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},a.Z.post("".concat(c.v,"/product"),n,o).then((function(e){console.log("Product Action",null===e||void 0===e?void 0:e.data)})),e.next=10;break;case 6:if(e.prev=6,e.t0=e.catch(1),!e.t0.response||!e.t0.response.data.message){e.next=10;break}return e.abrupt("return",r(e.t0.response.data.message));case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(n,t){return e.apply(this,arguments)}}()),(0,l.hg)("products/get",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var r,o,l,s,d;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.id,o=t.rejectWithValue,console.log("[getProductsForBrand]",r),e.prev=3,l={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},e.next=7,a.Z.get("".concat(c.v,"/product/").concat(r),l);case 7:if(s=e.sent,!(d=s.data)){e.next=12;break}return console.log("[getProductsForBrand]",d),e.abrupt("return",d);case 12:e.next=18;break;case 14:if(e.prev=14,e.t0=e.catch(3),!e.t0.response||!e.t0.response.data.message){e.next=18;break}return e.abrupt("return",o(e.t0.response.data.message));case 18:case"end":return e.stop()}}),e,null,[[3,14]])})));return function(n,t){return e.apply(this,arguments)}}()),(0,l.hg)("products/getAll",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var o,l,s,d;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(0,r.Z)(n),o=t.rejectWithValue,e.prev=2,l={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},e.next=6,a.Z.get("".concat(c.v,"/products"),l);case 6:if(s=e.sent,!(d=s.data)){e.next=10;break}return e.abrupt("return",d.products);case 10:e.next=16;break;case 12:if(e.prev=12,e.t0=e.catch(2),!e.t0.response||!e.t0.response.data.message){e.next=16;break}return e.abrupt("return",o(e.t0.response.data.message));case 16:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(n,t){return e.apply(this,arguments)}}()),(0,l.hg)("product/edit",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var r,o,l,s,d,p,h,v;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.id,o=n.values,l=t.rejectWithValue,e.prev=2,s={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},console.log("Action",r,o),e.next=7,a.Z.put("".concat(c.v,"/product/").concat(r),o,s);case 7:return null!==(d=e.sent)&&void 0!==d&&d.data&&console.log("Product edit payload",null===d||void 0===d?void 0:d.data),e.abrupt("return",null===d||void 0===d?void 0:d.data);case 12:if(e.prev=12,e.t0=e.catch(2),!e.t0.response){e.next=18;break}return e.abrupt("return",l(null===e.t0||void 0===e.t0||null===(p=e.t0.response)||void 0===p||null===(h=p.data)||void 0===h||null===(v=h.error)||void 0===v?void 0:v.message));case 18:return e.abrupt("return",l(e.t0.message));case 19:case"end":return e.stop()}}),e,null,[[2,12]])})));return function(n,t){return e.apply(this,arguments)}}()),(0,l.hg)("product/delete",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var r,o,l,s,d,p,h;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.rejectWithValue,e.prev=1,o={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},e.next=5,a.Z.delete("".concat(c.v,"/product/").concat(n),o);case 5:if(l=e.sent,!(s=l.data)){e.next=9;break}return e.abrupt("return",s);case 9:e.next=18;break;case 11:if(e.prev=11,e.t0=e.catch(1),!e.t0.response){e.next=17;break}return e.abrupt("return",r(null===e.t0||void 0===e.t0||null===(d=e.t0.response)||void 0===d||null===(p=d.data)||void 0===p||null===(h=p.error)||void 0===h?void 0:h.message));case 17:return e.abrupt("return",r(e.t0.message));case 18:case"end":return e.stop()}}),e,null,[[1,11]])})));return function(n,t){return e.apply(this,arguments)}}()),(0,l.hg)("product/sort",function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n,t){var r,o,l,s,d,p,h,v,f,x;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.sortBy,o=n.sort,l=t.rejectWithValue,e.prev=2,s=c.v+"/product/filter",r&&(s=c.v+"/product/filter?sortBy=".concat(r,"&sort=").concat(o)),d={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(u)}},e.next=8,a.Z.get("".concat(s),d);case 8:if(p=e.sent,!(h=p.data)){e.next=13;break}return console.log("Product sort payload",h),e.abrupt("return",h);case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(2),!e.t0.response){e.next=21;break}return e.abrupt("return",l(null===e.t0||void 0===e.t0||null===(v=e.t0.response)||void 0===v||null===(f=v.data)||void 0===f||null===(x=f.error)||void 0===x?void 0:x.message));case 21:return e.abrupt("return",l(e.t0.message));case 22:case"end":return e.stop()}}),e,null,[[2,15]])})));return function(n,t){return e.apply(this,arguments)}}())},2540:function(e,n,t){t.r(n);var r=t(1413),i=t(3433),o=t(9439),a=t(2791),l=t(1614),c=t(3767),u=t(890),s=t(4518),d=t(1889),p=t(8096),h=t(4613),v=t(9321),f=t(3786),x=t(2199),m=t(5523),g=t(9174),j=t(7391),Z=t(7621),b=t(9504),y=t(3400),C=t(5078),k=(t(5985),t(4600)),P=t(3609),w=t(7689),_=t(9434),W=(t(4469),t(184));window.Buffer=window.Buffer||t(9778).lW;var z={upper:["XS","S","M","L","XL"],lower:["28","29","30","31","32","33","34","35","36","37","38","39","40"],feet:["35","36","37","38","39","40","41","42","43","44","45","46","47"]};n.default=function(){var e,n,t,S,A,B,N,I,q,T,R,V,L,U,D=(0,w.s0)(),Q=((0,_.I0)(),(0,w.TH)().state),F=null===Q||void 0===Q||null===(e=Q.product)||void 0===e?void 0:e._id;console.log("State",Q),console.log("productId",F);var H=(0,a.useState)([]),M=(0,o.Z)(H,2),O=M[0],X=(M[1],(0,a.useState)([])),E=(0,o.Z)(X,2),G=E[0],J=(E[1],(0,a.useState)()),K=(0,o.Z)(J,2),Y=K[0],$=K[1],ee=(0,_.v9)((function(e){return e.auth})),ne=ee.brandInfo,te=ee.userInfo,re=null===te||void 0===te?void 0:te.user_role,ie=(null===ne||void 0===ne||ne.brand_id,(0,a.useRef)()),oe=(0,a.useRef)(),ae=(0,a.useState)([]),le=(0,o.Z)(ae,2),ce=le[0],ue=le[1];return(0,W.jsxs)(l.Z,{children:[(0,W.jsxs)(c.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",mb:5,children:[(0,W.jsx)(u.Z,{variant:"h4",sx:{mb:5},children:"Edit Product"}),(0,W.jsx)(s.Z,{variant:"contained",onClick:function(){return D("/dashboard/".concat(re,"/products"),{replace:!0})},children:"Back To Product"})]}),(0,W.jsx)(C.l0,{onSubmit:function(){console.log("Submit")},initialValues:{name:null===Q||void 0===Q||null===(n=Q.product)||void 0===n?void 0:n.name,category:null===Q||void 0===Q||null===(t=Q.product)||void 0===t||null===(S=t.category)||void 0===S?void 0:S._id,brand:null===Q||void 0===Q||null===(A=Q.product)||void 0===A||null===(B=A.brand)||void 0===B?void 0:B._id,productCode:null===Q||void 0===Q||null===(N=Q.product)||void 0===N?void 0:N.productCode,color:null===Q||void 0===Q||null===(I=Q.product)||void 0===I?void 0:I.color,size:null===Q||void 0===Q||null===(q=Q.product)||void 0===q?void 0:q.size,price:null===Q||void 0===Q||null===(T=Q.product)||void 0===T?void 0:T.price,quantity:null===Q||void 0===Q||null===(R=Q.product)||void 0===R?void 0:R.quantity,discount:null===Q||void 0===Q||null===(V=Q.product)||void 0===V?void 0:V.discount,description:null===Q||void 0===Q||null===(L=Q.product)||void 0===L?void 0:L.description,imgUrl:null===Q||void 0===Q||null===(U=Q.product)||void 0===U?void 0:U.imgUrl},validate:function(e){console.log("[validate]",e.size);var n={};return e.name||(n.name="Name is required!"),e.category||(n.category="Category is required!"),e.brand||"brand"===(null===te||void 0===te?void 0:te.user_role)||(n.brand="Brand name is required!"),0===e.price&&(n.price="Price is required!"),e.description||(n.description="Description is required!"),e.quantity||(n.quantity="Quantity is required!"),e.productCode||(n.productCode="ProductCode is required!"),e.color||(n.color="Color is required!"),console.log("ere",n),n},mutators:{onChangeQuantity:function(e,n,t){t.changeValue(n,"quantity",(function(n){return function(n){return n>1||1===n&&1==e?Number(null!==n&&void 0!==n?n:1)+Number(e):1}(n)}))},onChangeCheckBox:function(e,n,t){t.changeValue(n,"size",(function(n){return-1!==(t=n).indexOf(e[0])?t.filter((function(n){return n!==e[0]})):[].concat((0,i.Z)(t),[e[0]]);var t}))}},render:function(e){var n=e.handleSubmit,t=(e.errors,e.form);return(0,W.jsxs)("form",{onSubmit:n,children:[(0,W.jsxs)(d.ZP,{container:!0,spacing:4,children:[(0,W.jsx)(d.ZP,{item:!0,xs:6,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"name",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Product Name"},e))}})}),(0,W.jsx)(d.ZP,{item:!0,xs:6,children:(0,W.jsx)(C.gN,{fullWidth:!0,component:"select",name:"category",children:function(e){var n=e.input;e.meta,e.options;return(0,W.jsxs)(p.Z,{fullWidth:!0,children:[(0,W.jsx)(h.Z,{id:"brand-label",children:"Product Category"}),(0,W.jsx)(v.Z,(0,r.Z)((0,r.Z)({labelId:"brand-label",name:"category",options:G,MenuProps:{style:{maxHeight:300}}},n),{},{children:null===G||void 0===G?void 0:G.map((function(e,n){return(0,W.jsx)(f.Z,{value:e._id,children:e.categoryName},n)}))}))]})}})}),"brand"!==(null===te||void 0===te?void 0:te.user_role)&&(0,W.jsx)(d.ZP,{item:!0,xs:4,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"brand",children:function(e){var n,t=e.input;e.meta,e.options;return(0,W.jsxs)(p.Z,{fullWidth:!0,children:[(0,W.jsx)(h.Z,{id:"brand-label",children:"Brand Name"}),(0,W.jsx)(v.Z,(0,r.Z)((0,r.Z)({labelId:"brand-label",name:"brand",options:O,onChange:function(e){return t.onChange(e)},MenuProps:{style:{maxHeight:300}}},t),{},{children:null===O||void 0===O||null===(n=O.brands)||void 0===n?void 0:n.map((function(e,n){return(0,W.jsx)(f.Z,{value:e._id,children:e.brandName},n)}))}))]})}})}),(0,W.jsx)(d.ZP,{item:!0,xs:4,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"productCode",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Product Code"},e))}})}),(0,W.jsx)(d.ZP,{item:!0,xs:4,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"color",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Product Color"},e))}})}),(0,W.jsx)(d.ZP,{item:!0,xs:"brand"!==(null===te||void 0===te?void 0:te.user_role)?4:6,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"price",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Price",type:"number",style:{paddingRight:0},InputProps:{inputProps:{min:0}}},e))}})}),(0,W.jsx)(d.ZP,{item:!0,xs:"brand"!==(null===te||void 0===te?void 0:te.user_role)?4:6,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"quantity",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Available Quantity",type:"number",style:{paddingRight:0},InputProps:{inputProps:{max:100,min:0},endAdornment:(0,W.jsxs)(x.Z,{size:"small","aria-label":"small button group",orientation:"vertical",children:[(0,W.jsx)(s.Z,{color:"primary",variant:"text",onClick:function(){return t.mutators.onChangeQuantity(1)},children:(0,W.jsx)(P.Z,{icon:"eva:plus-fill"})}),(0,W.jsx)(s.Z,{color:"error",variant:"text",onClick:function(){return t.mutators.onChangeQuantity(-1)},children:(0,W.jsx)(P.Z,{icon:"eva:minus-fill"})})]})}},e))}})}),(0,W.jsx)(d.ZP,{item:!0,xs:"brand"!==(null===te||void 0===te?void 0:te.user_role)?4:6,mt:3,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"discount",children:function(e){return(0,W.jsx)(k.Z,(0,r.Z)({label:"Discount",type:"number",style:{paddingRight:0},InputProps:{inputProps:{min:0}}},e))}})}),G.find((function(e){return e._id===t.getState().values.category}))&&(0,W.jsx)(d.ZP,{item:!0,xs:"brand"!==(null===te||void 0===te?void 0:te.user_role)?12:6,children:(0,W.jsx)(C.gN,{fullWidth:!0,name:"size",type:"checkbox",children:function(e){var n,i;return(0,W.jsxs)(p.Z,{fullWidth:!0,children:["Available Size:",(0,W.jsx)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-evenly",padding:10},children:""!==G.find((function(e){return e._id===t.getState().values.category}))&&(null===(n=z[null===(i=G.find((function(e){return e._id===t.getState().values.category})))||void 0===i?void 0:i.sizeType])||void 0===n?void 0:n.map((function(n,i){return(0,W.jsx)(m.Z,{control:(0,W.jsx)(g.Z,(0,r.Z)({name:n,onChange:function(e){t.mutators.onChangeCheckBox(n)},checked:t.getState().values.size.includes(n)},e)),label:n},i)})))})]})}})}),(0,W.jsx)(d.ZP,{item:!0,xs:12,children:(0,W.jsx)(C.gN,{name:"description",render:function(e){var n=e.input;return(0,W.jsx)(j.Z,(0,r.Z)((0,r.Z)({fullWidth:!0},n),{},{label:"Product Description",multiline:!0,rows:6}))}})}),(0,W.jsx)(u.Z,{variant:"h4",sx:{marginTop:5,marginLeft:5},children:"Upload Images:"}),(0,W.jsxs)(d.ZP,{item:!0,xs:12,style:{flexDirection:"row",display:"flex"},children:[(null===ce||void 0===ce?void 0:ce.length)>0&&(null===ce||void 0===ce?void 0:ce.map((function(e){return(0,W.jsx)(W.Fragment,{children:(0,W.jsxs)(Z.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center",display:"grid",marginRight:5},children:[(0,W.jsx)(P.Z,{icon:"mdi:close-circle-outline",sx:{width:25,height:25,position:"absolute",right:5,top:5,zIndex:9999},onClick:function(){return function(e){var n=ce.filter((function(n){return n!==e}));ue(n)}(e)}}),(0,W.jsx)(b.Z,{children:(0,W.jsx)("img",{src:URL.createObjectURL(e),alt:""})})]})})}))),(0,W.jsx)(Z.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center"},children:(0,W.jsxs)(b.Z,{style:{justifyContent:"center"},children:[(0,W.jsx)("input",{ref:ie,style:{display:"none"},type:"file",accept:"image/*",onChange:function(e){return ue((function(n){return[].concat((0,i.Z)(n),[e.target.files[0]])}))},multiple:!0}),(0,W.jsx)(y.Z,{onClick:function(){return ie.current.click()},children:(0,W.jsx)(P.Z,{icon:"mdi:file-image-plus-outline",sx:{width:80,height:80}})})]})})]}),(0,W.jsxs)(u.Z,{variant:"h4",sx:{marginTop:5,marginLeft:5},children:["Upload Size Chart"," ",(0,W.jsx)("span",{style:{color:"#b2b2b2"},children:"(optional)"}),":"]}),(0,W.jsxs)(d.ZP,{item:!0,xs:12,style:{flexDirection:"row",display:"flex"},children:[Y&&(0,W.jsxs)(Z.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center",display:"grid",marginRight:5},children:[(0,W.jsx)(P.Z,{icon:"mdi:close-circle-outline",sx:{width:25,height:25,position:"absolute",right:5,top:5,zIndex:9999},onClick:function(){return $("")}}),(0,W.jsx)(b.Z,{children:(0,W.jsx)("img",{src:URL.createObjectURL(Y)})})]}),(0,W.jsx)(Z.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center"},children:(0,W.jsxs)(b.Z,{style:{justifyContent:"center"},children:[(0,W.jsx)("input",{ref:oe,style:{display:"none"},type:"file",accept:"image/*",onChange:function(e){return $((function(){return e.target.files[0]}))}}),(0,W.jsx)(y.Z,{onClick:function(){return oe.current.click()},children:(0,W.jsx)(P.Z,{icon:"mdi:file-image-plus-outline",sx:{width:80,height:80}})})]})})]})]}),(0,W.jsx)(d.ZP,{container:!0,direction:"row",justifyContent:"center",alignItems:"center",m:4,children:(0,W.jsx)(s.Z,{variant:"contained",size:"large",type:"submit",children:"Save"})})]})}})]})}}}]);
//# sourceMappingURL=540.b6767f6e.chunk.js.map
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists