Update src/Pages/StockPriceUpdate/StockPriceUpdate.jsx
This commit is contained in:
parent
297afa72d0
commit
6d4d68c475
|
|
@ -36,6 +36,7 @@ import Search from '../../Components/Forms/Search';
|
||||||
import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx';
|
import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx';
|
||||||
import { useAuth } from '../../AuthContext.jsx';
|
import { useAuth } from '../../AuthContext.jsx';
|
||||||
import '../../Styles/OverAllStyle/OverAllStyle.scss';
|
import '../../Styles/OverAllStyle/OverAllStyle.scss';
|
||||||
|
import './StockPriceUpdate.scss';
|
||||||
import { getPreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js';
|
import { getPreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js';
|
||||||
import { DropDowns } from '../../Components/Forms/DropDown.jsx';
|
import { DropDowns } from '../../Components/Forms/DropDown.jsx';
|
||||||
import { FiDelete, FiUploadCloud } from 'react-icons/fi';
|
import { FiDelete, FiUploadCloud } from 'react-icons/fi';
|
||||||
|
|
@ -158,7 +159,10 @@ const StockPriceUpdate = () => {
|
||||||
key: 'ProductName',
|
key: 'ProductName',
|
||||||
width: 180,
|
width: 180,
|
||||||
render: (value, record, index) => (
|
render: (value, record, index) => (
|
||||||
<p>{`${value} (${record?.Size} ${record?.UOMName})`}</p>
|
<p>
|
||||||
|
{value}{' '}
|
||||||
|
{record?.Size && `(${record?.Size || ''} ${record?.UOMName || ''})`}
|
||||||
|
</p>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -807,6 +811,7 @@ const StockPriceUpdate = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
currentRow[field] = numValue;
|
currentRow[field] = numValue;
|
||||||
|
currentRow.isModified = true;
|
||||||
updated[rowIndex] = currentRow;
|
updated[rowIndex] = currentRow;
|
||||||
return updated;
|
return updated;
|
||||||
});
|
});
|
||||||
|
|
@ -1487,7 +1492,7 @@ const StockPriceUpdate = () => {
|
||||||
|
|
||||||
/* ---------------- COLUMN DEFINITIONS ---------------- */
|
/* ---------------- COLUMN DEFINITIONS ---------------- */
|
||||||
const columns = [
|
const columns = [
|
||||||
{ header: 'Product Name', key: 'ProdName', width: 100 },
|
{ header: 'Product Name', key: 'ProdName', width: 20 },
|
||||||
...(isStockVariantBased === 'Yes'
|
...(isStockVariantBased === 'Yes'
|
||||||
? [{ header: 'Variant Name', key: 'ProdVariantName', width: 20 }]
|
? [{ header: 'Variant Name', key: 'ProdVariantName', width: 20 }]
|
||||||
: []),
|
: []),
|
||||||
|
|
@ -1755,7 +1760,34 @@ const StockPriceUpdate = () => {
|
||||||
setFileLoading(false);
|
setFileLoading(false);
|
||||||
return;
|
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);
|
setFileLoading(false);
|
||||||
// setFormValuesFromExtractedData(extractedData);
|
// setFormValuesFromExtractedData(extractedData);
|
||||||
};
|
};
|
||||||
|
|
@ -1929,10 +1961,13 @@ const StockPriceUpdate = () => {
|
||||||
const hasMRP = !!data?.NewMRP;
|
const hasMRP = !!data?.NewMRP;
|
||||||
const hasSell = !!data?.NewSellPrice;
|
const hasSell = !!data?.NewSellPrice;
|
||||||
const hasWholesale = !!data?.NewWholeSalePrice;
|
const hasWholesale = !!data?.NewWholeSalePrice;
|
||||||
|
const isModified = data?.isModified === true;
|
||||||
|
|
||||||
// valid cases
|
// valid cases
|
||||||
if (hasMRP && hasSell) return true;
|
if (hasMRP && hasSell && isModified) return true;
|
||||||
if (!hasMRP && !hasSell && hasWholesale) return true;
|
|
||||||
|
// ✅ Case 2: Only Wholesale changed
|
||||||
|
if (!hasMRP && !hasSell && hasWholesale && isModified) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
|
@ -1954,6 +1989,12 @@ const StockPriceUpdate = () => {
|
||||||
CreatedBy: UserId,
|
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();
|
const res = await dispatch(bulkPriceUpdate(putData))?.unwrap();
|
||||||
|
|
||||||
if (res?.data?.statusCode === 1) {
|
if (res?.data?.statusCode === 1) {
|
||||||
|
|
@ -2046,7 +2087,7 @@ const StockPriceUpdate = () => {
|
||||||
onComplete={onComplete}
|
onComplete={onComplete}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="formAddNew" style={{justifyContent:"space-between"}}>
|
<div className="formAddNew" style={{ justifyContent: 'space-between' }}>
|
||||||
<div>
|
<div>
|
||||||
<FormHeader title={'Price Change'} />
|
<FormHeader title={'Price Change'} />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -2058,9 +2099,7 @@ const StockPriceUpdate = () => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{RadioSelection == 'Bulk' && (
|
{RadioSelection == 'Bulk' && (
|
||||||
<div
|
<div className="PriChangeUpper">
|
||||||
className='PriChangeUpper'
|
|
||||||
>
|
|
||||||
<div className="formSearch">
|
<div className="formSearch">
|
||||||
<Search
|
<Search
|
||||||
value={BulksearchedText}
|
value={BulksearchedText}
|
||||||
|
|
@ -2360,14 +2399,24 @@ const StockPriceUpdate = () => {
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowKey={(record) => record.localId}
|
rowKey={(record) => record.localId}
|
||||||
// components={components}
|
|
||||||
// bordered
|
|
||||||
dataSource={uploadedData}
|
dataSource={uploadedData}
|
||||||
// className="tableExcelUpload"
|
|
||||||
// onChange={handleTableChange}
|
|
||||||
className="price-change-data"
|
className="price-change-data"
|
||||||
|
rowClassName={(record) =>
|
||||||
|
record.isModified ? 'modified-row' : 'old-row'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="legend-container">
|
||||||
|
<div className="legend-item">
|
||||||
|
<div className="legend-box old-box"></div>
|
||||||
|
<span className="legend-text">Old</span>
|
||||||
|
</div>
|
||||||
|
<div className="legend-item">
|
||||||
|
<div className="legend-box modified-box"></div>
|
||||||
|
<span className="legend-text">Modified</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="cancel-link"
|
className="cancel-link"
|
||||||
onClick={handleCancelData}
|
onClick={handleCancelData}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue