From 6d4d68c475b97b4f60c9ecc5167790a5f348488f Mon Sep 17 00:00:00 2001 From: Vignesh M Date: Mon, 9 Feb 2026 12:28:08 +0530 Subject: [PATCH] Update src/Pages/StockPriceUpdate/StockPriceUpdate.jsx --- .../StockPriceUpdate/StockPriceUpdate.jsx | 75 +++++++++++++++---- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx b/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx index 1db7c22..d011682 100644 --- a/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx +++ b/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx @@ -36,6 +36,7 @@ import Search from '../../Components/Forms/Search'; import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx'; import { useAuth } from '../../AuthContext.jsx'; import '../../Styles/OverAllStyle/OverAllStyle.scss'; +import './StockPriceUpdate.scss'; import { getPreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js'; import { DropDowns } from '../../Components/Forms/DropDown.jsx'; import { FiDelete, FiUploadCloud } from 'react-icons/fi'; @@ -158,7 +159,10 @@ const StockPriceUpdate = () => { key: 'ProductName', width: 180, render: (value, record, index) => ( -

{`${value} (${record?.Size} ${record?.UOMName})`}

+

+ {value}{' '} + {record?.Size && `(${record?.Size || ''} ${record?.UOMName || ''})`} +

), }, { @@ -807,6 +811,7 @@ const StockPriceUpdate = () => { } currentRow[field] = numValue; + currentRow.isModified = true; updated[rowIndex] = currentRow; return updated; }); @@ -1487,7 +1492,7 @@ const StockPriceUpdate = () => { /* ---------------- COLUMN DEFINITIONS ---------------- */ const columns = [ - { header: 'Product Name', key: 'ProdName', width: 100 }, + { header: 'Product Name', key: 'ProdName', width: 20 }, ...(isStockVariantBased === 'Yes' ? [{ header: 'Variant Name', key: 'ProdVariantName', width: 20 }] : []), @@ -1755,7 +1760,34 @@ const StockPriceUpdate = () => { setFileLoading(false); return; } - setUploadedData(extractedData); + + // Compare and mark as Old/Modified + const comparedData = extractedData + .map((uploaded) => { + const current = BulkProductData.find( + (p) => + p.ProdId === uploaded.ProdId && + (!uploaded.InwardDtlId || p.InwardDtlId === uploaded.InwardDtlId) + ); + + if (current) { + const isModified = + Number(current.MRP) !== Number(uploaded.NewMRP) || + Number(current.SellPrice) !== Number(uploaded.NewSellPrice) || + Number(current.WhSalePrice || 0) !== + Number(uploaded.NewWholeSalePrice || 0); + + return { + ...uploaded, + isModified, + status: isModified ? 'Modified' : 'Old', + }; + } + + return { ...uploaded, isModified: false, status: 'Old' }; + }) + .sort((a, b) => Number(b.isModified) - Number(a.isModified)); + setUploadedData(comparedData); setFileLoading(false); // setFormValuesFromExtractedData(extractedData); }; @@ -1929,10 +1961,13 @@ const StockPriceUpdate = () => { const hasMRP = !!data?.NewMRP; const hasSell = !!data?.NewSellPrice; const hasWholesale = !!data?.NewWholeSalePrice; + const isModified = data?.isModified === true; // valid cases - if (hasMRP && hasSell) return true; - if (!hasMRP && !hasSell && hasWholesale) return true; + if (hasMRP && hasSell && isModified) return true; + + // ✅ Case 2: Only Wholesale changed + if (!hasMRP && !hasSell && hasWholesale && isModified) return true; return false; }) @@ -1954,6 +1989,12 @@ const StockPriceUpdate = () => { CreatedBy: UserId, }; + if (!updatedData || updatedData.length === 0) { + setMessageData('Minimum 1 product needs to be changed or added'); + setMessageType('error'); + return; + } + const res = await dispatch(bulkPriceUpdate(putData))?.unwrap(); if (res?.data?.statusCode === 1) { @@ -2046,7 +2087,7 @@ const StockPriceUpdate = () => { onComplete={onComplete} /> -
+
@@ -2058,9 +2099,7 @@ const StockPriceUpdate = () => { }} > {RadioSelection == 'Bulk' && ( -
+
{ record.localId} - // components={components} - // bordered dataSource={uploadedData} - // className="tableExcelUpload" - // onChange={handleTableChange} className="price-change-data" + rowClassName={(record) => + record.isModified ? 'modified-row' : 'old-row' + } /> +
+
+
+ Old +
+
+
+ Modified +
+
+