/
home
/
infinitibizsol
/
www
/
auction-sync.com
/
static
/
js
/
File Upload :
llllll
Current File: /home/infinitibizsol/www/auction-sync.com/static/js/824.0bcf08ea.chunk.js
"use strict";(self.webpackChunk_minimal_material_kit_react=self.webpackChunk_minimal_material_kit_react||[]).push([[824],{4469:(e,t,n)=>{var i=n(1243),r=n(6382),o=n(9113);const a=n(644).Z.getItem("userToken");(0,r.hg)("products/create",(async(e,t)=>{let{rejectWithValue:n}=t;try{const t={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}};i.Z.post("".concat(o.v,"/product"),e,t).then((e=>{console.log("Product Action",null===e||void 0===e?void 0:e.data)}))}catch(r){if(r.response&&r.response.data.message)return n(r.response.data.message)}})),(0,r.hg)("products/get",(async(e,t)=>{let{id:n}=e,{rejectWithValue:r}=t;console.log("[getProductsForBrand]",n);try{const e={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}},{data:t}=await i.Z.get("".concat(o.v,"/product/").concat(n),e);if(t)return console.log("[getProductsForBrand]",t),t}catch(l){if(l.response&&l.response.data.message)return r(l.response.data.message)}})),(0,r.hg)("products/getAll",(async(e,t)=>{let{}=e,{rejectWithValue:n}=t;try{const e={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}},{data:t}=await i.Z.get("".concat(o.v,"/products"),e);if(t)return t.products}catch(r){if(r.response&&r.response.data.message)return n(r.response.data.message)}})),(0,r.hg)("product/edit",(async(e,t)=>{let{id:n,values:r}=e,{rejectWithValue:l}=t;try{const e={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}};console.log("Action",n,r);const t=await i.Z.put("".concat(o.v,"/product/").concat(n),r,e);return null!==t&&void 0!==t&&t.data&&console.log("Product edit payload",null===t||void 0===t?void 0:t.data),null===t||void 0===t?void 0:t.data}catch(u){var s,c,d;return u.response?l(null===u||void 0===u||null===(s=u.response)||void 0===s||null===(c=s.data)||void 0===c||null===(d=c.error)||void 0===d?void 0:d.message):l(u.message)}})),(0,r.hg)("product/delete",(async(e,t)=>{let{rejectWithValue:n}=t;try{const t={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}},{data:n}=await i.Z.delete("".concat(o.v,"/product/").concat(e),t);if(n)return n}catch(c){var r,l,s;return c.response?n(null===c||void 0===c||null===(r=c.response)||void 0===r||null===(l=r.data)||void 0===l||null===(s=l.error)||void 0===s?void 0:s.message):n(c.message)}})),(0,r.hg)("product/sort",(async(e,t)=>{let{sortBy:n,sort:r}=e,{rejectWithValue:l}=t;try{let e=o.v+"/product/filter";n&&(e=o.v+"/product/filter?sortBy=".concat(n,"&sort=").concat(r));const t={headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}},{data:l}=await i.Z.get("".concat(e),t);if(l)return console.log("Product sort payload",l),l}catch(u){var s,c,d;return u.response?l(null===u||void 0===u||null===(s=u.response)||void 0===s||null===(c=s.data)||void 0===c||null===(d=c.error)||void 0===d?void 0:d.message):l(u.message)}}))},824:(e,t,n)=>{n.r(t),n.d(t,{default:()=>z});var i=n(2791),r=n(1614),o=n(3767),a=n(890),l=n(4518),s=n(1889),c=n(8096),d=n(4613),u=n(9321),h=n(3786),p=n(2199),g=n(5523),m=n(9174),x=n(7391),j=n(7621),v=n(9504),y=n(3400),f=n(5078),Z=(n(5985),n(4600)),b=n(3609),C=n(7689),P=n(9434),w=(n(4469),n(9113)),A=n(1243),_=n(644),k=n(184);window.Buffer=window.Buffer||n(9778).lW;const W={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]},z=()=>{const e=(0,C.s0)(),[t,n]=((0,P.I0)(),(0,i.useState)([])),[z,B]=(0,i.useState)([]),[N,S]=(0,i.useState)(""),{brandInfo:I,userInfo:T}=(0,P.v9)((e=>e.auth)),q=null===T||void 0===T?void 0:T.user_role,R=null===I||void 0===I?void 0:I.brand_id,V=_.Z.getItem("userToken");(0,i.useEffect)((()=>{A.Z.get("".concat(w.v,"/brands/"),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(V)}}).then((e=>{n(e.data)})).catch((e=>{console.log("[Error]",e)}))}),[V]),(0,i.useEffect)((()=>{A.Z.get("".concat(w.v,"/category/"),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(V)}}).then((e=>{B(null===e||void 0===e?void 0:e.data)})).catch((e=>{console.log("[Error]",e)}))}),[V]);const L=(0,i.useRef)(),U=(0,i.useRef)(),[D,Q]=(0,i.useState)([]);return(0,k.jsxs)(r.Z,{children:[(0,k.jsxs)(o.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",mb:5,children:[(0,k.jsx)(a.Z,{variant:"h4",sx:{mb:5},children:"Create Products"}),(0,k.jsx)(l.Z,{variant:"contained",onClick:()=>e("/dashboard/".concat(q,"/products"),{replace:!0}),children:"Back To Product"})]}),(0,k.jsx)(f.l0,{onSubmit:()=>{console.log("Submit")},initialValues:{name:"",category:"",brand:"brand"===(null===T||void 0===T?void 0:T.user_role)?R:"",productCode:"",color:"",size:[],price:0,quantity:1,discount:0,description:"",imgUrl:[]},validate:e=>{console.log("[validate]",e.size);const t={};return e.name||(t.name="Name is required!"),e.category||(t.category="Category is required!"),e.brand||"brand"===(null===T||void 0===T?void 0:T.user_role)||(t.brand="Brand name is required!"),0===e.price&&(t.price="Price is required!"),e.description||(t.description="Description is required!"),e.quantity||(t.quantity="Quantity is required!"),e.productCode||(t.productCode="ProductCode is required!"),e.color||(t.color="Color is required!"),console.log("ere",t),t},mutators:{onChangeQuantity:(e,t,n)=>{n.changeValue(t,"quantity",(t=>(t=>{if(t>1||1===t&&1==e)return Number(null!==t&&void 0!==t?t:1)+Number(e);return 1})(t)))},onChangeCheckBox:(e,t,n)=>{n.changeValue(t,"size",(t=>{return-1!==(n=t).indexOf(e[0])?n.filter((t=>t!==e[0])):[...n,e[0]];var n}))}},render:e=>{let{handleSubmit:n,errors:i,form:r}=e;return(0,k.jsxs)("form",{onSubmit:n,children:[(0,k.jsxs)(s.ZP,{container:!0,spacing:4,children:[(0,k.jsx)(s.ZP,{item:!0,xs:6,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"name",children:e=>(0,k.jsx)(Z.Z,{label:"Product Name",...e})})}),(0,k.jsx)(s.ZP,{item:!0,xs:6,children:(0,k.jsx)(f.gN,{fullWidth:!0,component:"select",name:"category",children:e=>{let{input:t,meta:n,options:i}=e;return(0,k.jsxs)(c.Z,{fullWidth:!0,children:[(0,k.jsx)(d.Z,{id:"brand-label",children:"Product Category"}),(0,k.jsx)(u.Z,{labelId:"brand-label",name:"category",options:z,MenuProps:{style:{maxHeight:300}},...t,children:null===z||void 0===z?void 0:z.map(((e,t)=>(0,k.jsx)(h.Z,{value:e._id,children:e.categoryName},t)))})]})}})}),"brand"!==(null===T||void 0===T?void 0:T.user_role)&&(0,k.jsx)(s.ZP,{item:!0,xs:4,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"brand",children:e=>{var n;let{input:i,meta:r,options:o}=e;return(0,k.jsxs)(c.Z,{fullWidth:!0,children:[(0,k.jsx)(d.Z,{id:"brand-label",children:"Brand Name"}),(0,k.jsx)(u.Z,{labelId:"brand-label",name:"brand",options:t,onChange:e=>i.onChange(e),MenuProps:{style:{maxHeight:300}},children:null===t||void 0===t||null===(n=t.brands)||void 0===n?void 0:n.map(((e,t)=>(0,k.jsx)(h.Z,{value:e._id,children:e.brandName},t)))})]})}})}),(0,k.jsx)(s.ZP,{item:!0,xs:4,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"productCode",children:e=>(0,k.jsx)(Z.Z,{label:"Product Code",...e})})}),(0,k.jsx)(s.ZP,{item:!0,xs:4,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"color",children:e=>(0,k.jsx)(Z.Z,{label:"Product Color",...e})})}),(0,k.jsx)(s.ZP,{item:!0,xs:"brand"!==(null===T||void 0===T?void 0:T.user_role)?4:6,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"price",children:e=>(0,k.jsx)(Z.Z,{label:"Price",type:"number",style:{paddingRight:0},InputProps:{inputProps:{min:0}},...e})})}),(0,k.jsx)(s.ZP,{item:!0,xs:"brand"!==(null===T||void 0===T?void 0:T.user_role)?4:6,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"quantity",children:e=>(0,k.jsx)(Z.Z,{label:"Available Quantity",type:"number",style:{paddingRight:0},InputProps:{inputProps:{max:100,min:0},endAdornment:(0,k.jsxs)(p.Z,{size:"small","aria-label":"small button group",orientation:"vertical",children:[(0,k.jsx)(l.Z,{color:"primary",variant:"text",onClick:()=>r.mutators.onChangeQuantity(1),children:(0,k.jsx)(b.Z,{icon:"eva:plus-fill"})}),(0,k.jsx)(l.Z,{color:"error",variant:"text",onClick:()=>r.mutators.onChangeQuantity(-1),children:(0,k.jsx)(b.Z,{icon:"eva:minus-fill"})})]})},...e})})}),(0,k.jsx)(s.ZP,{item:!0,xs:"brand"!==(null===T||void 0===T?void 0:T.user_role)?4:6,mt:3,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"discount",children:e=>(0,k.jsx)(Z.Z,{label:"Discount",type:"number",style:{paddingRight:0},InputProps:{inputProps:{min:0}},...e})})}),z.find((e=>e._id===r.getState().values.category))&&(0,k.jsx)(s.ZP,{item:!0,xs:"brand"!==(null===T||void 0===T?void 0:T.user_role)?12:6,children:(0,k.jsx)(f.gN,{fullWidth:!0,name:"size",type:"checkbox",children:e=>{var t,n;return(0,k.jsxs)(c.Z,{fullWidth:!0,children:["Available Size:",(0,k.jsx)(s.ZP,{item:!0,lg:12,children:""!==z.find((e=>e._id===r.getState().values.category))&&(null===(t=W[null===(n=z.find((e=>e._id===r.getState().values.category)))||void 0===n?void 0:n.sizeType])||void 0===t?void 0:t.map(((t,n)=>(0,k.jsx)(g.Z,{control:(0,k.jsx)(m.Z,{name:t,onChange:e=>{r.mutators.onChangeCheckBox(t)},...e}),label:t},n))))})]})}})}),(0,k.jsx)(s.ZP,{item:!0,xs:12,children:(0,k.jsx)(f.gN,{name:"description",render:e=>{let{input:t}=e;return(0,k.jsx)(x.Z,{fullWidth:!0,...t,label:"Product Description",multiline:!0,rows:6})}})}),(0,k.jsx)(a.Z,{variant:"h4",sx:{marginTop:5,marginLeft:5},children:"Upload Images:"}),(0,k.jsxs)(s.ZP,{item:!0,xs:12,style:{flexDirection:"row",display:"flex"},children:[(null===D||void 0===D?void 0:D.length)>0&&(null===D||void 0===D?void 0:D.map((e=>(0,k.jsx)(k.Fragment,{children:(0,k.jsxs)(j.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center",display:"grid",marginRight:5},children:[(0,k.jsx)(b.Z,{icon:"mdi:close-circle-outline",sx:{width:25,height:25,position:"absolute",right:5,top:5,zIndex:9999},onClick:()=>(e=>{const t=D.filter((t=>t!==e));Q(t)})(e)}),(0,k.jsx)(v.Z,{children:(0,k.jsx)("img",{src:URL.createObjectURL(e),alt:""})})]})})))),(0,k.jsx)(j.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center"},children:(0,k.jsxs)(v.Z,{style:{justifyContent:"center"},children:[(0,k.jsx)("input",{ref:L,style:{display:"none"},type:"file",accept:"image/*",onChange:e=>Q((t=>[...t,e.target.files[0]])),multiple:!0}),(0,k.jsx)(y.Z,{onClick:()=>L.current.click(),children:(0,k.jsx)(b.Z,{icon:"mdi:file-image-plus-outline",sx:{width:80,height:80}})})]})})]}),(0,k.jsxs)(a.Z,{variant:"h4",sx:{marginTop:5,marginLeft:5},children:["Upload Size Chart ",(0,k.jsx)("span",{style:{color:"#b2b2b2"},children:"(optional)"}),":"]}),(0,k.jsxs)(s.ZP,{item:!0,xs:12,style:{flexDirection:"row",display:"flex"},children:[N&&(0,k.jsxs)(j.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center",display:"grid",marginRight:5},children:[(0,k.jsx)(b.Z,{icon:"mdi:close-circle-outline",sx:{width:25,height:25,position:"absolute",right:5,top:5,zIndex:9999},onClick:()=>S("")}),(0,k.jsx)(v.Z,{children:(0,k.jsx)("img",{src:URL.createObjectURL(N)})})]}),(0,k.jsx)(j.Z,{sx:{width:150,height:150,justifyContent:"center",alignContent:"center"},children:(0,k.jsxs)(v.Z,{style:{justifyContent:"center"},children:[(0,k.jsx)("input",{ref:U,style:{display:"none"},type:"file",accept:"image/*",onChange:e=>S((()=>e.target.files[0]))}),(0,k.jsx)(y.Z,{onClick:()=>U.current.click(),children:(0,k.jsx)(b.Z,{icon:"mdi:file-image-plus-outline",sx:{width:80,height:80}})})]})})]})]}),(0,k.jsx)(s.ZP,{container:!0,direction:"row",justifyContent:"center",alignItems:"center",m:4,children:(0,k.jsx)(l.Z,{variant:"contained",size:"large",type:"submit",children:"Save"})})]})}})]})}}}]); //# sourceMappingURL=824.0bcf08ea.chunk.js.map
Copyright ©2k19 -
Hexid
|
Tex7ure