Merge pull request 'Added Policy Details' (#314) from srinath into main

Reviewed-on: Pozomind/pozo-retail-app#314
This commit is contained in:
karthikalakshmi 2026-03-26 15:05:46 +05:30
commit b683d348cc
1 changed files with 68 additions and 14 deletions

View File

@ -17,6 +17,7 @@ import { DatePicProd } from "../../Components/Forms/DatePickerProduct";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { FaEye, FaPlus } from "react-icons/fa"; import { FaEye, FaPlus } from "react-icons/fa";
import { DefaultModal } from "../../Components/Modal/DefaultModal"; import { DefaultModal } from "../../Components/Modal/DefaultModal";
import { IoEye } from "react-icons/io5";
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const SEARCH_OPTIONS = [ const SEARCH_OPTIONS = [
@ -70,6 +71,8 @@ const SalesBillProductsReturn = () => {
const [currentEditingItem, setCurrentEditingItem] = useState(null); const [currentEditingItem, setCurrentEditingItem] = useState(null);
const [modalDescription, setModalDescription] = useState(''); const [modalDescription, setModalDescription] = useState('');
const [modalImageUrl, setModalImageUrl] = useState(''); const [modalImageUrl, setModalImageUrl] = useState('');
const [policyDeatilModal, setPolicyDeatilModal] = useState(false);
const [selectedPolicyDetails, setSelectedPolicyDetails] = useState(null);
console.log(selectedItems, "selectedItemsselectedItemsselectedItems") console.log(selectedItems, "selectedItemsselectedItemsselectedItems")
@ -77,7 +80,7 @@ const SalesBillProductsReturn = () => {
navigateTo(`${subDirectory}setting/sales-bill-product-return/list`); navigateTo(`${subDirectory}setting/sales-bill-product-return/list`);
}; };
const handleCheckboxChange = (item, checked) => { const handleCheckboxChange = (item, checked) => {
const { ProdId, InwardDtlId, Type, SalesQty, Rate, TotalAmt, TaxAmt, SinglePc, ProdNameQty,IsWarrantyEligible } = item; const { ProdId, InwardDtlId, Type, SalesQty, Rate, TotalAmt, TaxAmt, SinglePc, ProdNameQty, IsWarrantyEligible } = item;
if (checked) { if (checked) {
const data = { const data = {
ProdId, ProdId,
@ -108,7 +111,15 @@ const SalesBillProductsReturn = () => {
const description = product?.Description || "" const description = product?.Description || ""
return { ReturnEligible: eligible, Description: description }; return { ReturnEligible: eligible, Description: description };
}; };
const handleOrdermodalCancel = () => {
setPolicyDeatilModal(false);
setSelectedPolicyDetails(null);
};
const Viewdetails = (item) => {
const policy = policybasedprodcuts?.find(p => p.ProdId === item.ProdId) || null;
setSelectedPolicyDetails(policy);
setPolicyDeatilModal(true);
};
useEffect(() => { useEffect(() => {
const fetchPaymentOptions = async () => { const fetchPaymentOptions = async () => {
try { try {
@ -192,12 +203,11 @@ const SalesBillProductsReturn = () => {
try { try {
const res = await dispatch(getReturnBill(data)).unwrap(); const res = await dispatch(getReturnBill(data)).unwrap();
if (res?.data?.statusCode === 1) { if (res?.data?.statusCode === 1) {
const modifiedData = res?.data?.data?.map(item => { const modifiedData = res?.data?.data?.map(item => {
return { return {
...item, ...item,
productDetails: item?.productDetails.map(product => { productDetails: item?.productDetails?.map(product => {
return { return {
...product, ...product,
ExchangeQty: 0, ExchangeQty: 0,
@ -577,8 +587,9 @@ const SalesBillProductsReturn = () => {
<table className="custom-product-table"> <table className="custom-product-table">
<thead> <thead>
<tr> <tr>
<th></th> <th>Select</th>
<th style={{ width: "30px", whiteSpace: "normal", wordWrap: "break-word" }}>Sl.No</th> <th style={{ width: "30px", whiteSpace: "normal", wordWrap: "break-word" }}>Sl.No</th>
<th style={{ width: "100px", whiteSpace: "normal", wordWrap: "break-word" }}>Policy Details</th>
<th style={{ width: "100px", whiteSpace: "normal", wordWrap: "break-word" }}>Product Name</th> <th style={{ width: "100px", whiteSpace: "normal", wordWrap: "break-word" }}>Product Name</th>
<th style={{ width: "70px", whiteSpace: "normal", wordWrap: "break-word" }}>Sales-Qty</th> <th style={{ width: "70px", whiteSpace: "normal", wordWrap: "break-word" }}>Sales-Qty</th>
<th style={{ width: "80px", whiteSpace: "normal", wordWrap: "break-word" }}>Rate</th> <th style={{ width: "80px", whiteSpace: "normal", wordWrap: "break-word" }}>Rate</th>
@ -597,17 +608,23 @@ const SalesBillProductsReturn = () => {
disabled={!ReturnEligible} disabled={!ReturnEligible}
onChange={(e) => handleCheckboxChange(item, e.target.checked)} onChange={(e) => handleCheckboxChange(item, e.target.checked)}
/> />
{!ReturnEligible && ( {/* {(
<span style={{ marginLeft: 4 }}> <span style={{ marginLeft: 4 }}>
<Tooltip title={Description}> <Tooltip title={Description}>
{/* <span style={{ color: '#faad14', cursor: 'pointer', fontSize: 18, verticalAlign: 'middle' }}> */} <IoEye
<RiErrorWarningLine /> style={{ color: '#1292EE', fontSize: '25px', cursor: 'pointer' }}
{/* </span> */} onClick={() => Viewdetails(item)}
/>
</Tooltip> </Tooltip>
</span> </span>
)} )} */}
</td> </td>
<td style={{ textAlignLast: "center", width: "30px", whiteSpace: "normal", wordWrap: "break-word" }}>{index + 1}</td> <td style={{ textAlignLast: "center", width: "30px", whiteSpace: "normal", wordWrap: "break-word" }}>{index + 1}</td>
<td style={{ width: "100px", wordWrap: "break-word" }}>
<IoEye
style={{ color: '#1292EE', fontSize: '25px', cursor: 'pointer' }}
onClick={() => Viewdetails(item)}
/></td>
<td style={{ width: "100px", wordWrap: "break-word" }}>{item.ProdNameQty}</td> <td style={{ width: "100px", wordWrap: "break-word" }}>{item.ProdNameQty}</td>
<td style={{ textAlignLast: "center" }}>{item.SalesQty}</td> <td style={{ textAlignLast: "center" }}>{item.SalesQty}</td>
<td style={{ textAlignLast: "end" }}>{item.Rate}</td> <td style={{ textAlignLast: "end" }}>{item.Rate}</td>
@ -634,11 +651,11 @@ const SalesBillProductsReturn = () => {
<th>Sales-Qty</th> <th>Sales-Qty</th>
<th>Return-Qty</th> <th>Return-Qty</th>
<th>More</th> <th>More</th>
<th>Details</th> {/* <th>Details</th> */}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{selectedItems.map((item, index) => { {selectedItems?.map((item, index) => {
return ( return (
<tr key={item.ProdId} > <tr key={item.ProdId} >
<td>{index + 1}</td> <td>{index + 1}</td>
@ -706,7 +723,7 @@ const SalesBillProductsReturn = () => {
<FaPlus /> <FaPlus />
</button> </button>
</td> </td>
<td style={{ textAlign: "center", maxWidth: "150px" }}> {/* <td style={{ textAlign: "center", maxWidth: "150px" }}>
{item.description && ( {item.description && (
<Tooltip title={item.description}> <Tooltip title={item.description}>
<div style={{ <div style={{
@ -724,7 +741,7 @@ const SalesBillProductsReturn = () => {
<div>🖼</div> <div>🖼</div>
</Tooltip> </Tooltip>
)} )}
</td> </td> */}
</tr> </tr>
); );
})} })}
@ -816,6 +833,43 @@ const SalesBillProductsReturn = () => {
handleCancel={handleCancel} handleCancel={handleCancel}
handleSubmit={handleModalSubmit} handleSubmit={handleModalSubmit}
/> />
<DefaultModal
open={policyDeatilModal}
title="Product Policy Details"
handleCancel={handleOrdermodalCancel}
footer={false}
children={
<div style={{ padding: '8px' }}>
{selectedPolicyDetails ? (
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: '14px' }}>
<tbody>
{[
['Product Name', selectedPolicyDetails.ProdName],
['Policy Name', selectedPolicyDetails.PolicyName],
['Description', selectedPolicyDetails.Description],
['Return Allowed', selectedPolicyDetails.IsReturnAllowed === 'Y' ? 'Yes' : 'No'],
['Exchange Allowed', selectedPolicyDetails.IsExchangeAllowed === 'Y' ? 'Yes' : 'No'],
['Return Window (Days)', selectedPolicyDetails.ReturnWindowDays],
['Exchange Window (Days)', selectedPolicyDetails.ExchangeWindowDays],
['Exchange Limit Count', selectedPolicyDetails.ExchangeLimitCount ?? 'N/A'],
['Return Eligible', selectedPolicyDetails.ReturnEligible ? 'Yes' : 'No'],
// ['Effective From', selectedPolicyDetails.EffectiveFrom ? dayjs(selectedPolicyDetails.EffectiveFrom).format('DD-MM-YYYY') : 'N/A'],
// ['Effective To', selectedPolicyDetails.EffectiveTo ? dayjs(selectedPolicyDetails.EffectiveTo).format('DD-MM-YYYY') : 'N/A'],
].map(([label, value]) => (
<tr key={label} style={{ borderBottom: '1px solid #f0f0f0' }}>
<td style={{ padding: '8px', fontWeight: 600, color: '#555', width: '45%' }}>{label}</td>
<td style={{ padding: '8px', color: '#222' }}>{value}</td>
</tr>
))}
</tbody>
</table>
) : (
<p style={{ textAlign: 'center', color: '#888' }}>No policy found for this product.</p>
)}
</div>
}
/>
</div> </div>
</div> </div>
</div> </div>