From d01da1bfc6ebccfde1bf08720ee388d0a12db029 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 29 Jan 2026 14:43:47 +0530 Subject: [PATCH] Purchase Order Deliver Address added new Form --- src/Pages/PurchaseOrder/PurchaseOrder.jsx | 418 ++++++++++++++++------ 1 file changed, 316 insertions(+), 102 deletions(-) diff --git a/src/Pages/PurchaseOrder/PurchaseOrder.jsx b/src/Pages/PurchaseOrder/PurchaseOrder.jsx index 268d069..49deea0 100644 --- a/src/Pages/PurchaseOrder/PurchaseOrder.jsx +++ b/src/Pages/PurchaseOrder/PurchaseOrder.jsx @@ -51,6 +51,7 @@ import { getPrintSelectionComponentData } from '../../Features/ThemeChange/Theme import { PrintStyleFunction } from '../paymentpdfPage/PrintStyleFunction.js'; import { PurchaseOrderMobilePrint } from './PurchsasePrintStyle/PurchaseOrderMobilePrint.js'; import { isMobile } from 'react-device-detect'; +import { CiEdit } from 'react-icons/ci'; const subDirectory = import.meta.env.BASE_URL; const stylesMap = { @@ -79,6 +80,7 @@ const PurchaseOrder = () => { const location = useLocation(); const formProductRef = useRef(null); const formSupplierRef = useRef(null); + const deliveryAddressRef = useRef(null); const dispatch = useDispatch(); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); @@ -107,6 +109,8 @@ const PurchaseOrder = () => { const [submittedOrderData, setSubmittedOrderData] = useState(null); const [isModalOpen, setIsModalOpen] = useState(false); const [isLowStockModel, setisLowStockModel] = useState(false); + const [addressModel, setAddressModel] = useState(false); + const [deliveryAddress, setDeliveryAddress] = useState(''); const [searchedText, setSearchedText] = useState(''); const [iSEmail, setiSEmail] = useState(false); const [enteredEmail, setEnteredEmail] = useState(''); @@ -219,6 +223,7 @@ const PurchaseOrder = () => { console.error('Error fetching stock details:', err); } }; +console.log('hi'); const debouncedFetchStock = useMemo(() => debounce(ProductStockFun, 600), []); const handleMinQtyChange = (e) => { @@ -965,7 +970,7 @@ const PurchaseOrder = () => { PostData['LocationType'] = Supplierdata?.find( (find) => find.SuppId === selecPurSupplier )?.Type; - + PostData['DeliveryAddressDetails'] = deliveryAddress; let PostPurOrder = await dispatch(postPurcOrderData(PostData)).unwrap(); if (PostPurOrder?.data?.statusCode === 1) { setMessage({ type: 'success', data: PostPurOrder?.data?.response }); @@ -989,6 +994,8 @@ const PurchaseOrder = () => { // Reset form fields formProductRef?.current?.resetFields(); formRef?.current?.resetFields(); + deliveryAddressRef?.current?.resetFields(); + setDeliveryAddress(''); setselecPurSupplier(null); getProductDatas(null); setselecSuppDetails(null); @@ -1030,6 +1037,11 @@ const PurchaseOrder = () => { Dist: response[0]['PostOffice'][0]['District'], State: response[0]['PostOffice'][0]['State'], }); + deliveryAddressRef.current?.setFieldsValue({ + City: response[0]['PostOffice'][0]['Block'], + Dist: response[0]['PostOffice'][0]['District'], + State: response[0]['PostOffice'][0]['State'], + }); } else { setZipCodeData(false); } @@ -1250,6 +1262,29 @@ const PurchaseOrder = () => { } }; + const handleAddressSubmit = async () => { + try { + const values = await deliveryAddressRef.current?.validateFields(); + const formattedAddress = { + Address1: values.Address1, + Address2: values.Address2, + Zip: Number(values.Zip), + City: values.City, + Dist: values.Dist, + State: values.State, + Latitude: values.Latitude ?? 0, + Longitude: values.Longitude ?? 0, + CreatedBy: UserId + }; + setDeliveryAddress(formattedAddress); + setAddressModel(false); + } catch (err) { + console.log('Validation error:', err); + } + }; + + + return (
@@ -1344,6 +1379,84 @@ const PurchaseOrder = () => { + +
+ {selecSuppDetails !== null && + (() => { + const fields = []; + if (selecSuppDetails?.SuppName) { + fields.push( +

+ Name: {selecSuppDetails.SuppName} +

+ ); + } + if (selecSuppDetails?.Address1) { + fields.push( +

+ Address:{' '} + {selecSuppDetails.Address1} +

+ ); + } + if (selecSuppDetails?.SuppMobile) { + fields.push( +

+ Mobile Number:{' '} + {selecSuppDetails.SuppMobile} +

+ ); + } + if (selecSuppDetails?.DiscountLevel) { + fields.push( +

+ Discount Level:{' '} + {selecSuppDetails.DiscountLevel} +

+ ); + } + if (selecSuppDetails?.QualityofSupp) { + fields.push( +

+ Quality of Supplier:{' '} + {selecSuppDetails.QualityofSupp} +

+ ); + } + if (selecSuppDetails?.OtherInfo) { + fields.push( +

+ Other Info:{' '} + {selecSuppDetails.OtherInfo} +

+ ); + } + const firstColumn = fields.slice(0, 3); + const secondColumn = fields.slice(3); + return ( +
+
+

{`${selecSuppDetails?.Type} Details:`}

+ {firstColumn} +
+ {secondColumn.length > 0 && ( +
+

+
+

+ {secondColumn} +
+ )} +
+ ); + })()} +
setisLowStockModel(true)} @@ -1351,82 +1464,33 @@ const PurchaseOrder = () => { Low Stock
- {console.log(selecSuppDetails, 'selecSuppDetails')} - {selecSuppDetails !== null && - (() => { - const fields = []; - if (selecSuppDetails?.SuppName) { - fields.push( -

- Name: {selecSuppDetails.SuppName} -

- ); - } - if (selecSuppDetails?.Address1) { - fields.push( -

- Address:{' '} - {selecSuppDetails.Address1} -

- ); - } - if (selecSuppDetails?.SuppMobile) { - fields.push( -

- Mobile Number:{' '} - {selecSuppDetails.SuppMobile} -

- ); - } - if (selecSuppDetails?.DiscountLevel) { - fields.push( -

- Discount Level:{' '} - {selecSuppDetails.DiscountLevel} -

- ); - } - if (selecSuppDetails?.QualityofSupp) { - fields.push( -

- Quality of Supplier:{' '} - {selecSuppDetails.QualityofSupp} -

- ); - } - if (selecSuppDetails?.OtherInfo) { - fields.push( -

- Other Info:{' '} - {selecSuppDetails.OtherInfo} -

- ); - } - const firstColumn = fields.slice(0, 3); - const secondColumn = fields.slice(3); - return ( -
-
-

{`${selecSuppDetails?.Type} Details:`}

- {firstColumn} -
- {secondColumn.length > 0 && ( -
-

-
-

- {secondColumn} -
- )} -
- ); - })()} + {!deliveryAddress &&
setAddressModel(true)} + > + Delivery Address +
} + {deliveryAddress && ( +
+ setAddressModel(true)}>Delivery Address Details: + {deliveryAddress?.Address1 &&

+ Address:{' '} + {deliveryAddress?.Address1} +

} + {deliveryAddress?.City &&

+ City: {deliveryAddress?.City} +

} + {deliveryAddress?.Dist &&

+ district: {deliveryAddress?.Dist} +

} + {deliveryAddress?.State &&

+ State: {deliveryAddress?.State} +

} + {deliveryAddress?.Zip &&

+ Zip: {deliveryAddress?.Zip} +

} +
+ )}
{(() => { @@ -1457,12 +1521,12 @@ const PurchaseOrder = () => {
{/* ({ @@ -1527,9 +1591,9 @@ const PurchaseOrder = () => { options={ !scanner ? PurProductdata?.map((option) => ({ - value: option.ProdId, - label: `${option.ProdName} (${option.Size} ${option.UomName})${option?.BrandName ? ` - ${option?.BrandName}` : ''}`, - })) + value: option.ProdId, + label: `${option.ProdName} (${option.Size} ${option.UomName})${option?.BrandName ? ` - ${option?.BrandName}` : ''}`, + })) : [] } onSelect={PurcProductDropDownChange} @@ -1605,7 +1669,7 @@ const PurchaseOrder = () => { ProductVariantDropDownChange(e) } valueData={SelProductVariant} - // disabled={Edit ? true : false} + // disabled={Edit ? true : false} /> )} @@ -1643,10 +1707,10 @@ const PurchaseOrder = () => { } inputMode="numeric" onInput={(e) => - (e.target.value = e.target.value.replace( - /[^0-9]/g, - '' - )) + (e.target.value = e.target.value.replace( + /[^0-9]/g, + '' + )) } /> @@ -1829,7 +1893,7 @@ const PurchaseOrder = () => { autoComplete="off" label="GST No" autocapitalize="on" - // isOnChange={formType == 'edit' ? true : false} + // isOnChange={formType == 'edit' ? true : false} /> @@ -1851,10 +1915,10 @@ const PurchaseOrder = () => { // isOnChange={formType == 'edit' ? true : false} inputMode="numeric" onInput={(e) => - (e.target.value = e.target.value.replace( - /[^0-9]/g, - '' - )) + (e.target.value = e.target.value.replace( + /[^0-9]/g, + '' + )) } /> @@ -1866,7 +1930,7 @@ const PurchaseOrder = () => { MailId} autocomplete="off" - // isOnChange={formType == 'edit' ? true : false} + // isOnChange={formType == 'edit' ? true : false} /> @@ -1893,7 +1957,7 @@ const PurchaseOrder = () => { Point of Contact} autocomplete="off" - // isOnChange={formType == 'edit' ? true : false} + // isOnChange={formType == 'edit' ? true : false} /> @@ -1915,7 +1979,7 @@ const PurchaseOrder = () => { label={} autocomplete="off" maxLength="10" - // isOnChange={formType == 'edit' ? true : false} + // isOnChange={formType == 'edit' ? true : false} /> @@ -1926,7 +1990,7 @@ const PurchaseOrder = () => { POC MailId} autocomplete="off" - // isOnChange={formType == 'edit' ? true : false} + // isOnChange={formType == 'edit' ? true : false} /> @@ -2276,9 +2340,159 @@ const PurchaseOrder = () => {
} /> + {/* Address model */} + setAddressModel(false)} + footer={true} + children={ +
+
+
+ { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + Address} + /> + + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + Address} + /> + + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + Zipcode} + maxLength="6" + onChange={pinCodeChange} + /> + + {zipCodeData ? ( + <> + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + + ) : ( + '' + )} +
+
+ +
+ } + />
- - + + ); };