Added prices change short cut funtionalies
This commit is contained in:
parent
ef0245d862
commit
231b6ba523
|
|
@ -148,13 +148,13 @@ const ComboSalesBillTable = () => {
|
|||
OrderType === 'Hold'
|
||||
? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway')
|
||||
: tableData?.filter(
|
||||
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
|
||||
);
|
||||
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
|
||||
);
|
||||
const OldtableDataTakeAway =
|
||||
OrderType != 'Hold'
|
||||
? tableData?.filter(
|
||||
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
|
||||
)
|
||||
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
|
||||
)
|
||||
: [];
|
||||
|
||||
const [EditQuantity, setEditQuantity] = useState(false);
|
||||
|
|
@ -249,27 +249,54 @@ const ComboSalesBillTable = () => {
|
|||
// );
|
||||
// setBillOrderPre(BillOrder?.SettingValue);
|
||||
// }, [preferenceDatas]);
|
||||
|
||||
useEffect(() => {
|
||||
const getSelectedItem = () => {
|
||||
const getItem = (data = []) => {
|
||||
if (!data.length) return null;
|
||||
return BillOrderPre === 'Y' ? data[0] : data[data.length - 1];
|
||||
};
|
||||
|
||||
if (tableDataTakeAway?.length > 0) {
|
||||
return getItem(tableDataTakeAway);
|
||||
} else if (tableDataDinein?.length > 0) {
|
||||
return getItem(tableDataDinein);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleShortcut = (method) => {
|
||||
const item = getSelectedItem();
|
||||
if (!item) return;
|
||||
|
||||
handleEditQuantity(item);
|
||||
setshortKeyMethod(method);
|
||||
};
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.ctrlKey && event.key.toLowerCase() === 'q') {
|
||||
const key = event.key.toLowerCase();
|
||||
// 👉 ALT + P → Open Edit Total Amount
|
||||
if (event.altKey && key === 'p') {
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
|
@ -1122,9 +1149,9 @@ const ComboSalesBillTable = () => {
|
|||
)?.map((item, idx) =>
|
||||
idx === 0
|
||||
? {
|
||||
...item,
|
||||
FreeQty,
|
||||
}
|
||||
...item,
|
||||
FreeQty,
|
||||
}
|
||||
: item
|
||||
),
|
||||
};
|
||||
|
|
@ -2246,20 +2273,20 @@ const ComboSalesBillTable = () => {
|
|||
tableDataDinein?.length >= PreviousdataLength
|
||||
? 'wheat'
|
||||
: BookingType !== 'Dine In' &&
|
||||
triggerAnimation &&
|
||||
OldtableDataTakeAway?.length + index === 0 &&
|
||||
tableDataDinein?.length >= PreviousdataLength &&
|
||||
!HoldOrderDtl &&
|
||||
!UnpaidData
|
||||
triggerAnimation &&
|
||||
OldtableDataTakeAway?.length + index === 0 &&
|
||||
tableDataDinein?.length >= PreviousdataLength &&
|
||||
!HoldOrderDtl &&
|
||||
!UnpaidData
|
||||
? 'wheat'
|
||||
: 'inherit'
|
||||
: 'none',
|
||||
background: row?.SalesId
|
||||
? 'rgb(243, 248, 213)'
|
||||
: GlobEstBooking === 'ParEst' &&
|
||||
GlobProdwisedata?.includes(
|
||||
row?.InwardDtlId + ' ' + row?.BookingTypeName
|
||||
)
|
||||
GlobProdwisedata?.includes(
|
||||
row?.InwardDtlId + ' ' + row?.BookingTypeName
|
||||
)
|
||||
? '#b2d1f7'
|
||||
: (OldtableDataTakeAway?.length + index) % 2 === 0
|
||||
? 'white'
|
||||
|
|
@ -2294,37 +2321,37 @@ const ComboSalesBillTable = () => {
|
|||
{/* Product Name / Item */}
|
||||
{(item.OptionName === 'Item' ||
|
||||
item.OptionName === 'Product Name') && (
|
||||
<td
|
||||
key={`prod-${index}`}
|
||||
className="productNameTd"
|
||||
onClick={() =>
|
||||
row.FullProductIdentifierDtls?.length > 0 ||
|
||||
row.ProductIdentifierDtls?.length > 0
|
||||
? handleImeiDetails(row)
|
||||
: editField && handleEditQuantity(row)
|
||||
}
|
||||
>
|
||||
{row?.Type !== 'OS' ? row.ProdName : row.ServiceName}
|
||||
{row?.BrandName ? ` ${row.BrandName}` : ''}
|
||||
{row?.Type !== 'C' && (
|
||||
<p className="Tbl3-Variant">
|
||||
{/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */}
|
||||
(
|
||||
{!row?.ProdVariantName?.toLowerCase()?.includes(
|
||||
'variant'
|
||||
) && <span>{row?.ProdVariantName} </span>}
|
||||
{row?.Size}
|
||||
{row?.SinglePc == 'Y' ? 'PCS' : row?.UomName})
|
||||
</p>
|
||||
)}
|
||||
{row?.Type === 'C' &&
|
||||
row.ProdDetail?.map((prod, idx) => (
|
||||
<p key={idx}>
|
||||
{prod.ProdName} - {prod.Size} {prod.UomName}
|
||||
<td
|
||||
key={`prod-${index}`}
|
||||
className="productNameTd"
|
||||
onClick={() =>
|
||||
row.FullProductIdentifierDtls?.length > 0 ||
|
||||
row.ProductIdentifierDtls?.length > 0
|
||||
? handleImeiDetails(row)
|
||||
: editField && handleEditQuantity(row)
|
||||
}
|
||||
>
|
||||
{row?.Type !== 'OS' ? row.ProdName : row.ServiceName}
|
||||
{row?.BrandName ? ` ${row.BrandName}` : ''}
|
||||
{row?.Type !== 'C' && (
|
||||
<p className="Tbl3-Variant">
|
||||
{/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */}
|
||||
(
|
||||
{!row?.ProdVariantName?.toLowerCase()?.includes(
|
||||
'variant'
|
||||
) && <span>{row?.ProdVariantName} </span>}
|
||||
{row?.Size}
|
||||
{row?.SinglePc == 'Y' ? 'PCS' : row?.UomName})
|
||||
</p>
|
||||
))}
|
||||
</td>
|
||||
)}
|
||||
)}
|
||||
{row?.Type === 'C' &&
|
||||
row.ProdDetail?.map((prod, idx) => (
|
||||
<p key={idx}>
|
||||
{prod.ProdName} - {prod.Size} {prod.UomName}
|
||||
</p>
|
||||
))}
|
||||
</td>
|
||||
)}
|
||||
|
||||
{/* Barcode */}
|
||||
{item.OptionName === 'Barcode' && (
|
||||
|
|
@ -2351,7 +2378,7 @@ const ComboSalesBillTable = () => {
|
|||
onClick={() =>
|
||||
editField && handleEditQuantityCombo(row)
|
||||
}
|
||||
// onClick={() => handleEditQTYcombo()}
|
||||
// onClick={() => handleEditQTYcombo()}
|
||||
>
|
||||
{(!EditQtyCombo || row?.localId !== Index) && (
|
||||
<>{row.OrderQty}</>
|
||||
|
|
@ -2367,7 +2394,7 @@ const ComboSalesBillTable = () => {
|
|||
Index={Index}
|
||||
setIndex={setIndex}
|
||||
setEditQtyCombo={setEditQtyCombo}
|
||||
// id={`qty-${index}`}
|
||||
// id={`qty-${index}`}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
|
|
@ -2414,9 +2441,9 @@ const ComboSalesBillTable = () => {
|
|||
>
|
||||
{row?.Offer > 0
|
||||
? `${(
|
||||
(row.Offer / (row?.OrderQty * row?.OrderRate)) *
|
||||
100
|
||||
).toFixed(2)}%`
|
||||
(row.Offer / (row?.OrderQty * row?.OrderRate)) *
|
||||
100
|
||||
).toFixed(2)}%`
|
||||
: '-'}
|
||||
</td>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue