Added prices change short cut funtionalies
This commit is contained in:
parent
f13eb99a92
commit
9ae30c81b9
|
|
@ -38,6 +38,10 @@ const BSEditTotalAmt = (props) => {
|
|||
console.log(OverAllSales, 'OverAllEstimateOverAllEstimate');
|
||||
const formRef = useRef(null);
|
||||
const formEstRef = useRef(null);
|
||||
const salesDiscInputRef = useRef(null);
|
||||
const salesMoreOptInputRef = useRef(null);
|
||||
const estDiscInputRef = useRef(null);
|
||||
const estMoreOptInputRef = useRef(null);
|
||||
const dispatch = useDispatch();
|
||||
const [messageType, setMessageType] = useState(null);
|
||||
const [messageData, setMessageData] = useState(null);
|
||||
|
|
@ -87,6 +91,29 @@ const BSEditTotalAmt = (props) => {
|
|||
return () => clearInterval(timer);
|
||||
}, [timeLeft]);
|
||||
|
||||
useEffect(() => {
|
||||
const focusInput = (ref) => {
|
||||
setTimeout(() => {
|
||||
const inputElement = ref.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
if (SalesData?.length > 0) {
|
||||
if (MoreOpt) {
|
||||
focusInput(salesMoreOptInputRef);
|
||||
} else if (EditTotalAmt) {
|
||||
focusInput(salesDiscInputRef);
|
||||
}
|
||||
} else if (EstimateData?.length > 0 && EditTotalAmt) {
|
||||
if (ESTMoreOpt) {
|
||||
focusInput(estMoreOptInputRef);
|
||||
} else {
|
||||
focusInput(estDiscInputRef);
|
||||
}
|
||||
}
|
||||
}, [EditTotalAmt, MoreOpt, ESTMoreOpt, SalesData, EstimateData]);
|
||||
|
||||
const handleOtpChange = (index, value) => {
|
||||
// Allow empty value for clearing
|
||||
if (value === '' || value.match(/^[0-9]$/)) {
|
||||
|
|
@ -201,6 +228,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setMessageData('Please Give less than value for sell price');
|
||||
setESTSellingPrice(0);
|
||||
formEstRef?.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = estDiscInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
} else {
|
||||
setESTSellingPrice(inputValue);
|
||||
// Check if entered amount is 0 or equals total amount
|
||||
|
|
@ -214,6 +245,13 @@ const BSEditTotalAmt = (props) => {
|
|||
handleOk();
|
||||
}
|
||||
};
|
||||
|
||||
const handleEstKeyDown = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
SetTotalDiscount();
|
||||
}
|
||||
};
|
||||
const SalesChangefun = (e) => {
|
||||
const inputValue = e.target.value.trim();
|
||||
console.log(e, e.target.value, 'SalesChangefun');
|
||||
|
|
@ -223,6 +261,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setMessageData('Please Give less than value for sell price');
|
||||
setSellingPrice(0);
|
||||
formRef?.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = salesDiscInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
} else {
|
||||
setSellingPrice(inputValue);
|
||||
// SalesTotalAmount()
|
||||
|
|
@ -232,6 +274,13 @@ const BSEditTotalAmt = (props) => {
|
|||
// setSalesDiscAmount(0)
|
||||
}
|
||||
};
|
||||
|
||||
const handleSalesKeyDown = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
SetTotalDiscount();
|
||||
}
|
||||
};
|
||||
const orderscolumns = [
|
||||
{
|
||||
title: 'Sl.No',
|
||||
|
|
@ -347,6 +396,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setSalesDiscAmount(0);
|
||||
// setFinalTotalAmt()
|
||||
formRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = salesMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
};
|
||||
const onEstPercentageSelectionChange = (data) => {
|
||||
setESTPercentageSelection(data);
|
||||
|
|
@ -354,6 +407,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setEstDiscAmount(0);
|
||||
// setFinalTotalAmt()
|
||||
formEstRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = estMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const PriceChangefun = (data) => {
|
||||
|
|
@ -375,6 +432,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setSalesDiscAmount(0);
|
||||
// setNewPrice1(0)
|
||||
formRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = salesMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
// Percentage mode
|
||||
|
|
@ -391,6 +452,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setMessageData('Please Give less than or equal to 100');
|
||||
setSalesDiscAmount(0);
|
||||
formRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = salesMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -400,6 +465,13 @@ const BSEditTotalAmt = (props) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handlePriceKeyDown = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
SetTotalDiscount();
|
||||
}
|
||||
};
|
||||
|
||||
const PriceChangefunEst = (data) => {
|
||||
console.log(data?.target.value, PercentageSelection, 'datadata');
|
||||
if (data?.target.value) {
|
||||
|
|
@ -418,6 +490,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setMessageData('Please Give less than value for sell price');
|
||||
setEstDiscAmount(0);
|
||||
formEstRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = estMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
// Percentage mode
|
||||
|
|
@ -434,6 +510,10 @@ const BSEditTotalAmt = (props) => {
|
|||
setMessageData('Please Give less than or equal to 100');
|
||||
setEstDiscAmount(0);
|
||||
formEstRef.current?.resetFields();
|
||||
setTimeout(() => {
|
||||
const inputElement = estMoreOptInputRef.current?.querySelector('input');
|
||||
inputElement?.focus();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -444,6 +524,13 @@ const BSEditTotalAmt = (props) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handlePriceEstKeyDown = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
SetTotalDiscount();
|
||||
}
|
||||
};
|
||||
|
||||
const moreOptions = () => {
|
||||
setMoreOpt((prev) => !prev);
|
||||
setSalesDiscAmount(0);
|
||||
|
|
@ -535,15 +622,18 @@ const BSEditTotalAmt = (props) => {
|
|||
},
|
||||
]}
|
||||
>
|
||||
<InputField
|
||||
field="SalesDisc"
|
||||
name="SalesDisc"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
autocomplete="off"
|
||||
onChange={(e) => SalesChangefun(e)}
|
||||
maxLength={8}
|
||||
/>
|
||||
<div ref={salesDiscInputRef}>
|
||||
<InputField
|
||||
field="SalesDisc"
|
||||
name="SalesDisc"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
autocomplete="off"
|
||||
onChange={(e) => SalesChangefun(e)}
|
||||
onKeyDown={(e) => handleSalesKeyDown(e)}
|
||||
maxLength={8}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</Form>{' '}
|
||||
</td>
|
||||
|
|
@ -593,18 +683,21 @@ const BSEditTotalAmt = (props) => {
|
|||
},
|
||||
]}
|
||||
>
|
||||
<InputField
|
||||
field="SellPrice"
|
||||
name="SellPrice"
|
||||
// value={NewPrice1}
|
||||
label="Reduction"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => PriceChangefun(e)}
|
||||
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
|
||||
/>
|
||||
<div ref={salesMoreOptInputRef}>
|
||||
<InputField
|
||||
field="SellPrice"
|
||||
name="SellPrice"
|
||||
// value={NewPrice1}
|
||||
label="Reduction"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => PriceChangefun(e)}
|
||||
onKeyDown={(e) => handlePriceKeyDown(e)}
|
||||
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
{/* <input type="text"
|
||||
onChange={(e)=>PriceChangefun(e)}
|
||||
|
|
@ -684,16 +777,19 @@ const BSEditTotalAmt = (props) => {
|
|||
},
|
||||
]}
|
||||
>
|
||||
<InputField
|
||||
field="ESTSalesDisc"
|
||||
name="ESTSalesDisc"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => EstChangefun(e)}
|
||||
maxLength={8}
|
||||
/>
|
||||
<div ref={estDiscInputRef}>
|
||||
<InputField
|
||||
field="ESTSalesDisc"
|
||||
name="ESTSalesDisc"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => EstChangefun(e)}
|
||||
onKeyDown={(e) => handleEstKeyDown(e)}
|
||||
maxLength={8}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</td>
|
||||
|
|
@ -742,18 +838,21 @@ const BSEditTotalAmt = (props) => {
|
|||
},
|
||||
]}
|
||||
>
|
||||
<InputField
|
||||
field="SellPrice"
|
||||
name="ESTSellingPrice"
|
||||
// value={NewPrice1}
|
||||
label="Reduction"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => PriceChangefunEst(e)}
|
||||
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
|
||||
/>
|
||||
<div ref={estMoreOptInputRef}>
|
||||
<InputField
|
||||
field="SellPrice"
|
||||
name="ESTSellingPrice"
|
||||
// value={NewPrice1}
|
||||
label="Reduction"
|
||||
fieldState={true}
|
||||
fieldApi={true}
|
||||
// id="error2"
|
||||
autocomplete="off"
|
||||
onChange={(e) => PriceChangefunEst(e)}
|
||||
onKeyDown={(e) => handlePriceEstKeyDown(e)}
|
||||
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
{/* <input type="text"
|
||||
onChange={(e)=>PriceChangefun(e)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue