2026-02-05 09:30:32 +05:30
|
|
|
import { shallowEqual, useSelector } from "react-redux";
|
|
|
|
|
import { GlobalAccessForOthers, GlobalCardAccess, GlobalCombosearch, GlobalItemCard, GlobalProductCategorie, GlobalSelectedDatas, GlobalWithoutSubCatItemCard, triggerProductCard } from "../../../../Features/BookingScreen/BookingData/BookingData";
|
|
|
|
|
import { DefaultModal } from "../../../../Components/Modal/DefaultModal";
|
|
|
|
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
|
|
import { Tables } from "../../../../Components/Tables/Table";
|
|
|
|
|
import { InputField } from "../../../../Components/Forms/InputField";
|
|
|
|
|
import { Form, Pagination, Tooltip } from "antd";
|
|
|
|
|
import { getSession } from "../../../../Services/Others";
|
|
|
|
|
import { Messages } from "../../../../Components/Notifications/Messages";
|
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import { PutStockPrice } from "../../../../Features/StockPriceUpdate/StockPriceUpdateMaster";
|
2026-02-09 12:48:02 +05:30
|
|
|
import PriceChange from "../../../../Images/PayOptImgs/PriceChange.svg";
|
|
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
2026-02-05 09:30:32 +05:30
|
|
|
|
|
|
|
|
const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, productPriceChange = false, setProductPriceChange = () => { }, setPriceChangeProduct = () => { } }) => {
|
|
|
|
|
|
|
|
|
|
const formRef = useRef(null);
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
const AppId = getSession('AppId');
|
|
|
|
|
const CompId = getSession('CompId');
|
|
|
|
|
const BranchId = getSession('BranchId');
|
|
|
|
|
const UserId = getSession('UserId');
|
|
|
|
|
|
|
|
|
|
const [messageData, setMessageData] = useState(null);
|
|
|
|
|
const [messageType, setMessageType] = useState(null);
|
|
|
|
|
const [currentPage, setCurrentPage] = useState(1);
|
|
|
|
|
const [pageSize] = useState(10);
|
|
|
|
|
|
|
|
|
|
const [noSubcatCardData, setNoSubcatCardData] = useState();
|
|
|
|
|
const [priceChangeModal, setPriceChangeModal] = useState(false);
|
|
|
|
|
|
|
|
|
|
const comboSearch = useSelector(GlobalCombosearch);
|
|
|
|
|
const ProdCat = useSelector(GlobalProductCategorie, shallowEqual);
|
|
|
|
|
const ItemCard = useSelector(GlobalItemCard, shallowEqual);
|
|
|
|
|
const withoutSubCatItemCard = useSelector(GlobalWithoutSubCatItemCard, shallowEqual);
|
|
|
|
|
const CardAccess = useSelector(GlobalCardAccess, shallowEqual);
|
|
|
|
|
const globalAccessForOthers = useSelector(GlobalAccessForOthers, shallowEqual);
|
|
|
|
|
const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual);
|
|
|
|
|
const [tableData, setTableData] = useState([]);
|
|
|
|
|
const [editingKey, setEditingKey] = useState(null);
|
|
|
|
|
const [priceChangedProducts, setPriceChangedProducts] = useState([]);
|
|
|
|
|
console.log(comboSearch, "comboSearch")
|
|
|
|
|
|
|
|
|
|
// console.log(noSubcatCardData, "noSubcatCardData")
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-02-09 14:39:38 +05:30
|
|
|
if (ProdCat && (ItemCard || withoutSubCatItemCard)) {
|
2026-02-05 09:30:32 +05:30
|
|
|
setNoSubcatCardData(ItemCard?.length === 0 ? withoutSubCatItemCard : ItemCard);
|
|
|
|
|
}
|
|
|
|
|
}, [ProdCat, ItemCard, withoutSubCatItemCard, noSubcatCardData]);
|
|
|
|
|
|
|
|
|
|
const priceChangeColumns = [
|
|
|
|
|
{
|
|
|
|
|
title: 'S.No',
|
|
|
|
|
dataIndex: 'SlNo',
|
|
|
|
|
key: 'SlNo',
|
|
|
|
|
width: '60px',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (text, record, index) => <div>{(currentPage - 1) * pageSize + index + 1}</div>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Product Name',
|
|
|
|
|
dataIndex: 'ProdName',
|
|
|
|
|
key: 'ProdName',
|
|
|
|
|
},
|
2026-02-09 12:48:02 +05:30
|
|
|
{
|
|
|
|
|
title: 'Batch No.',
|
|
|
|
|
dataIndex: 'BatchRef',
|
|
|
|
|
key: 'BatchRef',
|
|
|
|
|
},
|
2026-02-05 09:30:32 +05:30
|
|
|
{
|
|
|
|
|
title: 'Old MRP',
|
|
|
|
|
dataIndex: 'MRP',
|
|
|
|
|
key: 'MRP',
|
|
|
|
|
width: '100px',
|
|
|
|
|
align: 'right',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'New MRP (Optional)',
|
|
|
|
|
dataIndex: 'NewMRP',
|
|
|
|
|
key: 'NewMRP',
|
|
|
|
|
width: '100px',
|
|
|
|
|
align: 'right',
|
|
|
|
|
render: (text, record, index) => {
|
|
|
|
|
// if (index === editingKey) {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// return <div>{text ? text : 'Enter New MRP'}</div>
|
|
|
|
|
return (
|
|
|
|
|
<Form.Item
|
2026-02-09 12:48:02 +05:30
|
|
|
key={`NewMRP-${record?.localId}`}
|
|
|
|
|
name={`NewMRP${record?.localId}`}
|
2026-02-05 09:30:32 +05:30
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
validator: async (_, value) => {
|
|
|
|
|
if (value === '') {
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
} else if (parseFloat(value) < 1) {
|
|
|
|
|
return Promise.reject(`MRP should be greater than 0`)
|
|
|
|
|
}
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]}>
|
|
|
|
|
<InputField
|
2026-02-09 12:48:02 +05:30
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
value={text}
|
|
|
|
|
placeholder="Enter New MRP"
|
2026-02-09 12:48:02 +05:30
|
|
|
onChange={(e) => handleNewMRPChange(e?.target?.value, record?.localId)}
|
2026-02-05 09:30:32 +05:30
|
|
|
inputMode="decimal"
|
|
|
|
|
onInput={(e) => {
|
|
|
|
|
let cleanedValue = e.target.value.replace(
|
|
|
|
|
/[^0-9.]/g,
|
|
|
|
|
''
|
|
|
|
|
); // Remove invalid characters
|
|
|
|
|
const parts = cleanedValue.split('.');
|
|
|
|
|
|
|
|
|
|
if (cleanedValue.startsWith('.')) {
|
|
|
|
|
cleanedValue = '0' + cleanedValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.target.value =
|
|
|
|
|
parts.length > 2
|
|
|
|
|
? `${parts[0]}.${parts.slice(1).join('')}`
|
|
|
|
|
: cleanedValue;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Old Sell Price',
|
|
|
|
|
dataIndex: 'SellPrice',
|
|
|
|
|
key: 'SellPrice',
|
|
|
|
|
width: '120px',
|
|
|
|
|
align: 'right',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'New Sell Price',
|
|
|
|
|
dataIndex: 'NewSellPrice',
|
|
|
|
|
key: 'NewSellPrice',
|
2026-02-09 12:48:02 +05:30
|
|
|
width: '120px',
|
2026-02-05 09:30:32 +05:30
|
|
|
align: 'right',
|
|
|
|
|
render: (text, record, index) => {
|
|
|
|
|
// if (index === editingKey) {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// return <div>{text ? text : 'Enter New Sell Price'}</div>
|
|
|
|
|
return (
|
|
|
|
|
<Form.Item
|
2026-02-09 12:48:02 +05:30
|
|
|
key={`NewSellPrice-${record?.localId}`}
|
|
|
|
|
name={`NewSellPrice${record?.localId}`}
|
2026-02-05 09:30:32 +05:30
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
validator: async (_, value) => {
|
|
|
|
|
if (value === '') {
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
} else if (parseFloat(value) < 1) {
|
|
|
|
|
return Promise.reject(`Sell Price should be greater than 0`)
|
|
|
|
|
}
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<InputField
|
2026-02-09 12:48:02 +05:30
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
value={text}
|
|
|
|
|
placeholder="Enter New Sell Price"
|
2026-02-09 12:48:02 +05:30
|
|
|
onChange={(e) => handleNewSellPriceChange(e?.target?.value, record?.localId)}
|
2026-02-05 09:30:32 +05:30
|
|
|
inputMode="decimal"
|
|
|
|
|
onInput={(e) => {
|
|
|
|
|
let cleanedValue = e.target.value.replace(
|
|
|
|
|
/[^0-9.]/g,
|
|
|
|
|
''
|
|
|
|
|
); // Remove invalid characters
|
|
|
|
|
const parts = cleanedValue.split('.');
|
|
|
|
|
|
|
|
|
|
if (cleanedValue.startsWith('.')) {
|
|
|
|
|
cleanedValue = '0' + cleanedValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.target.value =
|
|
|
|
|
parts.length > 2
|
|
|
|
|
? `${parts[0]}.${parts.slice(1).join('')}`
|
|
|
|
|
: cleanedValue;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const cardData = !globalAccessForOthers
|
|
|
|
|
? CardAccess
|
|
|
|
|
? SelectedDatas?.length > 1
|
|
|
|
|
? SelectedDatas
|
|
|
|
|
: SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0
|
|
|
|
|
? []
|
|
|
|
|
: SelectedDatas
|
|
|
|
|
: ItemCard?.length === 0 || (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0)
|
|
|
|
|
? noSubcatCardData
|
|
|
|
|
: ItemCard
|
|
|
|
|
: '';
|
|
|
|
|
|
2026-02-09 14:39:38 +05:30
|
|
|
console.log(cardData, "cardData1", ItemCard, SelectedDatas, noSubcatCardData)
|
2026-02-05 09:30:32 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const extractStockDtls = (data) => {
|
|
|
|
|
if (data?.length === 0) return [];
|
|
|
|
|
|
|
|
|
|
let stockDtls = [];
|
|
|
|
|
|
|
|
|
|
data?.forEach(item => {
|
2026-02-09 12:48:02 +05:30
|
|
|
const products = item?.ProductDetail ?? [];
|
|
|
|
|
|
|
|
|
|
products.forEach(product => {
|
|
|
|
|
const variants = product?.ProdVariantDetails ?? [];
|
|
|
|
|
|
|
|
|
|
variants
|
|
|
|
|
.filter(variant => variant?.StockDetails?.length > 0)
|
|
|
|
|
.forEach(variant => {
|
|
|
|
|
const stocks = variant.StockDetails.map(stock => ({
|
|
|
|
|
...stock,
|
|
|
|
|
ProdName:
|
|
|
|
|
product?.ProdName +
|
|
|
|
|
(
|
|
|
|
|
product?.Size && product?.UomName
|
|
|
|
|
? ` (${product.Size} ${product.UomName})`
|
|
|
|
|
: product?.Size
|
|
|
|
|
? ` (${product.Size})`
|
|
|
|
|
: ''
|
|
|
|
|
) +
|
|
|
|
|
(
|
|
|
|
|
product?.BrandName
|
|
|
|
|
? ` - (${product.BrandName})`
|
|
|
|
|
: ''
|
|
|
|
|
) +
|
|
|
|
|
(
|
|
|
|
|
variant?.ProdVariantName
|
|
|
|
|
? ` (${variant.ProdVariantName})`
|
|
|
|
|
: ''
|
|
|
|
|
),
|
|
|
|
|
UomName: product?.UomName,
|
|
|
|
|
BrandName: product?.BrandName,
|
|
|
|
|
Size: product?.Size,
|
|
|
|
|
StockAvailable: product?.StockAvailable,
|
|
|
|
|
ProdVariantName: variant?.ProdVariantName,
|
|
|
|
|
localId: uuidv4(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
stockDtls.push(
|
|
|
|
|
...stocks.filter(stock =>
|
|
|
|
|
stock?.StockAvailable === 'Y'
|
|
|
|
|
? stock?.BatchRef
|
|
|
|
|
: true
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-02-05 09:30:32 +05:30
|
|
|
});
|
2026-02-09 12:48:02 +05:30
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
console.log("extractStockDtls", stockDtls);
|
|
|
|
|
return stockDtls;
|
|
|
|
|
}
|
|
|
|
|
setTableData(extractStockDtls(priceChangeProduct || cardData))
|
|
|
|
|
setCurrentPage(1)
|
|
|
|
|
}, [cardData, priceChangeProduct])
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-09 12:48:02 +05:30
|
|
|
const handleNewMRPChange = (value, localId) => {
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
const updatedTableData = [...tableData];
|
2026-02-09 12:48:02 +05:30
|
|
|
const index = updatedTableData.findIndex(item => item?.localId === localId);
|
2026-02-05 09:30:32 +05:30
|
|
|
updatedTableData[index].NewMRP = value;
|
|
|
|
|
setTableData(updatedTableData);
|
|
|
|
|
updatedTableData[index].NewSellPrice = null;
|
2026-01-27 18:27:29 +05:30
|
|
|
formRef.current.setFieldsValue({
|
2026-02-09 12:48:02 +05:30
|
|
|
[`NewMRP${localId}`]: value,
|
|
|
|
|
[`NewSellPrice${localId}`]: null,
|
2026-01-27 18:27:29 +05:30
|
|
|
});
|
2026-02-02 19:34:35 +05:30
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
const priceChangedProdList = [...priceChangedProducts];
|
|
|
|
|
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId);
|
2026-01-27 18:27:29 +05:30
|
|
|
if (prodIndex !== -1) {
|
2026-02-05 09:30:32 +05:30
|
|
|
priceChangedProdList[prodIndex] = {
|
|
|
|
|
...priceChangedProdList?.[prodIndex],
|
|
|
|
|
NewMRP: value,
|
|
|
|
|
NewSellPrice: null,
|
|
|
|
|
};
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
|
|
|
|
setPriceChangedProducts(priceChangedProdList);
|
|
|
|
|
}
|
2026-02-05 09:30:32 +05:30
|
|
|
|
2026-02-09 12:48:02 +05:30
|
|
|
const handleNewSellPriceChange = (value, localId) => {
|
|
|
|
|
const index = tableData.findIndex(item => item?.localId === localId);
|
2026-02-05 09:30:32 +05:30
|
|
|
const updatedTableData = [...tableData];
|
|
|
|
|
if (updatedTableData[index]?.NewMRP) {
|
|
|
|
|
if (parseFloat(value) > parseFloat(updatedTableData[index]?.NewMRP)) {
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
setMessageData('New Sell Price cannot be greater than New MRP');
|
|
|
|
|
formRef.current.setFieldsValue({
|
2026-02-09 12:48:02 +05:30
|
|
|
[`NewSellPrice${localId}`]: null,
|
2026-02-05 09:30:32 +05:30
|
|
|
});
|
|
|
|
|
updatedTableData[index].NewSellPrice = null;
|
|
|
|
|
setTableData(updatedTableData);
|
|
|
|
|
const priceChangedProdList = [...priceChangedProducts];
|
|
|
|
|
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId);
|
|
|
|
|
|
|
|
|
|
if (prodIndex !== -1) {
|
|
|
|
|
priceChangedProdList.splice(prodIndex, 1);
|
|
|
|
|
}
|
|
|
|
|
setPriceChangedProducts(priceChangedProdList);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!updatedTableData[index]?.NewMRP && updatedTableData[index]?.MRP) {
|
|
|
|
|
if (parseFloat(value) > parseFloat(updatedTableData[index]?.MRP)) {
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
setMessageData('New Sell Price cannot be greater than MRP');
|
|
|
|
|
formRef.current.setFieldsValue({
|
|
|
|
|
[`NewSellPrice${index}`]: null,
|
|
|
|
|
});
|
|
|
|
|
updatedTableData[index].NewSellPrice = null;
|
|
|
|
|
setTableData(updatedTableData);
|
|
|
|
|
const priceChangedProdList = [...priceChangedProducts];
|
|
|
|
|
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId);
|
|
|
|
|
|
|
|
|
|
if (prodIndex !== -1) {
|
|
|
|
|
priceChangedProdList.splice(prodIndex, 1);
|
|
|
|
|
}
|
|
|
|
|
setPriceChangedProducts(priceChangedProdList);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
updatedTableData[index].NewSellPrice = value;
|
|
|
|
|
setTableData(updatedTableData);
|
2026-01-27 18:27:29 +05:30
|
|
|
formRef.current.setFieldsValue({
|
2026-02-05 09:30:32 +05:30
|
|
|
[`NewSellPrice${index}`]: value,
|
2026-01-27 18:27:29 +05:30
|
|
|
});
|
2026-02-05 09:30:32 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
const priceChangedProdList = [...priceChangedProducts];
|
2026-02-05 09:30:32 +05:30
|
|
|
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId);
|
2026-01-27 18:27:29 +05:30
|
|
|
|
|
|
|
|
if (prodIndex !== -1) {
|
2026-02-05 09:30:32 +05:30
|
|
|
priceChangedProdList[prodIndex] = {
|
|
|
|
|
...priceChangedProdList[prodIndex],
|
|
|
|
|
SellPrice: String(value)
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
priceChangedProdList.push({
|
|
|
|
|
ProdId: updatedTableData[index]?.ProdId,
|
|
|
|
|
ProdName: updatedTableData[index]?.ProdName,
|
|
|
|
|
MRP: String(updatedTableData[index]?.NewMRP || updatedTableData[index]?.MRP),
|
|
|
|
|
SellPrice: String(value),
|
|
|
|
|
AdjComment: "string",
|
|
|
|
|
InwardDtlId: updatedTableData[index]?.InwardDtlId
|
|
|
|
|
});
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
2026-02-05 09:30:32 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
setPriceChangedProducts(priceChangedProdList);
|
|
|
|
|
}
|
2026-02-05 09:30:32 +05:30
|
|
|
|
|
|
|
|
const edit = (record, index) => {
|
|
|
|
|
console.log("edit", record, index);
|
|
|
|
|
setEditingKey(index);
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
|
|
|
|
|
2026-02-05 09:30:32 +05:30
|
|
|
const handleSubmit = async () => {
|
|
|
|
|
console.log("submit");
|
|
|
|
|
|
|
|
|
|
if (priceChangedProducts?.length > 0) {
|
|
|
|
|
console.log("priceChangedProducts", priceChangedProducts);
|
|
|
|
|
const validation = priceChangedProducts?.every((prod) => {
|
|
|
|
|
if (parseFloat(prod?.MRP) < parseFloat(prod?.SellPrice)) {
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
setMessageData(`${prod?.ProdName}: MRP cannot be less than Sell Price`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!parseFloat(prod?.SellPrice) || !parseFloat(prod?.MRP)) {
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
setMessageData(`${prod?.ProdName}: Please give Sell Price or MRP`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
if (!validation) return;
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
AppId: AppId,
|
|
|
|
|
CompId: CompId,
|
|
|
|
|
BranchId: BranchId,
|
|
|
|
|
ProductDetails: priceChangedProducts,
|
|
|
|
|
UpdatedBy: UserId,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const res = await dispatch(PutStockPrice(data))?.unwrap();
|
|
|
|
|
if (res?.data?.statusCode === 1) {
|
|
|
|
|
setMessageData('Price Changed Successfully');
|
|
|
|
|
setMessageType('success');
|
|
|
|
|
setPriceChangeModal(false);
|
|
|
|
|
setProductPriceChange(false);
|
|
|
|
|
setEditingKey(null);
|
|
|
|
|
setPriceChangedProducts([]);
|
|
|
|
|
setTableData([]);
|
|
|
|
|
dispatch(triggerProductCard())
|
|
|
|
|
setPriceChangeProduct(null);
|
|
|
|
|
formRef.current.resetFields();
|
|
|
|
|
} else {
|
|
|
|
|
setMessageData('Error Updating Product Price')
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setMessageType('error');
|
|
|
|
|
setMessageData('No changes made / No sell price entered');
|
2026-02-02 19:34:35 +05:30
|
|
|
}
|
2026-02-05 09:30:32 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
2026-02-05 09:30:32 +05:30
|
|
|
|
|
|
|
|
const onComplete = useCallback(() => {
|
|
|
|
|
setMessageData(null);
|
|
|
|
|
setMessageType(null);
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
|
|
<Messages messageData={messageData} messageType={messageType} onComplete={onComplete} />
|
|
|
|
|
{showButton ? <Tooltip title="Price Change">
|
|
|
|
|
<button className="price-change-btn" type="button" onClick={() => {
|
|
|
|
|
if (comboSearch) {
|
|
|
|
|
setMessageType('warning');
|
|
|
|
|
setMessageData('Price change will not work for combo products');
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
setPriceChangeModal(true)
|
|
|
|
|
}}>
|
|
|
|
|
{/* <FaIndianRupeeSign size={35}/> */}
|
|
|
|
|
<img src={PriceChange} alt="" width={30} />
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip> : <></>}
|
|
|
|
|
<DefaultModal
|
|
|
|
|
title="Price Change"
|
|
|
|
|
className={'price-change-modal'}
|
|
|
|
|
open={priceChangeModal || productPriceChange}
|
|
|
|
|
footer={true}
|
2026-02-09 12:48:02 +05:30
|
|
|
width={900}
|
2026-02-05 09:30:32 +05:30
|
|
|
handleCancel={() => {
|
|
|
|
|
setPriceChangeModal(false);
|
|
|
|
|
setProductPriceChange(false);
|
|
|
|
|
setEditingKey(null);
|
|
|
|
|
setPriceChangedProducts([]);
|
|
|
|
|
formRef?.current?.resetFields();
|
|
|
|
|
setPriceChangeProduct(null);
|
2026-02-09 14:39:38 +05:30
|
|
|
setCurrentPage(1);
|
2026-02-05 09:30:32 +05:30
|
|
|
}}
|
|
|
|
|
handleSubmit={handleSubmit}
|
2026-01-27 18:27:29 +05:30
|
|
|
>
|
2026-02-05 09:30:32 +05:30
|
|
|
<div className="price-change-table">
|
|
|
|
|
{/* <div className="table-notes">Note : Click on a row to edit/modify</div> */}
|
|
|
|
|
<Form ref={formRef}>
|
|
|
|
|
<Tables
|
|
|
|
|
columns={priceChangeColumns}
|
|
|
|
|
data={tableData?.slice((currentPage - 1) * pageSize, currentPage * pageSize)}
|
|
|
|
|
onRow={(record, index) => ({
|
|
|
|
|
onClick: () => {
|
|
|
|
|
edit(record, index);
|
|
|
|
|
},
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'center', margin: '20px 0' }}>
|
|
|
|
|
<Pagination
|
|
|
|
|
current={currentPage}
|
|
|
|
|
pageSize={pageSize}
|
|
|
|
|
total={tableData?.length}
|
|
|
|
|
onChange={(page) => setCurrentPage(page)}
|
|
|
|
|
showSizeChanger={false}
|
|
|
|
|
showTotal={(total, range) => `${range[0]}-${range[1]} of ${total} items`}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
</DefaultModal>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ProductPriceChange;
|