convert into components
This commit is contained in:
parent
25ee133359
commit
f04b00474d
|
|
@ -1,6 +1,8 @@
|
||||||
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
||||||
import { axiosRetailInstanceData,axiosRetailOcrData } from '../AuthenicationToken/AuthenticationToken';
|
import {
|
||||||
|
axiosRetailInstanceData,
|
||||||
|
axiosRetailOcrData,
|
||||||
|
} from '../AuthenicationToken/AuthenticationToken';
|
||||||
|
|
||||||
// get Product dropdown
|
// get Product dropdown
|
||||||
export const getProductData = createAsyncThunk(
|
export const getProductData = createAsyncThunk(
|
||||||
|
|
@ -28,17 +30,13 @@ export const getInvoiceImageData = createAsyncThunk(
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file); // 👈 actual file here
|
formData.append('file', file); // 👈 actual file here
|
||||||
|
|
||||||
const response = await axiosRetailOcrData.post(
|
const response = await axiosRetailOcrData.post('/invoice', formData, {
|
||||||
"/invoice",
|
headers: {
|
||||||
formData,
|
'Content-Type': 'multipart/form-data',
|
||||||
{
|
},
|
||||||
headers: {
|
});
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
@ -125,16 +123,34 @@ export const postPurchaseData = createAsyncThunk(
|
||||||
export const getPurchaseData = createAsyncThunk(
|
export const getPurchaseData = createAsyncThunk(
|
||||||
'Stock/getPurchaseData',
|
'Stock/getPurchaseData',
|
||||||
async (ProdData) => {
|
async (ProdData) => {
|
||||||
|
console.log(ProdData, 'ProdData');
|
||||||
if (
|
if (
|
||||||
ProdData?.CompId != null &&
|
ProdData?.CompId != null &&
|
||||||
ProdData?.CompId != undefined &&
|
ProdData?.CompId != undefined &&
|
||||||
ProdData?.BranchId != null &&
|
ProdData?.BranchId != null &&
|
||||||
ProdData?.BranchId != undefined &&
|
ProdData?.BranchId != undefined &&
|
||||||
ProdData?.AppId != null &&
|
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(
|
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',
|
name: 'Stock',
|
||||||
initialState,
|
initialState,
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(getProductData.fulfilled, (state, action) => {
|
(builder.addCase(getProductData.fulfilled, (state, action) => {
|
||||||
if (action?.payload?.status) {
|
if (action?.payload?.status) {
|
||||||
state.ProductData = action?.payload?.data?.data?.filter(
|
state.ProductData = action?.payload?.data?.data?.filter(
|
||||||
(item) => item?.ProdTypeName === 'Product'
|
(item) => item?.ProdTypeName === 'Product'
|
||||||
|
|
@ -335,7 +351,7 @@ const StockSlice = createSlice({
|
||||||
} else {
|
} else {
|
||||||
state.PurchaseData = [];
|
state.PurchaseData = [];
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
Loading…
Reference in New Issue