fixes
- clean coupon on success order - in menu on clicking on the sticky categories make scroll jump to the category title postion exactly
This commit is contained in:
@@ -42,12 +42,22 @@ export function ScrollHandlerProvider({ children }: { children: ReactNode }) {
|
|||||||
const scrollToCategory = useCallback((categoryId: number) => {
|
const scrollToCategory = useCallback((categoryId: number) => {
|
||||||
const categoryRef = categoryRefs.current?.[categoryId];
|
const categoryRef = categoryRefs.current?.[categoryId];
|
||||||
if (categoryRef) {
|
if (categoryRef) {
|
||||||
categoryRef.scrollIntoView({
|
// Get the sticky header height (70px when sticky, 0 when not)
|
||||||
|
const stickyHeaderHeight = isCategoriesSticky && categoriesContainerRef.current
|
||||||
|
? categoriesContainerRef.current.offsetHeight
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
// Calculate the position of the category element
|
||||||
|
const elementPosition = categoryRef.getBoundingClientRect().top;
|
||||||
|
const offsetPosition = elementPosition + window.pageYOffset - stickyHeaderHeight;
|
||||||
|
|
||||||
|
// Scroll to the exact position, accounting for sticky header
|
||||||
|
window.scrollTo({
|
||||||
|
top: offsetPosition,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, [isCategoriesSticky, categoriesContainerRef]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollHandlerContext.Provider
|
<ScrollHandlerContext.Provider
|
||||||
|
|||||||
@@ -364,6 +364,19 @@ const orderSlice = createSlice({
|
|||||||
state.collectionMethod = "";
|
state.collectionMethod = "";
|
||||||
state.paymentMethod = "";
|
state.paymentMethod = "";
|
||||||
state.loyaltyValidationError = null;
|
state.loyaltyValidationError = null;
|
||||||
|
state.discount = {
|
||||||
|
value: 0,
|
||||||
|
isGift: false,
|
||||||
|
isDiscount: false,
|
||||||
|
};
|
||||||
|
state.plateCar = "";
|
||||||
|
state.pickupDate = "";
|
||||||
|
state.pickupTime = "";
|
||||||
|
state.pickupType = "";
|
||||||
|
state.estimateWay = "";
|
||||||
|
state.order = null;
|
||||||
|
state.splitBillAmount = 0;
|
||||||
|
state.customerName = "";
|
||||||
// Clear all cart data from localStorage
|
// Clear all cart data from localStorage
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
Object.values(CART_STORAGE_KEYS)
|
Object.values(CART_STORAGE_KEYS)
|
||||||
|
|||||||
@@ -158,8 +158,7 @@ export function AddToCartButton({ item }: { item: Product }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return isInCart && !hasOptions ? (
|
return (
|
||||||
<>
|
|
||||||
<div
|
<div
|
||||||
className={styles.cartItemActions}
|
className={styles.cartItemActions}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -167,12 +166,16 @@ export function AddToCartButton({ item }: { item: Product }) {
|
|||||||
e.preventDefault;
|
e.preventDefault;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{isInCart && !hasOptions ? (
|
||||||
|
<>
|
||||||
<div className={styles.quantityControls}>
|
<div className={styles.quantityControls}>
|
||||||
<div className={styles.quantityInputContainer}>
|
<div className={styles.quantityInputContainer}>
|
||||||
<Button
|
<Button
|
||||||
shape="circle"
|
shape="circle"
|
||||||
iconPlacement="start"
|
iconPlacement="start"
|
||||||
icon={<MinusOutlined title="minus" style={{ color: "black" }} />}
|
icon={
|
||||||
|
<MinusOutlined title="minus" style={{ color: "black" }} />
|
||||||
|
}
|
||||||
size="small"
|
size="small"
|
||||||
onClick={handleMinusClick}
|
onClick={handleMinusClick}
|
||||||
className={styles.addButton}
|
className={styles.addButton}
|
||||||
@@ -221,17 +224,8 @@ export function AddToCartButton({ item }: { item: Product }) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
bottom: -11,
|
|
||||||
[isRTL ? "left" : "right"]: -2,
|
|
||||||
borderRadius: "50%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
shape="circle"
|
shape="circle"
|
||||||
iconPlacement="start"
|
iconPlacement="start"
|
||||||
@@ -252,13 +246,14 @@ export function AddToCartButton({ item }: { item: Product }) {
|
|||||||
width: 28,
|
width: 28,
|
||||||
height: 28,
|
height: 28,
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
bottom: 16,
|
[isRTL ? "left" : "right"]: -87,
|
||||||
[isRTL ? "left" : "right"]: 7,
|
bottom: 3,
|
||||||
minWidth: 28,
|
minWidth: 28,
|
||||||
boxShadow:
|
boxShadow:
|
||||||
"0px 1px 2px 0px #8585851A, 0px 3px 3px 0px #85858517, -1px 7px 4px 0px #8585850D, -1px 13px 5px 0px #85858503, -2px 20px 6px 0px #85858500",
|
"0px 1px 2px 0px #8585851A, 0px 3px 3px 0px #85858517, -1px 7px 4px 0px #8585850D, -1px 13px 5px 0px #85858503, -2px 20px 6px 0px #85858500",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user