Merge pull request 'qty-shortcut-key' (#108) from qty-shortcut-key into main

Reviewed-on: Pozomind/pozo-retail-app#108
This commit is contained in:
karthikalakshmi 2026-02-09 14:33:43 +05:30
commit fa70173fc1
12 changed files with 405 additions and 235 deletions

View File

@ -274,10 +274,33 @@ const BSBillingTable1 = () => {
setshortKeyMethod(method);
};
const handleKeyDown = (event) => {
if (!event.ctrlKey) return;
// const handleKeyDown = (event) => {
// if (!event.ctrlKey) return;
// const key = event.key.toLowerCase();
// if (key === 'q') {
// event.preventDefault();
// handleShortcut('qty');
// }
// if (key === 'e') {
// event.preventDefault();
// handleShortcut('price');
// }
// };
const handleKeyDown = (event) => {
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();

View File

@ -228,11 +228,18 @@ const BSBillingTable3 = () => {
handleEditQuantity(item);
setshortKeyMethod(method);
};
const handleKeyDown = (event) => {
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();

View File

@ -282,10 +282,17 @@ const BSBillingTable4 = () => {
};
const handleKeyDown = (event) => {
if (!preferenceshortcutkey) return;
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();

View File

@ -1928,10 +1928,17 @@ const BsBill = () => {
};
const handleKeyDown = (event) => {
if (!preferenceshortcutkey) return;
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (TableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();

View File

@ -256,11 +256,17 @@ const BSBillingTable6 = () => {
};
const handleKeyDown = (event) => {
if (!preferenceshortcutkey) return
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();
@ -272,7 +278,6 @@ const BSBillingTable6 = () => {
handleShortcut('price');
}
};
window.addEventListener('keydown', handleKeyDown);
return () => {

View File

@ -225,35 +225,6 @@ const BSBillingTable7 = () => {
setPreviousdataLength(PreviousOrderLength);
}, [PreviousOrderLength]);
// useEffect(() => {
// const handleKeyDown = (event) => {
// // Ctrl + Q
// if (event.ctrlKey && event.key.toLowerCase() === 'q') {
// event.preventDefault();
// const getItem = (data = []) => {
// if (!data.length) return null;
// return BillOrderPre === 'Y' ? data[0] : data[data.length - 1];
// };
// let item = null;
// if (tableDataTakeAway?.length > 0) {
// item = getItem(tableDataTakeAway);
// } else if (tableDataDinein?.length > 0) {
// item = getItem(tableDataDinein);
// }
// if (item) {
// handleEditQuantity(item);
// }
// }
// };
// window.addEventListener('keydown', handleKeyDown);
// return () => {
// window.removeEventListener('keydown', handleKeyDown);
// };
// }, [tableDataTakeAway, tableDataDinein, BillOrderPre]);
useEffect(() => {
if (!preferenceshortcutkey) return;
const getSelectedItem = () => {
@ -279,16 +250,20 @@ const BSBillingTable7 = () => {
};
const handleKeyDown = (event) => {
if (!preferenceshortcutkey) return;
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();
handleShortcut('qty');
}
if (key === 'e') {
event.preventDefault();
handleShortcut('price');

View File

@ -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,6 +622,7 @@ const BSEditTotalAmt = (props) => {
},
]}
>
<div ref={salesDiscInputRef}>
<InputField
field="SalesDisc"
name="SalesDisc"
@ -542,8 +630,10 @@ const BSEditTotalAmt = (props) => {
fieldApi={true}
autocomplete="off"
onChange={(e) => SalesChangefun(e)}
onKeyDown={(e) => handleSalesKeyDown(e)}
maxLength={8}
/>
</div>
</Form.Item>
</Form>{' '}
</td>
@ -593,6 +683,7 @@ const BSEditTotalAmt = (props) => {
},
]}
>
<div ref={salesMoreOptInputRef}>
<InputField
field="SellPrice"
name="SellPrice"
@ -603,8 +694,10 @@ const BSEditTotalAmt = (props) => {
// 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,6 +777,7 @@ const BSEditTotalAmt = (props) => {
},
]}
>
<div ref={estDiscInputRef}>
<InputField
field="ESTSalesDisc"
name="ESTSalesDisc"
@ -692,8 +786,10 @@ const BSEditTotalAmt = (props) => {
// id="error2"
autocomplete="off"
onChange={(e) => EstChangefun(e)}
onKeyDown={(e) => handleEstKeyDown(e)}
maxLength={8}
/>
</div>
</Form.Item>
</Form>
</td>
@ -742,6 +838,7 @@ const BSEditTotalAmt = (props) => {
},
]}
>
<div ref={estMoreOptInputRef}>
<InputField
field="SellPrice"
name="ESTSellingPrice"
@ -752,8 +849,10 @@ const BSEditTotalAmt = (props) => {
// 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)}

View File

@ -249,27 +249,54 @@ const ComboSalesBillTable = () => {
// );
// setBillOrderPre(BillOrder?.SettingValue);
// }, [preferenceDatas]);
useEffect(() => {
const handleKeyDown = (event) => {
if (event.ctrlKey && event.key.toLowerCase() === 'q') {
event.preventDefault();
const getSelectedItem = () => {
const getItem = (data = []) => {
if (!data.length) return null;
return BillOrderPre === 'Y' ? data[0] : data[data.length - 1];
};
let item = null;
if (tableDataTakeAway?.length > 0) {
item = getItem(tableDataTakeAway);
return getItem(tableDataTakeAway);
} else if (tableDataDinein?.length > 0) {
item = getItem(tableDataDinein);
return getItem(tableDataDinein);
}
if (item) {
return null;
};
const handleShortcut = (method) => {
const item = getSelectedItem();
if (!item) return;
handleEditQuantity(item);
setshortKeyMethod(method);
};
const handleKeyDown = (event) => {
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (tableData?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();
handleShortcut('qty');
}
if (key === 'e') {
event.preventDefault();
handleShortcut('price');
}
};
window.addEventListener('keydown', handleKeyDown);
return () => {
window.removeEventListener('keydown', handleKeyDown);
};

View File

@ -262,11 +262,18 @@ const StandardTable = () => {
handleEditQuantity(item);
setshortKeyMethod(method);
};
const handleKeyDown = (event) => {
if (!event.ctrlKey) return;
const key = event.key.toLowerCase();
// 👉 ALT + P Open Edit Total Amount
if (event.altKey && key === 'p') {
event.preventDefault();
if (OrderCardDetail?.length > 0) {
OpenEditTotalAmount();
}
return;
}
// 👉 CTRL shortcuts
if (!event.ctrlKey) return;
if (key === 'q') {
event.preventDefault();

View File

@ -15,6 +15,7 @@ const ShortcutKeyHelper = ({ }) => {
{ key: 'F4', description: 'Quick Pay' },
{ key: 'Alt + W', description: 'Hold and Recall' },
{ key: 'Ctrl + Q', description: 'Qty Change' },
{ key: 'Alt + P', description: 'Change Total Amount' },
{ key: 'Ctrl + E', description: 'Price Change' },
{ key: 'Ctrl + I', description: 'Customer Rate History' },
];

View File

@ -543,10 +543,10 @@ export default function BSCombo1() {
</div>
)}
</div>
{preferenceshortcutkey && (
{/* {preferenceshortcutkey && (
<div className="keyboardShortcut">
<ShortcutKeyHelper />
</div>)}
</div>)} */}
</div>
</div>
{/* </div> */}

View File

@ -85,6 +85,13 @@ const SalesCountComponent = React.memo(
type?.PreferredSubCatName?.toLowerCase() === 'take away' &&
type?.PreferredStatus === 'Y'
);
const preferenceshortcutkey = preferencedata?.[0]?.[
'SettingDtlDetails'
]?.some(
(item) =>
item.SettingIdName.toLowerCase() === 'shortcutkeys' &&
item.SettingValue === 'Y'
);
const [messageType, setMessageType] = useState(null);
@ -1085,6 +1092,11 @@ const SalesCountComponent = React.memo(
)}
</Tooltip>
</div>
{/* {preferenceshortcutkey && <ShortcutKeyHelper />} */}
{preferenceshortcutkey && (
<div className="keyboardShortcut">
<ShortcutKeyHelper />
</div>)}
<AllSalesPageSettings />
<ProductPriceChange />
<ReceivedStocksModal