1/*! For license information please see 948.14cb1dee.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkoutex_website=self.webpackChunkoutex_website||[]).push([[948],{39292:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},42043:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]])},43948:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var a=s(89379),r=s(65043),l=s(17868),i=s(70067),c=s(42043),d=s(71360),n=s(50516),o=s(88693),h=s(39292),x=s(9855),m=s(40614),u=s(79989),g=s(70579);function p(){const{products:e,addProduct:t,updateProduct:s,deleteProduct:p,loading:b,error:j,refreshData:v}=(0,l.q)(),[y,w]=(0,r.useState)(""),[N,f]=(0,r.useState)(!1),[A,k]=(0,r.useState)(null),C={type:"b2c",name:"",price:"",discountValue:"",discountType:"percent",category:"",description:"",images:[],rating:5,sizes:[],characteristics:[],reviews:[]},[F,P]=(0,r.useState)(C),E=e.filter(e=>e.name&&e.name.toLowerCase().includes(y.toLowerCase())||e.id&&e.id.toString().includes(y)),z=e=>{const t=Array.from(e.target.files);if(0===t.length)return;Promise.all(t.map(e=>new Promise(t=>{const s=new Image,a=new FileReader;a.onload=e=>{s.src=e.target.result,s.onload=()=>{const e=document.createElement("canvas"),a=e.getContext("2d"),r=800;let l=s.width,i=s.height;l>i?l>r&&(i*=r/l,l=r):i>r&&(l*=r/i,i=r),e.width=l,e.height=i,a.drawImage(s,0,0,l,i),t(e.toDataURL("image/jpeg",.7))}},a.readAsDataURL(e)}))).then(e=>{P(t=>(0,a.A)((0,a.A)({},t),{},{images:[...t.images||[],...e]}))})},M=(e,t)=>{P(s=>{const r=[...s.images];return-1===t&&e>0?[r[e],r[e-1]]=[r[e-1],r[e]]:1===t&&e<r.length-1&&([r[e],r[e+1]]=[r[e+1],r[e]]),(0,a.A)((0,a.A)({},s),{},{images:r})})},S=e=>{e.preventDefault();const r=JSON.stringify(F).length;r>38e4?alert("Product data is too large (".concat(Math.round(r/1024),"KB). Please remove some images.")):(A?s(A,F):t((0,a.A)((0,a.A)({},F),{},{createdAt:(new Date).toISOString()})),f(!1))};if(b&&0===e.length)return(0,g.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[50vh] text-gray-400",children:[(0,g.jsx)(c.A,{className:"w-8 h-8 animate-spin mb-4 text-[#FF821C]"}),(0,g.jsx)("p",{children:"Loading products..."})]});if(j)return(0,g.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[50vh] text-red-500",children:[(0,g.jsx)("p",{className:"mb-4",children:j}),(0,g.jsxs)("button",{onClick:v,className:"flex items-center gap-2 bg-[#252525] px-4 py-2 rounded-lg text-white hover:bg-[#333]",children:[(0,g.jsx)(n.A,{className:"w-4 h-4"})," Try Again"]})]});return(0,g.jsxs)("div",{children:[(0,g.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("h1",{className:"text-3xl font-bold text-white mb-2",children:"Product Management"}),(0,g.jsxs)("p",{className:"text-gray-400",children:["Total Products: ",e.length]})]}),(0,g.jsxs)("button",{onClick:()=>{k(null),P(C),f(!0)},className:"bg-[#FF821C] hover:bg-[#e07218] text-white px-4 py-2 rounded-lg flex items-center gap-2 transition-colors font-semibold shadow-lg shadow-[#FF821C]/20",children:[(0,g.jsx)(d.A,{className:"w-4 h-4"}),"Add Product"]})]}),(0,g.jsxs)("div",{className:"relative mb-8",children:[(0,g.jsx)("input",{type:"text",value:y,onChange:e=>w(e.target.value),placeholder:"Search products...",className:"w-full bg-[#1E1E1E] border border-white/10 rounded-xl py-4 px-6 pl-12 text-white placeholder-gray-500 focus:outline-none focus:border-[#FF821C]"}),(0,g.jsx)(h.A,{className:"w-5 h-5 text-gray-500 absolute left-4 top-4.5"})]}),(0,g.jsxs)("div",{className:"bg-[#1E1E1E] border border-white/10 rounded-xl overflow-hidden",children:[(0,g.jsx)("div",{className:"overflow-x-auto",children:(0,g.jsxs)("table",{className:"w-full text-left",children:[(0,g.jsx)("thead",{className:"bg-[#252525] text-gray-400 text-xs uppercase font-bold tracking-wider",children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{className:"p-4 w-20",children:"Img"}),(0,g.jsx)("th",{className:"p-4",children:"Product"}),(0,g.jsx)("th",{className:"p-4",children:"Category"}),(0,g.jsx)("th",{className:"p-4 w-32",children:"Price"}),(0,g.jsx)("th",{className:"p-4 w-32",children:"Discount"}),(0,g.jsx)("th",{className:"p-4 text-right",children:"Actions"})]})}),(0,g.jsx)("tbody",{className:"divide-y divide-white/5 text-sm",children:E.map(e=>{var t,s,r;return(0,g.jsxs)("tr",{className:"hover:bg-white/5 transition-colors group",children:[(0,g.jsx)("td",{className:"p-4",children:(0,g.jsx)("div",{className:"w-12 h-12 bg-black rounded overflow-hidden",children:null!==(t=e.images)&&void 0!==t&&t[0]||e.image_url?(0,g.jsx)("img",{src:(null===(s=e.images)||void 0===s?void 0:s[0])||e.image_url,alt:"",className:"w-full h-full object-cover"}):(0,g.jsx)("div",{className:"w-full h-full flex items-center justify-center text-gray-700 bg-white/5",children:(0,g.jsx)(i.A,{className:"w-6 h-6"})})})}),(0,g.jsxs)("td",{className:"p-4",children:[(0,g.jsx)("div",{className:"font-medium text-white text-base",children:e.name}),(0,g.jsxs)("div",{className:"text-gray-500 text-xs mt-1",children:["Type: ",e.type.toUpperCase()]}),(null===(r=e.sizes)||void 0===r?void 0:r.length)>0&&(0,g.jsxs)("div",{className:"text-gray-500 text-xs mt-0.5",children:["Sizes: ",e.sizes.length]})]}),(0,g.jsx)("td",{className:"p-4 text-gray-400",children:e.category}),(0,g.jsx)("td",{className:"p-4",children:(0,g.jsxs)("span",{className:"text-white font-mono text-base",children:["$",e.price]})}),(0,g.jsx)("td",{className:"p-4",children:e.discountValue>0?(0,g.jsxs)("span",{className:"text-[#FF821C] font-semibold text-xs bg-[#FF821C]/10 px-2 py-1 rounded",children:["-",e.discountValue,"percent"===e.discountType?"%":"$"]}):(0,g.jsx)("span",{className:"text-gray-600",children:"-"})}),(0,g.jsx)("td",{className:"p-4 text-right",children:(0,g.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,g.jsx)("button",{onClick:()=>(e=>{k(e.id),P((0,a.A)((0,a.A)((0,a.A)({},C),e),{},{images:e.images||(e.image_url?[e.image_url]:[]),sizes:e.sizes||[],characteristics:e.characteristics||[]})),f(!0)})(e),className:"text-gray-500 hover:text-white p-2 transition-colors bg-[#252525] hover:bg-[#333] rounded-lg",title:"Edit Full Details",children:(0,g.jsx)(u.A,{className:"w-4 h-4"})}),(0,g.jsx)("button",{onClick:()=>{return t=e.id,void(window.confirm("Are you sure you want to delete this product?")&&p(t));var t},className:"text-gray-500 hover:text-red-500 p-2 transition-colors hover:bg-red-500/10 rounded-lg",title:"Delete",children:(0,g.jsx)(x.A,{className:"w-4 h-4"})})]})})]},e.id)})})]})}),0===E.length&&(0,g.jsxs)("div",{className:"p-12 text-center text-gray-500",children:[(0,g.jsx)(Package,{className:"w-12 h-12 mx-auto mb-4 opacity-20"}),"No products found matching your search."]})]}),N&&(()=>{const e=((e,t,s)=>{const a=parseFloat(e)||0,r=parseFloat(t)||0;return r?"percent"===s?a-a*(r/100):Math.max(0,a-r):a})(F.price,F.discountValue,F.discountType);return(0,g.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm overflow-y-auto",children:(0,g.jsxs)("div",{className:"bg-[#1E1E1E] w-full max-w-4xl rounded-xl border border-white/10 my-8 shadow-2xl",children:[(0,g.jsxs)("div",{className:"p-6 border-b border-white/10 flex justify-between items-center sticky top-0 bg-[#1E1E1E] z-10 rounded-t-xl",children:[(0,g.jsx)("h2",{className:"text-xl font-bold text-white",children:A?"Edit Product":"Add New Product"}),(0,g.jsx)("button",{onClick:()=>f(!1),className:"text-gray-400 hover:text-white",children:(0,g.jsx)(m.A,{className:"w-6 h-6"})})]}),(0,g.jsxs)("form",{onSubmit:S,className:"p-6 space-y-6",children:[(0,g.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Type"}),(0,g.jsxs)("select",{className:"w-full bg-[#252525] border border-white/10 rounded-lg p-3 text-white",value:F.type,onCh
2ange:e=>P((0,a.A)((0,a.A)({},F),{},{type:e.target.value})),children:[(0,g.jsx)("option",{value:"b2c",children:"Customer (B2C)"}),(0,g.jsx)("option",{value:"b2b",children:"Business (B2B)"})]})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Category"}),(0,g.jsx)("input",{required:!0,className:"w-full bg-[#252525] border border-white/10 rounded-lg p-3 text-white",value:F.category,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{category:e.target.value}))})]}),(0,g.jsxs)("div",{className:"md:col-span-2",children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Product Name"}),(0,g.jsx)("input",{required:!0,className:"w-full bg-[#252525] border border-white/10 rounded-lg p-3 text-white",value:F.name,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{name:e.target.value}))})]}),(0,g.jsxs)("div",{className:"p-4 bg-[#252525] rounded-xl md:col-span-2 grid grid-cols-1 md:grid-cols-3 gap-4 border border-white/5",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Regular Price ($)"}),(0,g.jsx)("input",{type:"number",step:"0.01",required:!0,className:"w-full bg-black border border-white/10 rounded-lg p-3 text-white",value:F.price,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{price:e.target.value}))})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Discount"}),(0,g.jsxs)("div",{className:"flex gap-2",children:[(0,g.jsx)("input",{type:"number",step:"0.01",className:"w-full bg-black border border-white/10 rounded-lg p-3 text-white",placeholder:"0",value:F.discountValue,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{discountValue:e.target.value}))}),(0,g.jsxs)("select",{className:"bg-black border border-white/10 rounded-lg px-2 text-white",value:F.discountType,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{discountType:e.target.value})),children:[(0,g.jsx)("option",{value:"percent",children:"%"}),(0,g.jsx)("option",{value:"fixed",children:"$"})]})]})]}),(0,g.jsxs)("div",{className:"flex flex-col justify-end",children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Final Price"}),(0,g.jsxs)("div",{className:"text-2xl font-bold text-[#FF821C]",children:["$",e.toFixed(2)]})]})]}),(0,g.jsxs)("div",{className:"md:col-span-2",children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Description"}),(0,g.jsx)("textarea",{required:!0,className:"w-full bg-[#252525] border border-white/10 rounded-lg p-3 text-white h-32",value:F.description,onChange:e=>P((0,a.A)((0,a.A)({},F),{},{description:e.target.value}))})]}),(0,g.jsxs)("div",{className:"md:col-span-2",children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Sizes (comma separated)"}),(0,g.jsx)("input",{className:"w-full bg-[#252525] border border-white/10 rounded-lg p-3 text-white",placeholder:"S, M, L, XL",value:F.sizes?F.sizes.join(", "):"",onChange:e=>P((0,a.A)((0,a.A)({},F),{},{sizes:e.target.value.split(",").map(e=>e.trim())}))})]}),(0,g.jsxs)("div",{className:"md:col-span-2",children:[(0,g.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Characteristics"}),(0,g.jsxs)("div",{className:"space-y-2",children:[(F.characteristics||[]).map((e,t)=>(0,g.jsxs)("div",{className:"flex gap-2",children:[(0,g.jsx)("input",{placeholder:"Key",className:"w-1/3 bg-[#252525] border border-white/10 rounded-lg p-2 text-white text-sm",value:e.key,onChange:e=>{const s=[...F.characteristics];s[t].key=e.target.value,P((0,a.A)((0,a.A)({},F),{},{characteristics:s}))}}),(0,g.jsx)("input",{placeholder:"Value",className:"w-2/3 bg-[#252525] border border-white/10 rounded-lg p-2 text-white text-sm",value:e.value,onChange:e=>{const s=[...F.characteristics];s[t].value=e.target.value,P((0,a.A)((0,a.A)({},F),{},{characteristics:s}))}}),(0,g.jsx)("button",{type:"button",onClick:()=>{const e=F.characteristics.filter((e,s)=>s!==t);P((0,a.A)((0,a.A)({},F),{},{characteristics:e}))},className:"p-2 text-gray-500 hover:text-red-500",children:(0,g.jsx)(x.A,{className:"w-4 h-4"})})]},t)),(0,g.jsxs)("button",{type:"button",onClick:()=>P((0,a.A)((0,a.A)({},F),{},{characteristics:[...F.characteristics||[],{key:"",value:""}]})),className:"text-xs text-[#FF821C] hover:underline flex items-center gap-1",children:[(0,g.jsx)(d.A,{className:"w-3 h-3"})," Add Characteristic"]})]})]}),(0,g.jsxs)("div",{className:"md:col-span-2",children:[(0,g.jsx)("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Product Images"}),(0,g.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[F.images.map((e,t)=>(0,g.jsxs)("div",{className:"relative aspect-square bg-black rounded-lg overflow-hidden group border border-white/10",children:[(0,g.jsx)("img",{src:e,alt:"Product ".concat(t),className:"w-full h-full object-cover"}),(0,g.jsx)("button",{type:"button",onClick:()=>{return e=t,void P(t=>(0,a.A)((0,a.A)({},t),{},{images:t.images.filter((t,s)=>s!==e)}));var e},className:"absolute top-1 right-1 p-1 bg-red-500/80 text-white rounded-full opacity-0 group-hover:opacity-100 transition-opacity z-10",children:(0,g.jsx)(m.A,{className:"w-4 h-4"})}),(0,g.jsxs)("div",{className:"absolute bottom-1 left-1 right-1 flex justify-between opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,g.jsx)("button",{type:"button",onClick:()=>M(t,-1),className:"p-1 bg-black/60 text-white rounded ".concat(0===t?"invisible":""),children:"<"}),(0,g.jsx)("button",{type:"button",onClick:()=>M(t,1),className:"p-1 bg-black/60 text-white rounded ".concat(t===F.images.length-1?"invisible":""),children:">"})]})]},t)),(0,g.jsxs)("label",{className:"aspect-square bg-[#252525] border-2 border-dashed border-white/10 rounded-lg flex flex-col items-center justify-center cursor-pointer hover:border-[#FF821C] hover:text-[#FF821C] text-gray-400 transition-colors",children:[(0,g.jsx)(i.A,{className:"w-8 h-8 mb-2"}),(0,g.jsx)("span",{className:"text-xs",children:"Add Photos"}),(0,g.jsx)("input",{type:"file",multiple:!0,accept:"image/*",onChange:z,className:"hidden"})]})]})]})]}),(0,g.jsxs)("div",{className:"pt-6 border-t border-white/10 flex justify-end gap-3 sticky bottom-0 bg-[#1E1E1E] -mb-6 pb-6 rounded-b-xl",children:[(0,g.jsx)("button",{type:"button",onClick:()=>f(!1),className:"px-4 py-2 text-gray-400 hover:text-white",children:"Cancel"}),(0,g.jsxs)("button",{type:"submit",className:"px-6 py-2 bg-[#FF821C] hover:bg-[#e07218] text-white rounded-lg font-bold flex items-center gap-2",children:[(0,g.jsx)(o.A,{className:"w-4 h-4"})," ",A?"Save Changes":"Create Product"]})]})]})]})})})()]})}},50516:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},70067:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},79989:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]])},88693:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(77784).A)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])}}]); 3//# sourceMappingURL=948.14cb1dee.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.