1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[77566],{96926:function(e,t,l){l.r(t),l.d(t,{default:function(){return L}});var s=l(57437),a=l(2265),i=l(79373),r=l(16836),c=l(65319),n=l(44967),o=l(42264),d=l(3810),u=l(33866),m=l(93142),x=l(89970),h=l(71134),p=l(5945),v=l(45235),j=l(96350),g=l(72495),y=l(68565),f=l(22116),D=l(61778),b=l(9190),N=l(12221),k=l(62272),S=l(1119),C={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 192a32 32 0 0132 32v160h174.81a32 32 0 0126.68 14.33l113.19 170.84a32 32 0 015.32 17.68V672a32 32 0 01-32 32h-96c0 70.7-57.3 128-128 128s-128-57.3-128-128H384c0 70.7-57.3 128-128 128s-128-57.3-128-128H96a32 32 0 01-32-32V224a32 32 0 0132-32zM256 640a64 64 0 000 128h1.06A64 64 0 00256 640m448 0a64 64 0 000 128h1.06A64 64 0 00704 640M576 256H128v384h17.12c22.13-38.26 63.5-64 110.88-64 47.38 0 88.75 25.74 110.88 64H576zm221.63 192H640v145.12A127.43 127.43 0 01704 576c47.38 0 88.75 25.74 110.88 64H896v-43.52zM500 448a12 12 0 0112 12v40a12 12 0 01-12 12H332a12 12 0 01-12-12v-40a12 12 0 0112-12zM308 320a12 12 0 0112 12v40a12 12 0 01-12 12H204a12 12 0 01-12-12v-40a12 12 0 0112-12z"}}]},name:"truck",theme:"outlined"},Z=l(55015),I=a.forwardRef(function(e,t){return a.createElement(Z.Z,(0,S.Z)({},e,{ref:t,icon:C}))}),w=l(9775),A=l(96473),P=l(46783),T=l(35291),z=l(29271),M={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M864 248H728l-32.4-90.8a32.07 32.07 0 00-30.2-21.2H358.6c-13.5 0-25.6 8.5-30.1 21.2L296 248H160c-44.2 0-80 35.8-80 80v456c0 44.2 35.8 80 80 80h704c44.2 0 80-35.8 80-80V328c0-44.2-35.8-80-80-80zm8 536c0 4.4-3.6 8-8 8H160c-4.4 0-8-3.6-8-8V328c0-4.4 3.6-8 8-8h186.7l17.1-47.8 22.9-64.2h250.5l22.9 64.2 17.1 47.8H864c4.4 0 8 3.6 8 8v456zM512 384c-88.4 0-160 71.6-160 160s71.6 160 160 160 160-71.6 160-160-71.6-160-160-160zm0 256c-53 0-96-43-96-96s43-96 96-96 96 43 96 96-43 96-96 96z"}}]},name:"camera",theme:"outlined"},E=a.forwardRef(function(e,t){return a.createElement(Z.Z,(0,S.Z)({},e,{ref:t,icon:M}))});let{Title:O,Text:F}=i.default,{TextArea:H}=r.default,{Dragger:q}=c.default,B=[{value:"equipment",label:"\uD83D\uDD27 Equipment",color:"blue"},{value:"supplies",label:"\uD83D\uDCE6 Supplies",color:"green"},{value:"materials",label:"\uD83D\uDCDA Materials",color:"purple"},{value:"food",label:"\uD83C\uDF4E Food & Nutrition",color:"orange"},{value:"medical",label:"\uD83D\uDC8A Medical Supplies",color:"red"},{value:"technology",label:"\uD83D\uDCBB Technology",color:"cyan"},{value:"clothing",label:"\uD83D\uDC55 Clothing",color:"pink"},{value:"other",label:"\uD83D\uDCCB Other",color:"default"}];var L=e=>{var t;let{suiteId:l,programData:i,onRefresh:c,isEditMode:S}=e,[C,Z]=(0,a.useState)([]),[M,L]=(0,a.useState)([]),[V,_]=(0,a.useState)(!1),[U,$]=(0,a.useState)(!1),[K,J]=(0,a.useState)(null),[R,Q]=(0,a.useState)("inventory"),[W]=n.Z.useForm();(0,a.useEffect)(()=>{Y()},[l]);let Y=async()=>{try{let[e,t]=await Promise.all([fetch("/api/ngoCompany/getInventory?suiteId=".concat(l)),fetch("/api/ngoCompany/getSuiteInventoryTransactions?suiteId=".concat(l))]),s=await e.json(),a=await t.json();Z(s.items||[]),L(a.transactions||[])}catch(e){console.error("Error loading inventory data:",e)}},G=async e=>{try{let t={...e,suiteId:l,isActive:!0,currentStock:e.initialStock||0,stockAlerts:{lowStockThreshold:e.lowStockThreshold||10,criticalStockThreshold:e.critical
1StockThreshold||5,enableAlerts:e.enableStockAlerts||!0}};(await fetch("/api/inventory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok&&(o.ZP.success("Inventory item created successfully!"),_(!1),W.resetFields(),Y(),c())}catch(e){o.ZP.error("Failed to create inventory item")}},X=e=>{var t,l;let s=e.currentStock||0,a=(null===(t=e.stockAlerts)||void 0===t?void 0:t.lowStockThreshold)||10;return 0===s?{status:"error",text:"Out of Stock",color:"red"}:s<=((null===(l=e.stockAlerts)||void 0===l?void 0:l.criticalStockThreshold)||5)?{status:"error",text:"Critical",color:"red"}:s<=a?{status:"warning",text:"Low Stock",color:"orange"}:{status:"success",text:"In Stock",color:"green"}},ee=[{title:"Item",key:"item",render:e=>{let t=B.find(t=>t.value===e.category);return(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-lg flex items-center justify-center bg-".concat(null==t?void 0:t.color,"-100"),children:(0,s.jsx)("span",{className:"text-2xl",children:(null==t?void 0:t.label.split(" ")[0])||"\uD83D\uDCE6"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium text-gray-900",children:e.name}),(0,s.jsx)("div",{className:"text-sm text-gray-600",children:e.description}),(0,s.jsxs)("div",{className:"flex items-center space-x-2 mt-1",children:[(0,s.jsx)(d.Z,{color:null==t?void 0:t.color,children:null==t?void 0:t.label}),e.linkedToProducts&&(0,s.jsx)(d.Z,{color:"purple",icon:(0,s.jsx)(k.Z,{}),children:"Linked to Products"})]})]})]})}},{title:"Stock Level",key:"stock",render:e=>{let t=X(e);return(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"text-lg font-bold text-".concat(t.color,"-600"),children:e.currentStock||0}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:e.unitOfMeasure||"units"}),(0,s.jsx)(u.Z,{status:t.status,text:t.text})]})}},{title:"Unit Cost",key:"cost",render:e=>(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsxs)("div",{className:"text-lg font-bold text-blue-600",children:["$",(e.unitCost||0).toFixed(2)]}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"per unit"})]})},{title:"Total Value",key:"totalValue",render:e=>{let t=(e.currentStock||0)*(e.unitCost||0);return(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsxs)("div",{className:"text-lg font-bold text-purple-600",children:["$",t.toFixed(2)]}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"total value"})]})}},{title:"Actions",key:"actions",render:e=>(0,s.jsxs)(m.Z,{children:[(0,s.jsx)(x.Z,{title:"Make Delivery",children:(0,s.jsx)(h.ZP,{size:"small",icon:(0,s.jsx)(I,{}),onClick:()=>{J(e),$(!0)}})}),(0,s.jsx)(x.Z,{title:"View Analytics",children:(0,s.jsx)(h.ZP,{size:"small",icon:(0,s.jsx)(w.Z,{})})}),S&&(0,s.jsx)(h.ZP,{size:"small",type:"primary",children:"Edit"})]})}];return(0,s.jsxs)("div",{className:"enhanced-inventory-manager space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(O,{level:3,className:"mb-2",children:"\uD83D\uDCE6 Inventory Management"}),(0,s.jsx)(F,{type:"secondary",children:"Track and manage physical products connected to your program services"})]}),S&&(0,s.jsx)(h.ZP,{type:"primary",icon:(0,s.jsx)(A.Z,{}),onClick:()=>_(!0),size:"large",className:"bg-gradient-to-r from-blue-500 to-indigo-600 border-0 shadow-lg",children:"Add Inventory Item"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[(0,s.jsx)(p.default,{className:"text-center",children:(0,s.jsx)(v.Z,{title:"Total Items",value:C.length,prefix:(0,s.jsx)(P.Z,{}),valueStyle:{color:"#1890ff"}})}),(0,s.jsx)(p.default,{className:"text-center",children:(0,s.jsx)(v.Z,{title:"Low Stock Items",value:C.filter(e=>"warning"===X(e).status).length,prefix:(0,s.jsx)(T.Z,{}),valueStyle:{color:"#faad14"}})}),(0,s.jsx)(p.default,{className:"text-center",children:(0,s.jsx)(v.Z,{title:"Out of Stock",value:C.filter(e=>0===(e.currentStock||0)).length,prefix:(0,s.jsx)(z.Z,{}),valueStyle:{color:"#f5222d"}})}),(0,s.jsx)(p.default,{className:"text-center",children:(0,s.jsx)(v.Z,{title:"Total Value",value:C.reduce((e,t)=>
1e+(t.currentStock||0)*(t.unitCost||0),0),prefix:"$",valueStyle:{color:"#52c41a"},precision:2})})]}),(0,s.jsxs)(j.default,{activeKey:R,onChange:Q,className:"enhanced-inventory-tabs",children:[(0,s.jsx)(j.default.TabPane,{tab:"\uD83D\uDCE6 Inventory",children:(0,s.jsx)(p.default,{title:"\uD83D\uDCCB Inventory Items (".concat(C.length,")"),children:0===C.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83D\uDCE6"}),(0,s.jsx)(O,{level:4,type:"secondary",children:"No inventory items yet"}),(0,s.jsx)(F,{type:"secondary",className:"text-lg",children:"Add physical products and supplies to track and manage your program resources"}),S&&(0,s.jsx)("div",{className:"mt-6",children:(0,s.jsx)(h.ZP,{type:"primary",size:"large",icon:(0,s.jsx)(A.Z,{}),onClick:()=>_(!0),className:"bg-gradient-to-r from-blue-500 to-indigo-600 border-0",children:"Add Your First Inventory Item"})})]}):(0,s.jsx)(g.Z,{dataSource:C,columns:ee,rowKey:"_id",pagination:{pageSize:10,showTotal:(e,t)=>"".concat(t[0],"-").concat(t[1]," of ").concat(e," items")}})})},"inventory"),(0,s.jsx)(j.default.TabPane,{tab:"\uD83D\uDE9A Transactions",children:(0,s.jsx)(p.default,{title:"\uD83D\uDE9A Recent Inventory Transactions",children:(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83D\uDE9A"}),(0,s.jsx)(O,{level:4,type:"secondary",children:"Transaction History"}),(0,s.jsx)(F,{type:"secondary",children:"Track all inventory movements, deliveries, and stock changes"})]})})},"transactions"),(0,s.jsx)(j.default.TabPane,{tab:"\uD83D\uDCCA Analytics",children:(0,s.jsx)(p.default,{title:"\uD83D\uDCCA Inventory Analytics",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,s.jsx)(p.default,{title:"\uD83D\uDCC8 Stock Levels",size:"small",children:(0,s.jsx)("div",{className:"space-y-3",children:C.slice(0,5).map(e=>{var t;let l=X(e),a=e.maxStock||100,i=Math.round((e.currentStock||0)/a*100);return(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("span",{className:"text-lg",children:(null===(t=B.find(t=>t.value===e.category))||void 0===t?void 0:t.label.split(" ")[0])||"\uD83D\uDCE6"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium text-sm",children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-gray-600",children:[e.currentStock||0," / ",a," units"]})]})]}),(0,s.jsx)("div",{className:"text-right",children:(0,s.jsx)(y.Z,{percent:i,size:"small",strokeColor:l.color,className:"w-20"})})]},e._id)})})}),(0,s.jsx)(p.default,{title:"\uD83D\uDCB0 Value Breakdown",size:"small",children:(0,s.jsx)("div",{className:"space-y-3",children:B.map(e=>{let t=C.filter(t=>t.category===e.value),l=t.reduce((e,t)=>e+(t.currentStock||0)*(t.unitCost||0),0);return 0===t.length?null:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("span",{className:"text-lg",children:e.label.split(" ")[0]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium text-sm",children:e.label.split(" ").slice(1).join(" ")}),(0,s.jsxs)("div",{className:"text-xs text-gray-600",children:[t.length," items"]})]})]}),(0,s.jsx)("div",{className:"text-right",children:(0,s.jsxs)("div",{className:"font-bold text-green-600",children:["$",l.toFixed(2)]})})]},e.value)})})})]})})},"analytics")]}),(0,s.jsx)(f.default,{title:"\uD83D\uDCE6 Add Inventory Item",open:V,onCancel:()=>{_(!1),W.resetFields()},footer:null,width:800,children:(0,s.jsxs)(n.Z,{form:W,layout:"vertical",onFinish:G,className:"space-y-4",children:[(0,s.jsx)(D.Z,{message:"\uD83D\uDCE6 Inventory Management",description:"Add physical items that your program provides to beneficiaries. These can be linked to your products/services for automatic distribution.",type:"info",showIcon:!0,className:"mb-6"}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsx)(n.Z.Item,{name:"name",label:"Item Name",rules:[{required:!0,message:"Please enter item name"}],children:(0,s.jsx)(r.default,{size:"large",placeholder:"e.g., Training Laptop"})}),(0,s.jsx)(n.Z.Item,{name:"category",label:"Category",rules:[{required:!0,message:"Please select category"}],children:(0,s.jsx)(b.default,{size:"large",placeholder:"Select category",children:B.map(e=>(0,s.jsx)(b.default.Option,{value:e.value,children:(0,s.jsxs)(m.Z,{children:[(0,s.jsx)("span",{children:e.label.split(" ")[0]}),(0,s.jsx)("span",{children:e.label.split(" ").slice(1).join(" ")})]})},e.value))})})]}),(0,s.jsx)(n.Z.Item,{name:"description",label:"Description",children:(0,s.jsx)(H,{rows:3,placeholder:"Describe this inventory item..."})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[(0,s.jsx)(n.Z.Item,{name:"initialStock",label:"Initial Stock",rules:[{required:!0,message:"Please enter initial stock"}],children:(0,s.jsx)(N.Z,{size:"large",placeholder:"0",min:0,className:"w-full"})}),(0,s.jsx)(n.Z.Item,{name:"unitCost",label:"Unit Cost",rules:[{required:!0,message:"Please enter unit cost"}],children:(0,s.jsx)(N.Z,{size:"large",placeholder:"0.00",prefix:"$",className:"w-full"})}),(0,s.jsx)(n.Z.Item,{name:"unitOfMeasure",label:"Unit of Measure",rules:[{required:!0,message:"Please select unit"}],children:(0,s.jsxs)(b.default,{size:"large",children:[(0,s.jsx)(b.default.Option,{value:"piece",children:"Piece"}),(0,s.jsx)(b.default.Option,{value:"kg",children:"Kilogram"}),(0,s.jsx)(b.default.Option,{value:"liter",children:"Liter"}),(0,s.jsx)(b.default.Option,{value:"box",children:"Box"}),(0,s.jsx)(b.default.Option,{value:"set",children:"Set"}),(0,s.jsx)(b.default.Option,{value:"package",children:"Package"})]})}),(0,s.jsx)(n.Z.Item,{name:"lowStockThreshold",label:"Low Stock Alert",children:(0,s.jsx)(N.Z,{size:"large",placeholder:"10",min:1,className:"w-full"})})]}),(0,s.jsxs)(p.default,{title:"\uD83D\uDD17 Link to Products/Services",className:"bg-purple-50",children:[(0,s.jsx)(n.Z.Item,{name:"linkToProducts",label:"Connect to Products/Services",children:(0,s.jsx)(b.default,{mode:"multiple",placeholder:"Select products/services that use this inventory item",className:"w-full",children:null==i?void 0:null===(t=i.productsAndServices)||void 0===t?void 0:t.map(e=>(0,s.jsx)(b.default.Option,{value:e._id,children:(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("span",{children:"financial-service"===e.type?"\uD83D\uDCB0":"\uD83D\uDCE6"}),(0,s.jsx)("span",{children:e.name})]})},e._id))})}),(0,s.jsx)(D.Z,{message:"Automatic Distribution",description:"When linked products are approved for benef
1iciaries, inventory will be automatically allocated and tracked.",type:"info",showIcon:!0})]}),(0,s.jsx)(p.default,{title:"\uD83D\uDCF8 Item Image",className:"bg-blue-50",children:(0,s.jsx)(n.Z.Item,{name:"image",children:(0,s.jsxs)(q,{accept:"image/*",beforeUpload:()=>!1,className:"upload-dragger",children:[(0,s.jsx)("p",{className:"ant-upload-drag-icon",children:(0,s.jsx)(E,{className:"text-2xl text-blue-500"})}),(0,s.jsx)("p",{className:"ant-upload-text",children:"Upload Item Image"}),(0,s.jsx)("p",{className:"ant-upload-hint",children:"Click or drag image to upload (optional)"})]})})}),(0,s.jsxs)("div",{className:"flex justify-end space-x-3 pt-4",children:[(0,s.jsx)(h.ZP,{onClick:()=>_(!1),children:"Cancel"}),(0,s.jsx)(h.ZP,{type:"primary",htmlType:"submit",className:"bg-gradient-to-r from-blue-500 to-indigo-600 border-0",children:"Add to Inventory"})]})]})}),(0,s.jsx)(f.default,{title:"\uD83D\uDE9A Make Delivery",open:U,onCancel:()=>$(!1),footer:null,width:600,children:K&&(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(D.Z,{message:"Making delivery for: ".concat(K.name),description:"Current stock: ".concat(K.currentStock||0," ").concat(K.unitOfMeasure||"units"),type:"info",showIcon:!0}),(0,s.jsxs)(n.Z,{layout:"vertical",children:[(0,s.jsx)(n.Z.Item,{name:"beneficiary",label:"Select Beneficiary",rules:[{required:!0,message:"Please select beneficiary"}],children:(0,s.jsxs)(b.default,{size:"large",placeholder:"Choose beneficiary",children:[(0,s.jsx)(b.default.Option,{value:"demo1",children:"John Doe ([email protected])"}),(0,s.jsx)(b.default.Option,{value:"demo2",children:"Jane Smith ([email protected])"})]})}),(0,s.jsx)(n.Z.Item,{name:"quantity",label:"Quantity to Deliver",rules:[{required:!0,message:"Please enter quantity"}],children:(0,s.jsx)(N.Z,{size:"large",placeholder:"1",min:1,max:K.currentStock||1,className:"w-full",addonAfter:K.unitOfMeasure||"units"})}),(0,s.jsx)(n.Z.Item,{name:"notes",label:"Delivery Notes",children:(0,s.jsx)(H,{rows:3,placeholder:"Add any notes about this delivery..."})}),(0,s.jsxs)("div",{className:"flex justify-end space-x-3 pt-4",children:[(0,s.jsx)(h.ZP,{onClick:()=>$(!1),children:"Cancel"}),(0,s.jsx)(h.ZP,{type:"primary",className:"bg-gradient-to-r from-green-500 to-emerald-600 border-0",children:"Process Delivery"})]})]})]})}),0===C.length&&(0,s.jsx)(p.default,{title:"â¡ Quick Setup - Common Inventory Items",children:(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[{name:"Training Materials",category:"materials",cost:25,unit:"set"},{name:"Laptops",category:"technology",cost:800,unit:"piece"},{name:"Office Supplies",category:"supplies",cost:15,unit:"package"},{name:"Safety Equipment",category:"equipment",cost:50,unit:"set"},{name:"Books & Manuals",category:"materials",cost:20,unit:"piece"},{name:"Food Packages",category:"food",cost:30,unit:"package"},{name:"Medical Kits",category:"medical",cost:75,unit:"kit"},{name:"Uniforms",category:"clothing",cost:40,unit:"set"}].map((e,t)=>{var l;return(0,s.jsx)(p.default,{size:"small",className:"text-center hover:shadow-md transition-all cursor-pointer",onClick:()=>{W.setFieldsValue({name:e.name,category:e.category,unitCost:e.cost,unitOfMeasure:e.unit,initialStock:50,lowStockThreshold:10}),_(!0)},children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"text-2xl",children:null===(l=B.find(t=>t.value===e.category))||void 0===l?void 0:l.label.split(" ")[0]}),(0,s.jsx)("div",{className:"font-medium text-sm",children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-gray-600",children:["$",e.cost," per ",e.unit]}),(0,s.jsx)(h.ZP,{type:"primary",size:"small",className:"bg-gradient-to-r from-blue-500 to-indigo-600 border-0",children:"Add Item"})]})},t)})})})]})}}}]);
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.