after fixed conflict

This commit is contained in:
Your Name 2026-02-09 12:38:17 +05:30
commit 27afbf7dbc
7 changed files with 1951 additions and 1153 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2029,125 +2029,190 @@ const ProductList = () => {
formRef?.current?.resetFields();
};
const handleCancel = () => {
const handleResetExcelData = useCallback(() => {
dispatch(emptyExcelData());
}, []);
const handleCancel = useCallback(() => {
setOpenExcel(false);
handleResetExcelData();
};
}, [handleResetExcelData]);
const openModal = () => {
const openModal = useCallback(() => {
setOpenExcel(true);
};
const handleResetExcelData = () => {
dispatch(emptyExcelData());
};
const handleSubmitbulk = (excelData) => {
}, []);
const handleSubmitbulk = useCallback((excelData) => {
setExceldatasubmit(excelData?.filter((e) => e?.isModified));
};
}, []);
const handleSubmit = async () => {
const handleSubmit = useCallback(async () => {
setBulkpost(true);
let FilterData = Exceldatasubmit?.filter((a) => a['ProductName'] != '');
if (FilterData && FilterData.length > 0) {
const formattedData = FilterData?.map((data) => ({
AppId: getSession('AppId'),
CompId: getSession('CompId'),
BranchId: getSession('BranchId'),
CreatedBy: getSession('UserId'),
const FilterData = Exceldatasubmit?.filter(
a => a.ProductName !== ''
);
ProdName: data?.ProductName,
ProdVariantName: data?.ProductVariantName,
Size: data?.Quantity,
UOM: data?.UOM,
MRP: data?.MRP,
WhSalePrice: data?.WhSalePrice,
SellPrice: data?.SellPrice,
ProdCat: data?.Category ? data?.Category : 'General',
ProdSubCat: data?.SubCategory,
Brand: data?.Brand ? data?.Brand : '',
AutoGenerateQr: data?.AutoGenerateQrcode
? data?.AutoGenerateQrcode
: 'No',
QRCode: data?.AddQrCode,
StockAvailable: data?.StockAvailable ? data?.StockAvailable : 'No',
TaxId: data?.Tax ? data?.Tax : 'NIL - 0%',
Cess: data?.Cess,
HSNCode: data?.HSN,
PartNumber: data?.PartNumber,
Rack: data?.Rack,
ManufDate: moment(data?.ManufactureDate, ['M/D/YY']).format(
'YYYY-MM-DDTHH:mm:ss'
),
ExpDate: moment(data?.ExpireDate, ['M/D/YY']).format(
'YYYY-MM-DDTHH:mm:ss'
),
AvailableFrom: data?.AvailableFrom
? moment(data?.AvailableFrom, ['M/D/YY']).format('HH:mm:ss')
: '',
AvailableTo: data?.AvailableTo
? moment(data?.AvailableTo, ['M/D/YY']).format('HH:mm:ss')
: '',
OnePcsAvailable: data?.Amountperpiece ? data?.Amountperpiece : 'No',
OnePcsPrice: data?.AmountperpiecePrice,
// NoOfPcs:data?.NumberOfPieceInside,
AutoGenerateSingleQr: data?.AutoGenerateOnePieceQrcode
? data?.AutoGenerateOnePieceQrcode
: 'No',
OnePcQR: data?.AutoGenerateOnePieceQrcodeNumber,
// ProductType:data?.ProductType,
TokenAvailable: data?.TokenAvailable ? data?.TokenAvailable : 'No',
ProdLogo: data?.Productimage,
}));
let postDatas = { prodDetails: formattedData };
let response = await dispatch(bulkpostdata(postDatas)).unwrap();
if (response?.data?.statusCode == 1) {
setMessageType('success');
setMessageData(response?.data?.response);
setBulkpost(false);
setpage(1);
var responseData = await dispatch(
getProductDataPageNo({ CompId, BranchId, AppId, PageNumber: 1 })
).unwrap();
setCurrentPage(1);
if (responseData?.data?.statusCode === 1) {
setCachedData({ [currentPage]: responseData?.data?.data });
setproductData(responseData?.data?.data);
}
} else {
setMessageType('error');
setMessageData(responseData?.data?.response);
}
handleResetExcelData();
handleCancel();
} else {
if (!FilterData || FilterData.length === 0) {
setBulkpost(false);
setMessageType('error');
setMessageData('No data to submit. Please upload an Excel file.');
return;
}
};
const Unit = UomPreference?.map((e) => e.ConfigName);
const CategoryId = ProdCatData?.map((e) => e.ConfigId);
const CategoryNames = ProdCatData?.map((e) => e.ConfigName);
const CatconfigId = ProdCatData?.map((e) => e.ConfigId);
const Subcatnames = subCatData?.map((e) => e.ConfigName);
const SubcatId = subCatData?.map((e) => e.ConfigId);
const SubcatNumFId = subCatData?.map((e) => e.NumFId);
const BrandNumFId = allBrandData?.map((e) => e.NumFId);
const BrandId = allBrandData?.map((e) => e.ConfigId);
const BrandName = allBrandData?.map((e) => e.ConfigName);
const SuplierNames = SupplierData?.map((e) => e.SuppName);
const TaxDatas = TaxData?.map((e) => e.TaxIdName);
const TaxData1 = TaxData?.map((e) => e.TaxPercentage);
const combinedTaxData = TaxDatas?.map(
(taxIdName, index) => `${taxIdName} - ${TaxData1[index]}%`
const formattedData = FilterData.map(data => ({
AppId: getSession('AppId'),
CompId: getSession('CompId'),
BranchId: getSession('BranchId'),
CreatedBy: getSession('UserId'),
ProdName: data.ProductName,
ProdVariantName: data.ProductVariantName,
Size: data.Quantity,
UOM: data.UOM,
MRP: data.MRP,
WhSalePrice: data.WhSalePrice,
SellPrice: data.SellPrice,
ProdCat: data.Category || 'General',
ProdSubCat: data.SubCategory,
Brand: data.Brand || '',
AutoGenerateQr: data.AutoGenerateQrcode || 'No',
QRCode: data.AddQrCode,
StockAvailable: data.StockAvailable || 'No',
TaxId: data.Tax || 'NIL - 0%',
Cess: data.Cess,
HSNCode: data.HSN,
PartNumber: data.PartNumber,
Rack: data.Rack,
ManufDate: moment(data.ManufactureDate, ['M/D/YY']).format(
'YYYY-MM-DDTHH:mm:ss'
),
ExpDate: moment(data.ExpireDate, ['M/D/YY']).format(
'YYYY-MM-DDTHH:mm:ss'
),
AvailableFrom: data.AvailableFrom
? moment(data.AvailableFrom, ['M/D/YY']).format('HH:mm:ss')
: '',
AvailableTo: data.AvailableTo
? moment(data.AvailableTo, ['M/D/YY']).format('HH:mm:ss')
: '',
OnePcsAvailable: data.Amountperpiece || 'No',
OnePcsPrice: data.AmountperpiecePrice,
AutoGenerateSingleQr: data.AutoGenerateOnePieceQrcode || 'No',
OnePcQR: data.AutoGenerateOnePieceQrcodeNumber,
TokenAvailable: data.TokenAvailable || 'No',
ProdLogo: data.Productimage,
}));
const postDatas = { prodDetails: formattedData };
const response = await dispatch(bulkpostdata(postDatas)).unwrap();
if (response?.data?.statusCode === 1) {
setMessageType('success');
setMessageData(response.data.response);
setpage(1);
const responseData = await dispatch(
getProductDataPageNo({ CompId, BranchId, AppId, PageNumber: 1 })
).unwrap();
if (responseData?.data?.statusCode === 1) {
setCachedData({ 1: responseData.data.data });
setproductData(responseData.data.data);
setCurrentPage(1);
}
} else {
setMessageType('error');
setMessageData(response?.data?.response);
}
setBulkpost(false);
handleResetExcelData();
handleCancel();
}, [
Exceldatasubmit,
CompId,
BranchId,
AppId,
handleResetExcelData,
handleCancel
]);
const Unit = useMemo(
() => UomPreference?.map((e) => e.ConfigName),
[UomPreference]
);
const CategoryId = useMemo(
() => ProdCatData?.map((e) => e.ConfigId),
[ProdCatData]
);
const CategoryNames = useMemo(
() => ProdCatData?.map((e) => e.ConfigName),
[ProdCatData]
);
const CatconfigId = useMemo(
() => ProdCatData?.map((e) => e.ConfigId),
[ProdCatData]
);
const Subcatnames = useMemo(
() => subCatData?.map((e) => e.ConfigName),
[subCatData]
);
const SubcatId = useMemo(
() => subCatData?.map((e) => e.ConfigId),
[subCatData]
);
const SubcatNumFId = useMemo(
() => subCatData?.map((e) => e.NumFId),
[subCatData]
);
const BrandNumFId = useMemo(
() => allBrandData?.map((e) => e.NumFId),
[allBrandData]
);
const BrandId = useMemo(
() => allBrandData?.map((e) => e.ConfigId),
[allBrandData]
);
const BrandName = useMemo(
() => allBrandData?.map((e) => e.ConfigName),
[allBrandData]
);
const SuplierNames = useMemo(
() => SupplierData?.map((e) => e.SuppName),
[SupplierData]
);
const TaxDatas = useMemo(
() => TaxData?.map((e) => e.TaxIdName),
[TaxData]
);
const TaxData1 = useMemo(
() => TaxData?.map((e) => e.TaxPercentage),
[TaxData]
);
const combinedTaxData = useMemo(
() =>
TaxDatas?.map(
(taxIdName, index) => `${taxIdName} - ${TaxData1[index]}%`
),
[TaxDatas, TaxData1]
);
const Deletebulk = async () => {
let data = {
@ -2641,7 +2706,7 @@ const ProductList = () => {
generateQRCodeCopy={(code) =>
generateQRCodeCopy(QrandbarcodeDatas, code)
}
generateCodeImage={(code, codeType = 'Q') => generateCodeImage(code, codeType, QrandbarcodeDatas) }
generateCodeImage={(code, codeType = 'Q') => generateCodeImage(code, codeType, QrandbarcodeDatas)}
imageTagBarcodeAndQR={imageTagBarcodeAndQR}
dropdownValue={dropdownValue}
barcodeTemplateDetails={barcodeTemplateDetails}

View File

@ -1715,7 +1715,7 @@ const StockForm = ({ formType }) => {
title: 'Amount per piece',
dataIndex: 'OnePcsPrice',
key: 'OnePcsPrice',
width: 70,
width: 125,
editable: true,
render: (_, record, index) => {
return (
@ -1751,7 +1751,7 @@ const StockForm = ({ formType }) => {
title: 'Number of piece',
dataIndex: 'NoOfPcs',
key: 'NoOfPcs',
width: 70,
width: 125,
editable: true,
render: (_, record, index) => {
return (
@ -1784,7 +1784,7 @@ const StockForm = ({ formType }) => {
title: 'Wholesale price',
dataIndex: 'WhSalePrice',
key: 'WhSalePrice',
width: 70,
width: 125,
editable: true,
render: (_, record) => {
return (
@ -1821,6 +1821,7 @@ const StockForm = ({ formType }) => {
dataIndex: 'ManufDate',
key: 'ManufDate',
editable: true,
width: 100,
render: (text, record, index) => {
return (
<DatePicProd
@ -1856,6 +1857,7 @@ const StockForm = ({ formType }) => {
dataIndex: 'ExpDate',
key: 'ExpDate',
editable: true,
width: 100,
render: (text, record, index) => {
return (
<DatePicProd
@ -1879,7 +1881,8 @@ const StockForm = ({ formType }) => {
dataIndex: 'Hsn',
key: 'Hsn',
editable: true,
// width: 130,
width: 100,
align: 'center',
render: (text, record, index) => {
return (
<Input
@ -1911,6 +1914,8 @@ const StockForm = ({ formType }) => {
dataIndex: 'Model',
key: 'Model',
editable: true,
width: 100,
align: 'center',
render: (text, record, index) => {
return (
<Input
@ -1942,6 +1947,8 @@ const StockForm = ({ formType }) => {
title: 'Batch',
dataIndex: 'Batch',
key: 'Batch',
width: 100,
align: 'center',
editable: true,
render: (text, record, index) => {
return (
@ -1976,6 +1983,8 @@ const StockForm = ({ formType }) => {
dataIndex: 'RejectedQty',
key: 'RejectedQty',
editable: true,
width: 100,
align: 'center',
render: (text, record, index) => {
return (
<Input
@ -2034,6 +2043,8 @@ const StockForm = ({ formType }) => {
dataIndex: 'Freeqty',
key: 'Freeqty',
editable: true,
width: 100,
align: 'center',
render: (text, record) => {
return (
<Input

View File

@ -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';
@ -119,6 +120,7 @@ const StockPriceUpdate = () => {
const [fileLoading, setFileLoading] = useState(false);
const [loading, setLoading] = useState(false);
const [headers, setHeaders] = useState([]);
console.log(headers, 'headers');
const [uploadedData, setUploadedData] = useState([]);
const CompId = getSession('CompId');
const BranchId = getSession('BranchId');
@ -150,7 +152,7 @@ const StockPriceUpdate = () => {
const handleRemoveRecord = (index) => {
setUploadedData((prev) => prev.filter((_, i) => i !== index));
};
console.log(uploadedData, 'uploadedData');
const columns = [
{
title: 'Product Name',
@ -158,7 +160,10 @@ const StockPriceUpdate = () => {
key: 'ProductName',
width: 180,
render: (value, record, index) => (
<p>{`${value} (${record?.Size} ${record?.UOMName})`}</p>
<p>
{value}{' '}
{record?.Size && `(${record?.Size || ''} ${record?.UOMName || ''})`}
</p>
),
},
{
@ -807,6 +812,7 @@ const StockPriceUpdate = () => {
}
currentRow[field] = numValue;
currentRow.isModified = true;
updated[rowIndex] = currentRow;
return updated;
});
@ -1487,7 +1493,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 +1761,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 +1962,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 +1990,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 +2088,7 @@ const StockPriceUpdate = () => {
onComplete={onComplete}
/>
<div className="formAddNew" style={{justifyContent:"space-between"}}>
<div className="formAddNew" style={{ justifyContent: 'space-between' }}>
<div>
<FormHeader title={'Price Change'} />
</div>
@ -2058,9 +2100,7 @@ const StockPriceUpdate = () => {
}}
>
{RadioSelection == 'Bulk' && (
<div
className='PriChangeUpper'
>
<div className="PriChangeUpper">
<div className="formSearch">
<Search
value={BulksearchedText}
@ -2360,14 +2400,24 @@ const StockPriceUpdate = () => {
<Table
columns={columns}
rowKey={(record) => record.localId}
// components={components}
// bordered
dataSource={uploadedData}
// className="tableExcelUpload"
// onChange={handleTableChange}
className="price-change-data"
rowClassName={(record) =>
record.isModified ? 'modified-row' : 'old-row'
}
/>
</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
className="cancel-link"
onClick={handleCancelData}

View File

@ -0,0 +1,76 @@
.viewerExcelupload {
.ant-table-tbody {
.old-row {
background-color: #97441d !important;
td {
background-color: #ffe1fb !important;
}
&:hover {
background-color: #ffe1fb !important;
> td {
background-color: #ffe1fb !important;
}
}
}
.modified-row {
background-color: #cdffd5 !important;
td {
background-color: #cdffd5 !important;
}
&:hover {
background-color: #cdffd5 !important;
> td {
background-color: #cdffd5 !important;
}
}
}
}
.ant-table-tbody > tr.old-row:hover > td {
background-color: #ff9595 !important;
}
.ant-table-tbody > tr.modified-row:hover > td {
background-color: #aeffbb !important;
}
.legend-container {
margin-bottom: 10px;
display: flex;
gap: 15px;
align-items: center;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
}
.legend-box {
width: 20px;
height: 20px;
border-radius: 3px;
}
.old-box {
background: #ffe1fb;
border: 1px solid #ff43e6;
}
.modified-box {
background: #cdffd5;
border: 1px solid #72e018;
}
.legend-text {
font-size: 13px;
}
}

View File

@ -0,0 +1,26 @@
import { useEffect, useRef } from 'react';
function useWhyDidYouUpdate(componentName, props) {
const prevProps = useRef(props);
useEffect(() => {
const allKeys = Object.keys({ ...prevProps.current, ...props });
const changes = {};
allKeys.forEach((key) => {
if (prevProps.current[key] !== props[key]) {
changes[key] = {
from: prevProps.current[key],
to: props[key],
};
}
});
if (Object.keys(changes).length > 0) {
console.log(`🔍 ${componentName} re-rendered due to:`, changes);
}
prevProps.current = props;
});
}
export default useWhyDidYouUpdate

View File

@ -107,7 +107,6 @@
}
.ant-table-cell {
.ant-form-item {
margin-bottom: unset;
@ -116,4 +115,38 @@
}
}
}
}
.SheetIndiacte {
display: flex;
align-items: center;
gap: 1rem;
div {
display: flex;
align-items: center;
gap: 5px;
}
.mdsheet {
width: 25px;
height: 25px;
border: 1px solid #5bff73;
background-color: #b3ffbf;
border-radius: 4px;
}
.mdsheet2 {
width: 25px;
border-radius: 4px;
height: 25px;
background-color: #ffc7f8;
border: 1px solid #ff74ec;
}
span {
color: #333;
font-family: "Poppins";
font-size: 14px;
font-weight: 500;
}
}