1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[506],{39786(){},40506(e,t,a){a.r(t),a.d(t,{default:()=>j});var i=a(89379),n=a(25850),s=a(64435),d=a(42609),l=a(36497),r=a(5766),o=a.n(r),c=a(65043),u=a(49092),p=a(11238),h=a(95399),g=a(40361),v=(a(39786),a(43848));const m={products:[{title:"Sku",key:"sku"},{title:"Name",key:"name"},{title:"Stock",key:"stock"},{title:"Buy Price",key:"price"},{title:"Sell Price",key:"seller_price"},{title:"Discount",key:"discount_price"}],translate_products:[{title:"Sku",key:"sku"},{title:"name",key:"name"},{title:"long description",key:"long_description"}],action:""},k={products:[{title:"SKU",dataIndex:"sku",key:"sku"},{title:"Product Number",dataIndex:"product_number",key:"product_number"},{title:"Name",dataIndex:"name",key:"name"},{title:"EAN",dataIndex:"ean",key:"ean"},{title:"Image URL",dataIndex:"image",key:"image"},{title:"Long Description",dataIndex:"ean",key:"ean"},{title:"Length",dataIndex:"length",key:"length"},{title:"Weight",dataIndex:"weight",key:"weight"},{title:"Width",dataIndex:"width",key:"width"},{title:"Height",dataIndex:"height",key:"height"},{title:"Price",dataIndex:"price",key:"price"},{title:"Stock",dataIndex:"stock",key:"stock"},{title:"Rating",dataIndex:"rating",key:"rating"}],translate_products:[{title:"SKU",dataIndex:"sku",key:"sku"},{title:"Name",dataIndex:"name",key:"name"},{title:"Long Description",dataIndex:"long_description",key:"long_description"}],products_price:[{title:"SKU",dataIndex:"sku",key:"sku"},{title:"Name",dataIndex:"name",key:"name"},{title:"EAN",dataIndex:"ean",key:"ean"},{title:"Seller",dataIndex:"seller",key:"seller"},{title:"Rating",dataIndex:"rating",key:"rating"},{title:"CNCODE",dataIndex:"cncode",key:"cncode"},{title:"Stock",dataIndex:"stock",key:"stock"},{title:"Purchase Price",dataIndex:"purchase_price",key:"purchase_price"},{title:"Price",dataIndex:"price",key:"price"},{title:"Discount Price",dataIndex:"discount_price",key:"discount_price"},{title:"TVSH",dataIndex:"tvsh",key:"tvsh"}]};var x=a(89421),y=(a(48046),a(70579));const _=e=>{let{actionData:t,searchValue:a,languages:r,setSearchValue:o,importData:u,handleOnChange:p,loadingImport:h,form:v,action:m}=e;const k=(0,c.useRef)(),_=e=>{o((0,i.A)((0,i.A)({},a),e))};return(0,y.jsx)(y.Fragment,{children:"action"!=t&&(0,y.jsxs)("div",{className:"product-filter import-design",children:[(0,y.jsx)("div",{children:(0,y.jsx)(s.A,{direction:"horizontal",className:"filters",children:(0,y.jsxs)(n.A,{form:v,layout:"inline",children:["products_price"!=m&&(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(n.A.Item,{name:"translated",label:"Language:",className:"select-width",children:(0,y.jsx)(l.A,{dropdownMatchSelectWidth:!1,suffixIcon:(0,y.jsx)("img",{src:g.T.arrowCDown}),className:"language_fliter",placeholder:"All",onChange:e=>_({language:e}),bordered:!1,defaultValue:"English",children:r.map(e=>(0,y.jsx)(l.A.Option,{value:e.iso_code,children:e.name},e.iso_code))})})}),(0,y.jsx)(n.A.Item,{name:"file",label:"Select File:",className:"select-width",children:(0,y.jsx)(d.A,{className:"import-design-form-input",type:"file",accept:".xlsx",onChange:p,ref:k})})]})})}),(0,y.jsx)("div",{children:(0,y.jsx)(x.A,{onClick:u,loading:h,disabled:h,children:"Import"})})]})})},I=[{id:1,name:"Products",url:"import-products",colName:"products"}];var f=a(16994);a(53619);const S=e=>{let{loading:t,data:a,action:i}=e;const n=k[i];return(0,y.jsx)(f.A,{loading:t,className:"table",columns:n,dataSource:a,rowKey:e=>{let{sku:t}=e;return t},pagination:{defaultPageSize:50}})},j=()=>{const[e]=n.A.useForm(),{t:t}=(0,u.B)(),[a,r]=(0,c.useState)(!1),[k,x]=(0,c.useState)(!1),[f,j]=(0,c.useState)(!1),[A,N]=(0,c.useState)([]),[b,w]=(0,c.useState)([]),[P,C]=(0,c.useState)([]),[O,D]=(0,c.useState)("action"),[M,E]=(0,c.useState)({language:"en"}),T=e=>{(0,v.l)("error",e),r(!1),x(!1)},F=e=>{var t;const a=P.find(e=>e.id===(null===M||void 0===M?void 0:M.seller));return(null===a||void 0===a||null===(t=a.name.substring(0,3))||void 0===t?void 0:t.toUpperCase())+"-"+e};return(0,c.useEffect)(()=>{(0,h.A)("seller","GET",null).then(e=>{let{statusIsOk:t,statusMessage:a,result:i}=e;t||(0,v.l)("error",a),t&&C(i)}).catch(e=>{let{statusMessage:t}=e;return T(t)}),(0,h.A)("language","GET",null).then(e=>{let{statusIsOk:t,statusMessage:a,result:i}=e;t||(0,v.l)("error",a),t&&w(i.results)}).catch(e=>{let{statusMessage:t}=e;return(0,v.l)("error",t)})},[]),(0,y.jsxs)("div",{className:"dashboard-container",children:[(0,y.jsx)("div",{className:"dashboard-header import-design-header",children:(0,y.jsx)("div",{children:(0,y.jsx)("h2",{children:t("import")})})}),(0,y.jsx)("div",{className:"dashboard-header import-design-header",children:(0,y.jsx)("div",{children:(0,y.jsx)(s.A,{align:"center",children:(0,y.jsx)(d.A.Group,{className:"import-design-form",children:(0,y.jsx)(l.A,{placeholder:"Select action",onChange:t=>{N([]),e.resetFields(),D(t),j(!0)},size:"large",suffixIcon:(0,y.jsx)("img",{src:g.T.arrowCDown}),getPopupContainer:e=>e.parentNode,children:I.map(e=>{let{id:t,name:a,url:i,colName:n}=e;return(0,y.jsx)(l.A.Option,{value:n,children:a},t)})})})})})}),(0,y.jsx)("div",{className:"dashboard-header import-design-header",children:(0,y.jsx)(_,{form:e,setSearchValue:E,searchValue:M,languages:b,actionData:O,importData:()=>
1{if(x(!0),"action"!=m[O])switch(O.toString()){case"translate_products":(0,h.A)("import/translate/".concat(null===M||void 0===M?void 0:M.language,"/").concat(null===M||void 0===M?void 0:M.seller),"POST",{data:A}).then(e=>{let{statusIsOk:t,statusMessage:a,result:i}=e;t||T(a),t&&(x(!1),(0,v.l)("success","Sucessfully updated ".concat(i.length," products")))}).catch(e=>{let{statusMessage:t}=e;return T(t)});break;case"products":(0,h.A)("import/products/import/".concat(null===M||void 0===M?void 0:M.language,"/").concat(null===M||void 0===M?void 0:M.seller),"POST",{data:A}).then(e=>{let{statusIsOk:t,statusMessage:a,result:i}=e;t||T(a),t&&(x(!1),(0,v.l)("success","Sucessfully updated ".concat(i.length," products")))}).catch(e=>{let{error:t}=e;return T(t)});break;case"products_price":(0,h.A)("import/products/pricing","POST",{data:null===A||void 0===A?void 0:A.map(e=>(0,i.A)((0,i.A)({stock:Number(e.stock||0),tvsh:(null===e||void 0===e?void 0:e.tvsh)||18,id:null===e||void 0===e?void 0:e.id,price:null===e||void 0===e?void 0:e.price,sku:null===e||void 0===e?void 0:e.sku,net_price:0,discount_price:(null===e||void 0===e?void 0:e.discount_price)||0},(null===e||void 0===e?void 0:e.discount_price)&&{discount_price:(null===e||void 0===e?void 0:e.discount_price)||0}),{},{product:{id:null===e||void 0===e?void 0:e.product_id,is_updated:!0}}))}).then(e=>{let{statusIsOk:t,statusMessage:a}=e;t||T(a),t&&(x(!1),(0,v.l)("success","Sucessfully updated products"))}).catch(e=>{let{statusMessage:t}=e;return T(t)})}},handleOnChange:e=>{let{target:{files:t}}=e;t&&null!==t&&void 0!==t&&t.length&&(r(!0),o().parse(t[0],{header:!0,skipEmptyLines:!0,delimiter:",",encoding:"utf8",complete:async function(e){let a;if("action"!=m[O])switch(O.toString()){case"translate_products":a=e.data.map(e=>({sku:null===e||void 0===e?void 0:e.sku,name:null===e||void 0===e?void 0:e.name,short_description:(null===e||void 0===e?void 0:e.short_description)||" ",long_description:(null===e||void 0===e?void 0:e.long_description)||" "}));break;case"products":a=e.data.map(e=>({sku:F(null===e||void 0===e?void 0:e.sku),product_number:null===e||void 0===e?void 0:e.sku,name:null===e||void 0===e?void 0:e.name,ean:null===e||void 0===e?void 0:e.ean,image:null===e||void 0===e?void 0:e.image,long_description:(null===e||void 0===e?void 0:e.description)||" ",length:(null===e||void 0===e?void 0:e.length)||"0",weight:(null===e||void 0===e?void 0:e.weight)||"0",width:(null===e||void 0===e?void 0:e.width)||"0",height:(null===e||void 0===e?void 0:e.height)||"0",price:(null===e||void 0===e?void 0:e.price)||"0",stock:(null===e||void 0===e?void 0:e.stock)||"0",rating:(null===e||void 0===e?void 0:e.rating)||0}));break;case"products_price":i=t[0],new Promise((e,t)=>{const a=new FileReader;a.readAsArrayBuffer(i),a.onload=t=>{var a;const i=null===t||void 0===t||null===(a=t.target)||void 0===a?void 0:a.result,n=p.LF(i,{type:"buffer"}),s=n.SheetNames[0],d=n.Sheets[s],l=p.Wp.sheet_to_json(d,{header:1});l.shift(),e(l)},a.onerror=e=>{t(e)}}).then(e=>{const t=e.map(e=>({id:e[0],product_id:e[1],sku:"RDU-".concat(e[2]),ean:e[3],name:e[4],seller:e[5],rating:e[6],cncode:e[7],stock:Number(e[8]||0),purchase_price:e[9],price:e[10],discount_price:e[11]||0,tvsh:e[12]}));N(t)})}var i;N(a),r(!1)}}))},loadingImport:k,action:O})}),f&&(0,y.jsx)(S,{loading:a,data:A,action:O})]})}}}]); 2//# sourceMappingURL=506.585ae01f.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.