From 9ae30c81b99bc0b0e907ba2995e58d0cc35ceb66 Mon Sep 17 00:00:00 2001 From: Srinath Date: Mon, 9 Feb 2026 14:12:59 +0530 Subject: [PATCH] Added prices change short cut funtionalies --- .../BSEditTotalAmount/BSEditTotalAmt.jsx | 185 ++++++++++++++---- 1 file changed, 142 insertions(+), 43 deletions(-) diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx index 049f2e9..431dab8 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx @@ -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) => { }, ]} > - SalesChangefun(e)} - maxLength={8} - /> +
+ SalesChangefun(e)} + onKeyDown={(e) => handleSalesKeyDown(e)} + maxLength={8} + /> +
{' '} @@ -593,18 +683,21 @@ const BSEditTotalAmt = (props) => { }, ]} > - PriceChangefun(e)} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} - /> +
+ PriceChangefun(e)} + onKeyDown={(e) => handlePriceKeyDown(e)} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + /> +
{/* PriceChangefun(e)} @@ -684,16 +777,19 @@ const BSEditTotalAmt = (props) => { }, ]} > - EstChangefun(e)} - maxLength={8} - /> +
+ EstChangefun(e)} + onKeyDown={(e) => handleEstKeyDown(e)} + maxLength={8} + /> +
@@ -742,18 +838,21 @@ const BSEditTotalAmt = (props) => { }, ]} > - PriceChangefunEst(e)} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} - /> +
+ PriceChangefunEst(e)} + onKeyDown={(e) => handlePriceEstKeyDown(e)} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + /> +
{/* PriceChangefun(e)}