Inventory / Product Master Data

Product List
Product Code ↕ Product Name ↕ Category ↕ Activation Unit ↕ Status ↕ Actions
PROD-A-101 Steel Frame - Heavy Duty Raw Material
Kg Active
PROD-B-202 Alloy Brackets - 5mm Semi-Finished
Pcs Discontinued
PROD-C-303 Electronic Control Unit Finished Good
Pcs Inactive
PROD-C-304 Hydraulic Pump Raw Material
Liters Active
PROD-C-305 Gear Shaft Assembly Semi-Finished
Pcs Active
PROD-C-308 Cooling Fan Module Finished Good
Pcs Discontinued

}
const productCode = document.getElementById("productCode").value.trim(); const productName = document.getElementById("productName").value.trim(); const category = parseInt(document.getElementById("category").value); const unit = parseInt(document.getElementById("unit").value); const status = parseInt(document.getElementById("status").value); const description = document.getElementById("description").value.trim(); if (!productCode || !productName) { alert("Product Code and Name are required."); return; } const payload = { companyPk: 478, name: productName, category: category, description: description, productCode: productCode, unit: unit, status: status }; console.log("Submitting payload:", payload); fetch('/Product/CreateProduct', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }) .then(res => res.json()) .then(data => { if (data.success) { const unitLabels = { 1: 'Kg', 2: 'Pcs', 3: 'Meters', 4: 'Liters' }; const categoryLabels = { 1: 'Raw Material', 2: 'Semi-Finished', 3: 'Finished Good' }; const statusLabels = { 1: 'bg-label-success', 2: 'bg-label-warning', 3: 'bg-label-danger' }; const statusText = { 1: 'Active', 2: 'Inactive', 3: 'Discontinued' }; const tbody = document.querySelector("table tbody"); const newRow = document.createElement("tr"); newRow.innerHTML = ` ${productCode} ${productName} ${categoryLabels[category]}
${unitLabels[unit]} ${statusText[status]} `; tbody.appendChild(newRow); bootstrap.Modal.getInstance(document.getElementById('addProductModal')).hide(); document.getElementById("productCode").value = ""; document.getElementById("productName").value = ""; document.getElementById("description").value = ""; } else { alert("Error: " + data.message); } }) .catch(err => { console.error("API error:", err); alert("Failed to connect to server."); });