convert into components

This commit is contained in:
Tamilselvan 2026-02-06 13:05:04 +05:30
parent 25ee133359
commit f04b00474d
4 changed files with 3387 additions and 16 deletions

View File

@ -1,6 +1,8 @@
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { axiosRetailInstanceData,axiosRetailOcrData } from '../AuthenicationToken/AuthenticationToken';
import {
axiosRetailInstanceData,
axiosRetailOcrData,
} from '../AuthenicationToken/AuthenticationToken';
// get Product dropdown
export const getProductData = createAsyncThunk(
@ -28,17 +30,13 @@ export const getInvoiceImageData = createAsyncThunk(
if (!file) return;
const formData = new FormData();
formData.append("file", file); // 👈 actual file here
formData.append('file', file); // 👈 actual file here
const response = await axiosRetailOcrData.post(
"/invoice",
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
}
);
const response = await axiosRetailOcrData.post('/invoice', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
return response.data;
}
@ -125,16 +123,34 @@ export const postPurchaseData = createAsyncThunk(
export const getPurchaseData = createAsyncThunk(
'Stock/getPurchaseData',
async (ProdData) => {
console.log(ProdData, 'ProdData');
if (
ProdData?.CompId != null &&
ProdData?.CompId != undefined &&
ProdData?.BranchId != null &&
ProdData?.BranchId != undefined &&
ProdData?.AppId != null &&
ProdData?.AppId != undefined
ProdData?.AppId != undefined &&
ProdData?.OrderFromDate &&
ProdData?.OrderToDate
) {
const params = new URLSearchParams({
compId: ProdData.CompId,
branchId: ProdData.BranchId,
appId: ProdData.AppId,
fromDate: ProdData.OrderFromDate,
toDate: ProdData.OrderToDate,
});
if (ProdData?.search) {
params.append('searchText', ProdData.search);
}
if (ProdData?.PageNumber) {
params.append('pageNumber', ProdData.PageNumber);
}
return await axiosRetailInstanceData.get(
`/Purchase?compId=${ProdData?.CompId}&branchId=${ProdData?.BranchId}&appId=${ProdData?.AppId}`
`/Purchase?${params.toString()}`
);
}
}
@ -306,7 +322,7 @@ const StockSlice = createSlice({
name: 'Stock',
initialState,
extraReducers: (builder) => {
builder.addCase(getProductData.fulfilled, (state, action) => {
(builder.addCase(getProductData.fulfilled, (state, action) => {
if (action?.payload?.status) {
state.ProductData = action?.payload?.data?.data?.filter(
(item) => item?.ProdTypeName === 'Product'
@ -335,7 +351,7 @@ const StockSlice = createSlice({
} else {
state.PurchaseData = [];
}
});
}));
},
});

View File

@ -0,0 +1,94 @@
import { Table, message } from 'antd';
import { DefaultModal } from '../../Components/Modal/DefaultModal.jsx';
const QRCodeCopiesModal = ({
open,
onClose,
type = 'stock', // 'stock' or 'product'
onFinish,
QrandbarcodeDatas,
setQrandbarcodeDatas,
}) => {
const title = type === 'stock' ? 'Stock Wise Qrcode' : 'Product Wise Qrcode';
const showStockIndication = type === 'stock';
const totalCopies = QrandbarcodeDatas?.reduce(
(sum, item) => sum + Number(item?.copiesCount || 0),
0
);
const handleSubmit = () => {
if (totalCopies == 0) {
message.error('Please enter copies count');
return;
} else {
onClose();
onFinish();
}
};
const columns = [
{ title: 'Product Name', dataIndex: 'productName', key: 'productName' },
{
title: 'Copies Count',
dataIndex: 'copiesCount',
key: 'copiesCount',
render: (text, record) => (
<input
className="inputpwiseQR"
type="number"
min="1"
value={record.copiesCount}
onChange={(e) => {
const newValue =
type === 'product'
? parseInt(e.target.value) || 1
: parseInt(e.target.value);
setQrandbarcodeDatas((prev) =>
prev.map((item) =>
item.key === record.key
? { ...item, copiesCount: newValue }
: item
)
);
}}
style={{ width: '80px' }}
/>
),
},
];
return (
<DefaultModal
open={open}
title={title}
handleCancel={onClose}
handleSubmit={handleSubmit}
footer={true}
children={
<>
<div className="ProductList-pwiseQrcode">
<Table
columns={columns}
dataSource={QrandbarcodeDatas}
rowKey="ProdId"
pagination={false}
size="small"
rowClassName={
showStockIndication
? (record) => (record.StockAvailable === 'N' ? 'row-red' : '')
: undefined
}
/>
</div>
{showStockIndication && (
<div className="indicationInfo">
<p></p>
<span>Stock is not Maintained</span>
</div>
)}
</>
}
/>
);
};
export default QRCodeCopiesModal;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff