Merge pull request 'Fix #31: Add Supplier Product Mapping model Add button , All Product Mapping in the table' (#32) from purchase-Delivery-address into main
Reviewed-on: Pozomind/pozo-retail-app#32
This commit is contained in:
commit
3aa0e13b7a
|
|
@ -14,17 +14,17 @@ import {
|
||||||
} from '../../Features/SupplierProductMapping/SupplierProductMapping.js';
|
} from '../../Features/SupplierProductMapping/SupplierProductMapping.js';
|
||||||
import { getsupplierBasedOnCmpId, getsupplierBasedOnCmpIdBrId } from '../../Features/SupplierMaster/SupplierMaster.js';
|
import { getsupplierBasedOnCmpId, getsupplierBasedOnCmpIdBrId } from '../../Features/SupplierMaster/SupplierMaster.js';
|
||||||
|
|
||||||
const SupplierProductMappingForm = ({
|
const SupplierProductMappingForm = ({
|
||||||
isModalOpen = false,
|
isModalOpen = false,
|
||||||
setIsModalOpen,
|
setIsModalOpen,
|
||||||
CompId,
|
CompId,
|
||||||
BranchId,
|
BranchId,
|
||||||
AppId,
|
AppId,
|
||||||
setMessage,
|
setMessage,
|
||||||
onMappingAdded
|
onMappingAdded
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
// State variables
|
// State variables
|
||||||
const [supplierOptions, setSupplierOptions] = useState([]);
|
const [supplierOptions, setSupplierOptions] = useState([]);
|
||||||
const [productOptions, setProductOptions] = useState([]);
|
const [productOptions, setProductOptions] = useState([]);
|
||||||
|
|
@ -36,18 +36,18 @@ const SupplierProductMappingForm = ({
|
||||||
const [modalSelectedProduct, setModalSelectedProduct] = useState(null);
|
const [modalSelectedProduct, setModalSelectedProduct] = useState(null);
|
||||||
const [tabledata, setTabledata] = useState([]);
|
const [tabledata, setTabledata] = useState([]);
|
||||||
const [filteredTableData, setFilteredTableData] = useState([]);
|
const [filteredTableData, setFilteredTableData] = useState([]);
|
||||||
const details = {
|
const details = {
|
||||||
name :"tamil",
|
name: "tamil",
|
||||||
address : {
|
address: {
|
||||||
city : "hosur"
|
city: "hosur"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
const { address: { city } } = details
|
||||||
const {address : {city}} = details
|
|
||||||
|
|
||||||
// Fetch suppliers function
|
// Fetch suppliers function
|
||||||
const fetchSypplaiers = async () => {
|
const fetchSypplaiers = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await dispatch(getsupplierBasedOnCmpIdBrId({cmpId : CompId,BranchId,AppId}))?.unwrap();
|
const response = await dispatch(getsupplierBasedOnCmpIdBrId({ cmpId: CompId, BranchId, AppId }))?.unwrap();
|
||||||
if (response?.data?.statusCode === 1) {
|
if (response?.data?.statusCode === 1) {
|
||||||
const filteredData = response?.data?.data?.filter(filter => filter.ActiveStatus === 'A');
|
const filteredData = response?.data?.data?.filter(filter => filter.ActiveStatus === 'A');
|
||||||
setSupplierOptions(filteredData);
|
setSupplierOptions(filteredData);
|
||||||
|
|
@ -155,7 +155,7 @@ const {address : {city}} = details
|
||||||
setMessage({ type: "error", data: "Please select a supplier" });
|
setMessage({ type: "error", data: "Please select a supplier" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelTableData.length === 0) {
|
if (modelTableData.length === 0) {
|
||||||
setMessage({ type: "error", data: "Please add at least one product" });
|
setMessage({ type: "error", data: "Please add at least one product" });
|
||||||
return;
|
return;
|
||||||
|
|
@ -220,6 +220,14 @@ const {address : {city}} = details
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const allProductMap = () => {
|
||||||
|
const allProducts = productOptions;
|
||||||
|
const newTableData = [...modelTableData, ...allProducts];
|
||||||
|
setModelTableData(newTableData);
|
||||||
|
setProductOptions([]);
|
||||||
|
setMessage({ type: "success", data: "All Products Added Successfully" });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DefaultModal
|
<DefaultModal
|
||||||
open={isModalOpen}
|
open={isModalOpen}
|
||||||
|
|
@ -236,9 +244,9 @@ const {address : {city}} = details
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: "0.5rem", position: "relative" }}>
|
<div style={{ display: "flex", alignItems: "center", gap: "0.5rem", position: "relative" }}>
|
||||||
<DropDowns
|
<DropDowns
|
||||||
label={<label className='required'>Supplier Name</label>}
|
label={<label className='required'>Supplier Name</label>}
|
||||||
options={supplierOptions?.map(item => ({
|
options={supplierOptions?.map(item => ({
|
||||||
value: item.SuppId,
|
value: item.SuppId,
|
||||||
label: item.SuppName ?? item.SuppMobile ?? "No Name"
|
label: item.SuppName ?? item.SuppMobile ?? "No Name"
|
||||||
}))}
|
}))}
|
||||||
valueData={modalSelectedSupplier}
|
valueData={modalSelectedSupplier}
|
||||||
onChangeFunction={handleModelSuplaierOnChange}
|
onChangeFunction={handleModelSuplaierOnChange}
|
||||||
|
|
@ -247,18 +255,18 @@ const {address : {city}} = details
|
||||||
/>
|
/>
|
||||||
<AddSupplierModal onSupplierAdded={fetchSypplaiers} message={setMessage} />
|
<AddSupplierModal onSupplierAdded={fetchSypplaiers} message={setMessage} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{modalSelectedSupplier && (
|
{modalSelectedSupplier && (
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: "0.5rem", position: "relative" }}>
|
<div style={{ display: "flex", alignItems: "center", gap: "0.5rem", position: "relative" }}>
|
||||||
<DropDowns
|
<DropDowns
|
||||||
key={`product-dropdown-${dropdownKey}`}
|
key={`product-dropdown-${dropdownKey}`}
|
||||||
label={<label className='required'>Product Name</label>}
|
label={<label className='required'>Product Name</label>}
|
||||||
options={productOptions.map(item => {
|
options={productOptions.map(item => {
|
||||||
const size = (item.Size === null ? "" : " (" + item.Size + " " + (item.UomName === null ? "" : item.UomName) + ") ")
|
const size = (item.Size === null ? "" : " (" + item.Size + " " + (item.UomName === null ? "" : item.UomName) + ") ")
|
||||||
const brand = item.BrandName === null ? "" : item.BrandName
|
const brand = item.BrandName === null ? "" : item.BrandName
|
||||||
return {
|
return {
|
||||||
value: item.ProdId,
|
value: item.ProdId,
|
||||||
label: item.ProdName + size + brand
|
label: item.ProdName + size + brand
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
valueData={modalSelectedProduct}
|
valueData={modalSelectedProduct}
|
||||||
|
|
@ -266,16 +274,19 @@ const {address : {city}} = details
|
||||||
isOnchanges={false}
|
isOnchanges={false}
|
||||||
alphabetfilter="Yes"
|
alphabetfilter="Yes"
|
||||||
/>
|
/>
|
||||||
|
<button style={{ padding: '10px 10px', margin: '0px 15px', borderRadius: '6px',fontFamily:'poppins', background: '#901D77', color: 'white', border: 'none', cursor: 'pointer' }}
|
||||||
|
onClick={allProductMap}>Add All</button>
|
||||||
|
|
||||||
<div style={{ position: "absolute", left: "16rem", top: "1px" }}>
|
<div style={{ position: "absolute", left: "16rem", top: "1px" }}>
|
||||||
<Tooltip title={"Add Product"} placement={"top"}>
|
<Tooltip title={"Add Product"} placement={"top"}>
|
||||||
<PlusCircleOutlined
|
<PlusCircleOutlined
|
||||||
onClick={addProductOnClick}
|
onClick={addProductOnClick}
|
||||||
style={{ cursor: "pointer", fontSize: "16px" }}
|
style={{ cursor: "pointer", fontSize: "16px" }}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<FeaturesFunctionalities
|
<FeaturesFunctionalities
|
||||||
handleQuickAddCancel={onProductAdded}
|
handleQuickAddCancel={onProductAdded}
|
||||||
QuickAdd={addProduct}
|
QuickAdd={addProduct}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue