PageSourceSearch

https://sendunlimitedemail.com/sue/mod-MiRKSWPd.js

js sendunlimitedemail.com collected 2026-10-05 06:26:02 UTC 8,886 bytes, 1 lines download raw bytes

1import{k as E,r as a,e as d,t as x,j as e,P as R,T}from"./edge-BOITG1XR.js";import{L as N}from"./mod-DxqX0N6D.js";import{R as _}from"./mod-RPxq32x0.js";import{C as M}from"./mod-gbHpssdV.js";import{S as K}from"./mod-CKg_ZYcm.js";import{S as O}from"./mod-C9xhOiHj.js";import{X as W}from"./mod-C3kaoPgB.js";import{P as F}from"./mod-BVSlmYWv.js";const z=[["path",{d:"M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11",key:"pb2vm6"}],["path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z",key:"doq5xv"}],["path",{d:"M6 13h12",key:"yf64js"}],["path",{d:"M6 17h12",key:"1jwigz"}]],H=E("warehouse",z);function Q(){const[b,m]=a.useState(!0),[r,h]=a.useState([]),[v,w]=a.useState([]),[l,S]=a.useState(""),[o,k]=a.useState("all"),[g,c]=a.useState(null),[i,u]=a.useState(""),[y,p]=a.useState(null);a.useEffect(()=>{f()},[]);const f=async()=>{m(!0);try{const[t,s]=await Promise.all([d.get("/admin/warehouses"),d.get("/admin/stock/summary")]);w(Array.isArray(t.data?.data)?t.data.data:Array.isArray(t.data)?t.data:[]),h(Array.isArray(s.data?.data)?s.data.data:Array.isArray(s.data)?s.data:[])}catch(t){const s=t?.response?.data?.message||t?.message||"Failed to load inventory";x.error(s)}finally{m(!1)}},C=async t=>{p(t);try{await d.put("/admin/stock",{product_id:t,stock:parseInt(i,10)}),h(s=>s.map(n=>n.id===t?{...n,stock:parseInt(i,10)}:n)),x.success("Stock updated successfully"),c(null)}catch{x.error("Failed to update stock")}finally{p(null)}},A=r.length,L=r.reduce((t,s)=>t+(s.stock||0),0),P=r.filter(t=>t.stock>0&&t.stock<5).length,I=r.filter(t=>t.stock===0).length,j=r.filter(t=>(t.name||"").toLowerCase().includes(l.toLowerCase())||(t.sku||"").toLowerCase().includes(l.toLowerCase())?o==="low"?t.stock>0&&t.stock<5:o==="out"?t.stock===0:!0:!1),U=t=>t===0?e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs bg-red-100 text-red-700 font-medium",children:"Out of Stock"}):t<5?e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs bg-yellow-100 text-yellow-700 font-medium",children:[t," — Low"]}):e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs bg-green-100 text-green-700 font-medium",children:t});return b?e.jsx("div",{className:"flex items-center justify-center min-h-96",children:e.jsx(N,{className:"h-8 w-8 animate-spin text-violet-600"})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Inventory"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Monitor and manage stock levels across all warehouses"})]}),e.jsxs("button",{onClick:f,className:"flex items-center gap-2 px-4 py-2 bg-violet-600 hover:bg-violet-700 text-white rounded-lg text-sm font-medium transition-colors",children:[e.jsx(_,{className:"h-4 w-4"}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-violet-100 rounded-lg",children:e.jsx(R,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total SKUs"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:A})]})]})}),e.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 rounded-lg",children:e.jsx(H,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total Units"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:L.toLocaleString()})]})]})}),e.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:e.jsx(T,{className:"h-5 w-5 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Low Stock Alerts"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:P})]})]})}),e.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:e.jsx(M,{className:"h-5 w-5 text-red-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Out of Stock"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:I})]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Warehouses"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:v.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:t.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[t.product_count," products"]})]}),e.jsx("p",{className:"text-lg font-bold text-violet-600",children:t.total_units.toLocaleStr
1ing()})]},t.id))})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:[["all","All Products"],["low","Low Stock"],["out","Out of Stock"]].map(([t,s])=>e.jsx("button",{onClick:()=>k(t),className:`px-4 py-1.5 rounded-full text-sm font-medium transition-colors ${o===t?"bg-violet-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:s},t))}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx("input",{value:l,onChange:t=>S(t.target.value),placeholder:"Search by name or SKU...",className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-violet-500"})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Product Name"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"SKU"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Category"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Stock"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Warehouse"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Last Updated"}),e.jsx("th",{className:"text-left py-3 px-2 font-medium text-gray-600",children:"Actions"})]})}),e.jsx("tbody",{children:j.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"text-center py-10 text-gray-400",children:"No products found."})}):j.map(t=>e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-50",children:[e.jsx("td",{className:"py-3 px-2 font-medium text-gray-900",children:t.name}),e.jsx("td",{className:"py-3 px-2 text-gray-500 font-mono text-xs",children:t.sku}),e.jsx("td",{className:"py-3 px-2 text-gray-600",children:typeof t.category=="object"?t.category?.name:t.category}),e.jsx("td",{className:"py-3 px-2",children:g===t.id?e.jsx("input",{type:"number",min:"0",value:i,onChange:s=>u(s.target.value),className:"w-20 border border-violet-400 rounded px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-violet-500",autoFocus:!0}):U(t.stock)}),e.jsx("td",{className:"py-3 px-2 text-gray-600",children:t.warehouse}),e.jsx("td",{className:"py-3 px-2 text-gray-500",children:t.updated_at}),e.jsx("td",{className:"py-3 px-2",children:g===t.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>C(t.id),disabled:y===t.id,className:"flex items-center gap-1 px-2 py-1 bg-violet-600 hover:bg-violet-700 text-white rounded text-xs transition-colors disabled:opacity-50",children:[y===t.id?e.jsx(N,{className:"h-3 w-3 animate-spin"}):e.jsx(O,{className:"h-3 w-3"}),"Save"]}),e.jsx("button",{onClick:()=>c(null),className:"p-1 text-gray-400 hover:text-gray-600 rounded",children:e.jsx(W,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>{c(t.id),u(String(t.stock))},className:"flex items-center gap-1 px-2 py-1 text-gray-500 hover:text-violet-600 hover:bg-violet-50 rounded text-xs transition-colors",children:[e.jsx(F,{className:"h-3 w-3"}),"Edit"]})})]},t.id))})]})})]})]})}export{Q as default};

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.