diff --git a/src/Pages/Product/Printstyles.js b/src/Pages/Product/Printstyles.js index 1ebcbd6..a37962f 100644 --- a/src/Pages/Product/Printstyles.js +++ b/src/Pages/Product/Printstyles.js @@ -1,4 +1,15 @@ export const style = ` `; \ No newline at end of file diff --git a/src/Pages/Product/ProductForm.jsx b/src/Pages/Product/ProductForm.jsx index 3bf6ec7..5d2393a 100644 --- a/src/Pages/Product/ProductForm.jsx +++ b/src/Pages/Product/ProductForm.jsx @@ -125,7 +125,7 @@ const ProductForm = ({ formType }) => { UomTypePreference?.some?.( (e) => e?.PreferredSubCatName?.toLowerCase() == - item?.ConfigName?.toLowerCase() && e?.PreferredStatus == 'Y' + item?.ConfigName?.toLowerCase() && e?.PreferredStatus == 'Y' ) ); console.log(UomTypePreference, 'UomTypePreference'); @@ -536,9 +536,15 @@ const ProductForm = ({ formType }) => { }, [imageopen]); useEffect(() => { - productFetchData(); - fetchRackData(); - }, []); + if ( + AppId !== undefined && AppId !== null && + CompId !== undefined && CompId !== null && + BranchId !== undefined && BranchId !== null + ) { + productFetchData(); + fetchRackData(); + } + }, [AppId, CompId, BranchId]); useEffect(() => { if (imageUrl == '') { @@ -683,7 +689,7 @@ const ProductForm = ({ formType }) => { // sree const productFetchData = async () => { const response = await dispatch( - getProductData(AppId, BranchId, CompId) + getProductData({ AppId, BranchId, CompId }) ).unwrap(); setProductData(response?.data?.data); console.log(response, 'responseresponse'); @@ -1119,7 +1125,7 @@ const ProductForm = ({ formType }) => { (item) => parseFloat(item.MRP) === parseFloat(subVariantPriceData?.MRP) && parseFloat(item.SellPrice) === - parseFloat(subVariantPriceData?.SellPrice) && + parseFloat(subVariantPriceData?.SellPrice) && //dhana 18-02-2025 item.ProdVariantName == subVariantPriceData?.ProdVariantName ); @@ -1134,20 +1140,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: null, @@ -1203,20 +1209,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: null, @@ -1282,20 +1288,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: null, @@ -1350,20 +1356,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: null, @@ -1432,17 +1438,17 @@ const ProductForm = ({ formType }) => { (item) => parseFloat(item.MRP) === parseFloat(subVariantPriceData?.MRP) && parseFloat(item.SellPrice) === - parseFloat(subVariantPriceData?.SellPrice) + parseFloat(subVariantPriceData?.SellPrice) ); if ( existsData?.length == 0 || (parseFloat(variantPriceData[variantEditIndex]?.MRP) === parseFloat(subVariantPriceData?.MRP) && parseFloat(variantPriceData[variantEditIndex]?.SellPrice) === - parseFloat(subVariantPriceData?.SellPrice) && + parseFloat(subVariantPriceData?.SellPrice) && //dhana 18-02-2025 variantPriceData[variantEditIndex]?.ProdVariantName == - subVariantPriceData?.ProdVariantName) + subVariantPriceData?.ProdVariantName) ) { let editVariantData = [...variantPriceData]; if ( @@ -1460,20 +1466,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: editVariantData[variantEditIndex]?.InwardDtlId, @@ -1487,20 +1493,20 @@ const ProductForm = ({ formType }) => { SellPrice: subVariantPriceData?.SellPrice, WhSalePrice: subVariantPriceData?.WhSalePrice == undefined || - subVariantPriceData?.WhSalePrice == null || - subVariantPriceData?.WhSalePrice == '' + subVariantPriceData?.WhSalePrice == null || + subVariantPriceData?.WhSalePrice == '' ? 0 : subVariantPriceData?.WhSalePrice, OfferPrice: subVariantPriceData?.OfferPrice == undefined || - subVariantPriceData?.OfferPrice == null || - subVariantPriceData?.OfferPrice == '' + subVariantPriceData?.OfferPrice == null || + subVariantPriceData?.OfferPrice == '' ? 0 : subVariantPriceData?.OfferPrice, SpecialPrice: subVariantPriceData?.SpecialPrice == undefined || - subVariantPriceData?.SpecialPrice == null || - subVariantPriceData?.SpecialPrice == '' + subVariantPriceData?.SpecialPrice == null || + subVariantPriceData?.SpecialPrice == '' ? 0 : subVariantPriceData?.SpecialPrice, InwardDtlId: editVariantData[variantEditIndex]?.InwardDtlId, @@ -1628,20 +1634,20 @@ const ProductForm = ({ formType }) => { SellPrice: row?.SellPrice, WhSalePrice: row?.WhSalePrice == undefined || - row?.WhSalePrice == null || - row?.WhSalePrice == '' + row?.WhSalePrice == null || + row?.WhSalePrice == '' ? 0 : row?.WhSalePrice, OfferPrice: row?.OfferPrice == undefined || - row?.OfferPrice == null || - row?.OfferPrice == '' + row?.OfferPrice == null || + row?.OfferPrice == '' ? 0 : row?.OfferPrice, SpecialPrice: row?.SpecialPrice == undefined || - row?.SpecialPrice == null || - row?.SpecialPrice == '' + row?.SpecialPrice == null || + row?.SpecialPrice == '' ? 0 : row?.SpecialPrice, InwardDtlId: row?.InwardDtlId, @@ -1655,20 +1661,20 @@ const ProductForm = ({ formType }) => { SellPrice: row?.SellPrice, WhSalePrice: row?.WhSalePrice == undefined || - row?.WhSalePrice == null || - row?.WhSalePrice == '' + row?.WhSalePrice == null || + row?.WhSalePrice == '' ? 0 : row?.WhSalePrice, OfferPrice: row?.OfferPrice == undefined || - row?.OfferPrice == null || - row?.OfferPrice == '' + row?.OfferPrice == null || + row?.OfferPrice == '' ? 0 : row?.OfferPrice, SpecialPrice: row?.SpecialPrice == undefined || - row?.SpecialPrice == null || - row?.SpecialPrice == '' + row?.SpecialPrice == null || + row?.SpecialPrice == '' ? 0 : row?.SpecialPrice, InwardDtlId: row?.InwardDtlId, @@ -1805,14 +1811,14 @@ const ProductForm = ({ formType }) => { postData['InwardDate'] = new Date().toJSON(); postData['AutoGenerateQr'] = values?.QRCode === undefined || - values?.QRCode === null || - values?.QRCode === '' + values?.QRCode === null || + values?.QRCode === '' ? QrcodeAuto : 'N'; postData['AutoGenerateSingleQr'] = values?.OnePcQR === undefined || - values?.OnePcQR === null || - values?.OnePcQR === '' + values?.OnePcQR === null || + values?.OnePcQR === '' ? QrcodeAutoSingle : 'N'; postData['CreatedBy'] = UserId; @@ -2216,8 +2222,8 @@ const ProductForm = ({ formType }) => { label={} isOnChange={ editstate?.ProdName || - QrcodeExistsData?.[0]?.ProdName || - voiceData?.product + QrcodeExistsData?.[0]?.ProdName || + voiceData?.product ? true : false } @@ -2253,8 +2259,8 @@ const ProductForm = ({ formType }) => { label={} isOnChange={ editstate?.Size || - QrcodeExistsData?.[0]?.Size || - voiceData?.qty + QrcodeExistsData?.[0]?.Size || + voiceData?.qty ? true : false } @@ -2282,20 +2288,20 @@ const ProductForm = ({ formType }) => { /> } - // inputMode="decimal" - // onInput={(e) => { - // let cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); // Remove invalid characters - // const parts = cleanedValue.split("."); + // inputMode="decimal" + // onInput={(e) => { + // let cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); // Remove invalid characters + // const parts = cleanedValue.split("."); - // if (cleanedValue.startsWith(".")) { - // cleanedValue = "0" + cleanedValue; - // } + // if (cleanedValue.startsWith(".")) { + // cleanedValue = "0" + cleanedValue; + // } - // e.target.value = - // parts.length > 2 - // ? `${parts[0]}.${parts.slice(1).join("")}` - // : cleanedValue; - // }} + // e.target.value = + // parts.length > 2 + // ? `${parts[0]}.${parts.slice(1).join("")}` + // : cleanedValue; + // }} /> { label={} isOnChange={ editstate?.SellPrice || - QrcodeExistsData?.[0]?.SellPrice + QrcodeExistsData?.[0]?.SellPrice ? true : false } @@ -2465,12 +2471,12 @@ const ProductForm = ({ formType }) => { } onChangeFunction={handleProdCatDropDownChange} valueData={SelectedProdCat} - // disabled={ - // editstate?.ProdTypeName == 'Others' || - // formType == 'add' - // ? false - // : true - // } + // disabled={ + // editstate?.ProdTypeName == 'Others' || + // formType == 'add' + // ? false + // : true + // } /> { } onChangeFunction={handleProdSubCatDropDownChange} valueData={SelectedProdSubCat} - // disabled={ - // editstate?.ProdTypeName == 'Others' || - // formType == 'add' - // ? false - // : true - // } + // disabled={ + // editstate?.ProdTypeName == 'Others' || + // formType == 'add' + // ? false + // : true + // } /> {
{imagedata?.map((item, index) => (
setSelectedImage(item)} > @@ -2651,20 +2656,20 @@ const ProductForm = ({ formType }) => { {qrAndTokenDtlsFields?.includes( 'Auto Generate QRCode' ) && ( -
- openQrcodeAuto(e)} - disabled={editstate?.QRCode ? true : false} - /> -
- )} +
+ openQrcodeAuto(e)} + disabled={editstate?.QRCode ? true : false} + /> +
+ )} {(QrcodeAuto == 'N' || editstate?.QRCode) && qrAndTokenDtlsFields?.includes( 'Auto Generate QRCode' @@ -2701,19 +2706,19 @@ const ProductForm = ({ formType }) => { {qrAndTokenDtlsFields?.includes( 'Stock Maintenance' ) && ( -
- openStock(e)} - /> -
- )} +
+ openStock(e)} + /> +
+ )} {StockOpen === 'Y' && qrAndTokenDtlsFields?.includes( 'Stock Maintenance' @@ -2744,35 +2749,35 @@ const ProductForm = ({ formType }) => { {qrAndTokenDtlsFields?.includes( 'Token Maintenance' ) && ( -
- openToken(e)} - /> -
- )} +
+ openToken(e)} + /> +
+ )} {qrAndTokenDtlsFields?.includes( 'Rack Maintenance' ) && ( -
- openRack(e)} - /> -
- )} +
+ openRack(e)} + /> +
+ )} {RackOpen === 'Y' && qrAndTokenDtlsFields?.includes( @@ -2783,15 +2788,15 @@ const ProductForm = ({ formType }) => { options={ formType === 'edit' ? RackData?.map((option) => ({ - value: option.RackId, - label: option.RackName, - })) + value: option.RackId, + label: option.RackName, + })) : RackData?.filter( - (item) => item.ActiveStatus === 'A' - )?.map((option) => ({ - value: option.RackId, - label: option.RackName, - })) + (item) => item.ActiveStatus === 'A' + )?.map((option) => ({ + value: option.RackId, + label: option.RackName, + })) } label={ @@ -2817,21 +2822,21 @@ const ProductForm = ({ formType }) => { {qrAndTokenDtlsFields?.includes( 'Amount Per Piece' ) && ( -
- - openAmountPerPieceAvailable(e) - } - /> -
- )} +
+ + openAmountPerPieceAvailable(e) + } + /> +
+ )} {AmountPerPieceAvailable == 'Y' && qrAndTokenDtlsFields?.includes( @@ -2864,7 +2869,7 @@ const ProductForm = ({ formType }) => { } isOnChange={ editstate?.OnePcsPrice || - editstate?.OnePcsPrice == 0 + editstate?.OnePcsPrice == 0 ? true : false } @@ -2888,38 +2893,38 @@ const ProductForm = ({ formType }) => {
{(QrcodeAutoSingle == 'N' || editstate?.OnePcQR) && ( -
- - { - await validateSafeInput(value); // To block HTML tags & SQL keywords - return Promise.resolve(); +
+ + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, }, - }, - ]} - > - - -
- )} + ]} + > + +
+
+ )} )} @@ -2968,134 +2973,134 @@ const ProductForm = ({ formType }) => { {(priceDtlsFields?.length > 0 || hsnAndMoreDtlsFields?.length > 0 || dateAndTimeDtlsFields?.length > 0) && ( -
- - -
-
- - ({ +
+ + +
+
+ + ({ value: option.ConfigId, label: option.ConfigName, })) - : ProductTypeData.filter( + : ProductTypeData.filter( (item) => item.ConfigName !== 'Others' )?.map((option) => ({ value: option.ConfigId, label: option.ConfigName, })) - } - label={ - - } - className="field-DropDown" - isOnchanges={ - editstate?.ProdType || SelectedProductType - ? true - : false - } - onChangeFunction={ - handleProductTypeDropDownChange - } - valueData={SelectedProductType} - disabled={ - editstate?.ProdTypeName == 'Others' || - formType == 'add' - ? false - : true - } - /> - - - {priceDtlsFields?.includes('Tax') && ( - - ({ - value: option.TaxId, - label: getOptionLabel( - option, - SelectedTaxId === option.TaxId - ), - }))} - label="Tax" + } + label={ + + } className="field-DropDown" isOnchanges={ - editstate?.TaxId || SelectedTaxId + editstate?.ProdType || SelectedProductType ? true : false } - onChangeFunction={handleTaxDropDownChange} - valueData={SelectedTaxId} + onChangeFunction={ + handleProductTypeDropDownChange + } + valueData={SelectedProductType} + disabled={ + editstate?.ProdTypeName == 'Others' || + formType == 'add' + ? false + : true + } /> - - - - )} - {SelectedTaxId && - priceDtlsFields?.includes('Cess') && ( - { - await validateSafeInput(value); - if (!value) { - return Promise.resolve(); // Skip validation if the field is empty - } + {priceDtlsFields?.includes('Tax') && ( + + ({ + value: option.TaxId, + label: getOptionLabel( + option, + SelectedTaxId === option.TaxId + ), + }))} + label="Tax" + className="field-DropDown" + isOnchanges={ + editstate?.TaxId || SelectedTaxId + ? true + : false + } + onChangeFunction={handleTaxDropDownChange} + valueData={SelectedTaxId} + /> + + + + + )} - if ( - !/^\d{1,3}(\.\d{1,2})?$/.test(value) - ) { - return Promise.reject( - 'Cess should be a number with up to 2 decimal places' - ); - } + {SelectedTaxId && + priceDtlsFields?.includes('Cess') && ( + { + await validateSafeInput(value); + if (!value) { + return Promise.resolve(); // Skip validation if the field is empty + } - const cessValue = parseFloat(value); - if (cessValue < 0 || cessValue > 100) { - return Promise.reject( - 'Cess cannot be greater than 100%' - ); - } + if ( + !/^\d{1,3}(\.\d{1,2})?$/.test(value) + ) { + return Promise.reject( + 'Cess should be a number with up to 2 decimal places' + ); + } - return Promise.resolve(); + const cessValue = parseFloat(value); + if (cessValue < 0 || cessValue > 100) { + return Promise.reject( + 'Cess cannot be greater than 100%' + ); + } + + return Promise.resolve(); + }, }, - }, - ]} - > - - - )} - {priceDtlsFields?.includes('Discount Type') && ( -
-
+ + + )} + {priceDtlsFields?.includes('Discount Type') && ( +
+
{ padding: '5px', backgroundColor: '#fff', } - : { opacity: '0.6', boxShadow: 'none' } - } - onClick={() => { - Onchangeoffertype('P'); - }} - > - -

{ + Onchangeoffertype('P'); }} > - Percentage -

-
-
+

+ Percentage +

+
+
{ padding: '5px', backgroundColor: '#fff', } - : { opacity: '0.6', boxShadow: 'none' } - } - onClick={() => { - Onchangeoffertype('F'); - }} - > - -

- Fixed -

-
-
- )} - - {priceDtlsFields?.includes('Discount Limit') && ( -
- - Sales Limit} - autocomplete="off" - onChange={Handleoffervalue} - isOnChange={ - DiscountValue || DiscountValue == 0 - ? true - : false + : { opacity: '0.6', boxShadow: 'none' } } - inputMode="decimal" - onInput={(e) => { - const cleanedValue = - e.target.value.replace(/[^0-9.]/g, ''); - const parts = cleanedValue.split('.'); - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - value={DiscountValue} - /> - -
- )} -
- - {(hsnAndMoreDtlsFields?.length > 0 || - dateAndTimeDtlsFields?.length > 0 || - priceDtlsFields?.includes('Add Variant')) && ( -
- {(hsnAndMoreDtlsFields?.length > 0 || - dateAndTimeDtlsFields?.length > 0) && ( -
- {OpenAdd ? : } - { + Onchangeoffertype('F'); }} > - {OpenAdd - ? 'Hide Additional Details' - : 'Show Additional Details'} - + +

+ Fixed +

+
)} - {priceDtlsFields?.includes('Add Variant') && ( -
- Add Variant + + {priceDtlsFields?.includes('Discount Limit') && ( +
+ + Sales Limit} + autocomplete="off" + onChange={Handleoffervalue} + isOnChange={ + DiscountValue || DiscountValue == 0 + ? true + : false + } + inputMode="decimal" + onInput={(e) => { + const cleanedValue = + e.target.value.replace(/[^0-9.]/g, ''); + const parts = cleanedValue.split('.'); + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + value={DiscountValue} + /> +
)}
- )} -
- - {(hsnAndMoreDtlsFields?.length > 0 || - dateAndTimeDtlsFields?.length > 0) && ( -
- {OpenAdd && ( -
- {hsnAndMoreDtlsFields?.length > 0 && ( -
- 0 || + dateAndTimeDtlsFields?.length > 0 || + priceDtlsFields?.includes('Add Variant')) && ( +
+ {(hsnAndMoreDtlsFields?.length > 0 || + dateAndTimeDtlsFields?.length > 0) && ( +
- -
- {hsnAndMoreDtlsFields?.includes( - 'HSN' - ) && ( - { - await validateSafeInput( - value - ); - return Promise.resolve(); - }, - }, - ]} - > - - HSN Code - - } - id="HSNCode" - value={selectedHsn} - type="text" - list="hsnList" - maxLength={100} - autoComplete="off" - isOnChange={ - editstate?.HSNCode - ? true - : true - } - onChange={(e) => { - const value = - e?.target?.value || ''; - setSelectedHsn(value); - if (value.length >= 1) { - formRef.current?.setFieldsValue( - { - HSNCode: value, - } - ); - handleHsnData(value); - } - }} - suffix={ - selectedHsn?.length >= 1 ? ( - - setSelectedHsn('') - } - /> - ) : ( -
- ) - } - /> - {HsnDetails?.length > 0 && ( - - {HsnDetails.filter( - (item) => { - const search = - selectedHsn?.toLowerCase() || - ''; - return ( - item.HSN_CD?.toLowerCase()?.includes( - search - ) || - item.Description?.toLowerCase()?.includes( - search - ) - ); - } - ).map((item, index) => ( - - )} - - )} - {hsnAndMoreDtlsFields?.includes( - 'Part Number' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - - {hsnAndMoreDtlsFields?.includes( - 'Batch Number' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - {hsnAndMoreDtlsFields?.includes( - 'Model Number' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - {hsnAndMoreDtlsFields?.includes( - 'IMEI 1' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - {hsnAndMoreDtlsFields?.includes( - 'IMEI 2' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - {hsnAndMoreDtlsFields?.includes( - 'Serial Number' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} - {hsnAndMoreDtlsFields?.includes( - 'MacId' - ) && ( - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - - )} -
- - + {OpenAdd ? : } + + {OpenAdd + ? 'Hide Additional Details' + : 'Show Additional Details'} + +
+ )} + {priceDtlsFields?.includes('Add Variant') && ( +
+ Add Variant
)} -
- {dateAndTimeDtlsFields?.length > 0 && ( -
- - -
- {dateAndTimeDtlsFields?.includes( - 'Manufacture Date' - ) && ( - - -
-
- -
- )} - {/* {(dateAndTimeDtlsFields?.includes('Expiry Notification Days') && */} +
+ )} - { - await validateSafeInput( - value - ); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - Warranty Days - } - isOnChange={true} - /> - - {/* } */} - {dateAndTimeDtlsFields?.includes( - 'Expire Date' - ) && ( - - -
-
- -
- )} +
+ + {(hsnAndMoreDtlsFields?.length > 0 || + dateAndTimeDtlsFields?.length > 0) && ( +
+ {OpenAdd && ( +
+ {hsnAndMoreDtlsFields?.length > 0 && ( +
+ + +
+ {hsnAndMoreDtlsFields?.includes( + 'HSN' + ) && ( + { + await validateSafeInput( + value + ); + return Promise.resolve(); + }, + }, + ]} + > + + HSN Code + + } + id="HSNCode" + value={selectedHsn} + type="text" + list="hsnList" + maxLength={100} + autoComplete="off" + isOnChange={ + editstate?.HSNCode + ? true + : true + } + onChange={(e) => { + const value = + e?.target?.value || ''; + setSelectedHsn(value); + if (value.length >= 1) { + formRef.current?.setFieldsValue( + { + HSNCode: value, + } + ); + handleHsnData(value); + } + }} + suffix={ + selectedHsn?.length >= 1 ? ( + + setSelectedHsn('') + } + /> + ) : ( +
+ ) + } + /> + {HsnDetails?.length > 0 && ( + + {HsnDetails.filter( + (item) => { + const search = + selectedHsn?.toLowerCase() || + ''; + return ( + item.HSN_CD?.toLowerCase()?.includes( + search + ) || + item.Description?.toLowerCase()?.includes( + search + ) + ); + } + ).map((item, index) => ( + + )} + + )} + {hsnAndMoreDtlsFields?.includes( + 'Part Number' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + + {hsnAndMoreDtlsFields?.includes( + 'Batch Number' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + {hsnAndMoreDtlsFields?.includes( + 'Model Number' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + {hsnAndMoreDtlsFields?.includes( + 'IMEI 1' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + {hsnAndMoreDtlsFields?.includes( + 'IMEI 2' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + {hsnAndMoreDtlsFields?.includes( + 'Serial Number' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} + {hsnAndMoreDtlsFields?.includes( + 'MacId' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} +
+ + +
+ )} +
+ {dateAndTimeDtlsFields?.length > 0 && ( +
+ + +
+ {dateAndTimeDtlsFields?.includes( + 'Manufacture Date' + ) && ( + + +
+
+ +
+ )} + {/* {(dateAndTimeDtlsFields?.includes('Expiry Notification Days') && */} - {dateAndTimeDtlsFields?.includes( - 'Expiry Notification Days' - ) && - dateAndTimeDtlsFields?.includes( - 'Expire Date' - ) && ( { - Expiry Notification Days - + } isOnChange={true} /> - )} + {/* } */} + {dateAndTimeDtlsFields?.includes( + 'Expire Date' + ) && ( + + +
+
+ +
+ )} - {dateAndTimeDtlsFields?.includes( - 'Available From' - ) && ( - - -
-
- -
- )} - {dateAndTimeDtlsFields?.includes( - 'Available To' - ) && ( - - -
-
- -
- )} -
-
-
+ {dateAndTimeDtlsFields?.includes( + 'Expiry Notification Days' + ) && + dateAndTimeDtlsFields?.includes( + 'Expire Date' + ) && ( + { + await validateSafeInput( + value + ); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + Expiry Notification Days + + } + isOnChange={true} + /> + + )} + + {dateAndTimeDtlsFields?.includes( + 'Available From' + ) && ( + + +
+
+ +
+ )} + {dateAndTimeDtlsFields?.includes( + 'Available To' + ) && ( + + +
+
+ +
+ )} +
+
+
+
+ )} +
)} -
)} -
- )} -
- {openVariant && ( -
-
-
- - - Variant Name - - } - isOnChange={true} - disabled={ - formType == 'edit' && - variantPriceData[variantEditIndex]?.[ - 'ProdVariantName' - ] && - variantPriceData[variantEditIndex] - ?.InwardDtlId != null && - variantEdit - ? true - : false - } - /> - - { - await validateSafeInput(value); - if (parseFloat(value) === 0) { - return Promise.reject( - 'Please enter valid MRP' - ); - } - - if (value && value?.length > 10) { - return Promise.reject( - 'MRP should not exceed 10 chars' - ); - } - - return Promise.resolve(); - }, - }, - ]} - > - MRP - } - isOnChange={variantEdit ? true : false} - onChange={handleDynamicMRP} - onInput={(e) => { - let cleanedValue = - e.target.value.replace( - /[^0-9.]/g, - '' - ); // Remove invalid characters - const parts = cleanedValue.split('.'); - - if (cleanedValue.startsWith('.')) { - cleanedValue = '0' + cleanedValue; - } - - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> - - - - Sales Price - - } - isOnChange={variantEdit ? true : false} - onInput={(e) => { - let cleanedValue = - e.target.value.replace( - /[^0-9.]/g, - '' - ); // Remove invalid characters - const parts = cleanedValue.split('.'); - - if (cleanedValue.startsWith('.')) { - cleanedValue = '0' + cleanedValue; - } - - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> - - { - await validateSafeInput(value); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - WholeSale} - isOnChange={variantEdit ? true : false} - /> - - { - await validateSafeInput(value); - if (value?.length > 10) { - return Promise.reject( - 'Offer cannot exceed 10 chars' - ); - } - return Promise.resolve(); - }, - }, - ]} - > - Offer} - isOnChange={variantEdit ? true : false} - /> - - { - await validateSafeInput(value); - if (value?.length > 10) { - return Promise.reject( - 'Special Price cannot exceed 10 chars' - ); - } - return Promise.resolve(); - }, - }, - ]} - > - Special Price} - isOnChange={variantEdit ? true : false} - /> - - {AmountPerPieceAvailable == 'Y' && ( +
+ {openVariant && ( + +
+
+ + Variant Name + + } + isOnChange={true} + disabled={ + formType == 'edit' && + variantPriceData[variantEditIndex]?.[ + 'ProdVariantName' + ] && + variantPriceData[variantEditIndex] + ?.InwardDtlId != null && + variantEdit + ? true + : false + } + /> + + { + await validateSafeInput(value); + if (parseFloat(value) === 0) { + return Promise.reject( + 'Please enter valid MRP' + ); + } + + if (value && value?.length > 10) { + return Promise.reject( + 'MRP should not exceed 10 chars' + ); + } + + return Promise.resolve(); + }, + }, + ]} + > + MRP + } + isOnChange={variantEdit ? true : false} + onChange={handleDynamicMRP} + onInput={(e) => { + let cleanedValue = + e.target.value.replace( + /[^0-9.]/g, + '' + ); // Remove invalid characters + const parts = cleanedValue.split('.'); + + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; + } + + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + /> + + + + Sales Price + + } + isOnChange={variantEdit ? true : false} + onInput={(e) => { + let cleanedValue = + e.target.value.replace( + /[^0-9.]/g, + '' + ); // Remove invalid characters + const parts = cleanedValue.split('.'); + + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; + } + + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + /> + + { @@ -3979,56 +3909,131 @@ const ProductForm = ({ formType }) => { > WholeSale} + isOnChange={variantEdit ? true : false} /> - )} + { + await validateSafeInput(value); + if (value?.length > 10) { + return Promise.reject( + 'Offer cannot exceed 10 chars' + ); + } + return Promise.resolve(); + }, + }, + ]} + > + Offer} + isOnChange={variantEdit ? true : false} + /> + + { + await validateSafeInput(value); + if (value?.length > 10) { + return Promise.reject( + 'Special Price cannot exceed 10 chars' + ); + } + return Promise.resolve(); + }, + }, + ]} + > + Special Price} + isOnChange={variantEdit ? true : false} + /> + + {AmountPerPieceAvailable == 'Y' && ( + { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + + )} -
{ - try { - await formVariantRef.current?.validateFields(); - if (!variantEdit) { - addVariantPriceData(); - } else { - editVariantPrice(); +
{ + try { + await formVariantRef.current?.validateFields(); + if (!variantEdit) { + addVariantPriceData(); + } else { + editVariantPrice(); + } + } catch (err) { + setMessageType('error'); + setMessageData( + 'Please fix the validation errors before submitting.' + ); } - } catch (err) { - setMessageType('error'); - setMessageData( - 'Please fix the validation errors before submitting.' - ); - } - }} - > - {!variantEdit ? 'Add' : 'Update'} + }} + > + {!variantEdit ? 'Add' : 'Update'} +
-
- + + )} +
+
+ + {variantPriceData?.length > 0 && ( +
+ {' '} +
)}
-
- - {variantPriceData?.length > 0 && ( -
- {' '} -
- )} -
- - -
- )} +
+ +
+ )}
{ // rowClassName="editable-row" columns={Columns} dataSource={Tabledata} - // pagination={handlePageChange} - // onChange={handleChange} + // pagination={handlePageChange} + // onChange={handleChange} />