swipe extra with group of extra & don't show the global extra if we have variants
This commit is contained in:
@@ -10,6 +10,8 @@ import ArabicPrice from "components/ArabicPrice";
|
|||||||
import useBreakPoint from "hooks/useBreakPoint";
|
import useBreakPoint from "hooks/useBreakPoint";
|
||||||
import ExtraGroupsContainer from "pages/product/components/ExtraGroupsContainer.tsx";
|
import ExtraGroupsContainer from "pages/product/components/ExtraGroupsContainer.tsx";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useGetMenuQuery } from "redux/api/others.ts";
|
||||||
import { colors } from "ThemeConstants";
|
import { colors } from "ThemeConstants";
|
||||||
import { Extra, Product } from "utils/types/appTypes";
|
import { Extra, Product } from "utils/types/appTypes";
|
||||||
import BackButton from "../menu/components/BackButton";
|
import BackButton from "../menu/components/BackButton";
|
||||||
@@ -17,8 +19,6 @@ import ExtraComponent from "./components/Extra";
|
|||||||
import ProductFooter from "./components/ProductFooter";
|
import ProductFooter from "./components/ProductFooter";
|
||||||
import Variants from "./components/Variants";
|
import Variants from "./components/Variants";
|
||||||
import styles from "./product.module.css";
|
import styles from "./product.module.css";
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
import { useGetMenuQuery } from "redux/api/others.ts";
|
|
||||||
|
|
||||||
export default function ProductDetailPage({
|
export default function ProductDetailPage({
|
||||||
onClose,
|
onClose,
|
||||||
@@ -120,16 +120,12 @@ export default function ProductDetailPage({
|
|||||||
|
|
||||||
const getExtras = useCallback(() => {
|
const getExtras = useCallback(() => {
|
||||||
const finalSelectedVariant = getFinalSelectedVariant();
|
const finalSelectedVariant = getFinalSelectedVariant();
|
||||||
if (finalSelectedVariant) {
|
if (!finalSelectedVariant) return [];
|
||||||
const variant = product?.variants?.find(
|
const selectedVariant = product?.variants?.find(
|
||||||
(variant) => variant.id === finalSelectedVariant.id,
|
(variant) => variant.id === finalSelectedVariant.id,
|
||||||
);
|
);
|
||||||
if (variant?.extras?.length && variant.extras.length > 0) {
|
return selectedVariant?.extras || [];
|
||||||
return variant.extras;
|
}, [product?.variants, getFinalSelectedVariant]);
|
||||||
}
|
|
||||||
}
|
|
||||||
return product?.extras;
|
|
||||||
}, [product?.variants, product?.extras, getFinalSelectedVariant]);
|
|
||||||
|
|
||||||
// Validation function to check if all required selections are made
|
// Validation function to check if all required selections are made
|
||||||
const validateRequiredSelections = () => {
|
const validateRequiredSelections = () => {
|
||||||
@@ -316,14 +312,6 @@ export default function ProductDetailPage({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{getExtras()?.length > 0 && (
|
|
||||||
<ExtraComponent
|
|
||||||
extrasList={getExtras()}
|
|
||||||
selectedExtras={selectedExtras}
|
|
||||||
setSelectedExtras={setSelectedExtras}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{product.theExtrasGroups.length > 0 && (
|
{product.theExtrasGroups.length > 0 && (
|
||||||
<ExtraGroupsContainer
|
<ExtraGroupsContainer
|
||||||
groupsList={product.theExtrasGroups}
|
groupsList={product.theExtrasGroups}
|
||||||
@@ -331,6 +319,14 @@ export default function ProductDetailPage({
|
|||||||
setSelectedExtrasByGroup={setSelectedExtrasByGroup}
|
setSelectedExtrasByGroup={setSelectedExtrasByGroup}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{getExtras()?.length > 0 && (
|
||||||
|
<ExtraComponent
|
||||||
|
extrasList={getExtras()}
|
||||||
|
selectedExtras={selectedExtras}
|
||||||
|
setSelectedExtras={setSelectedExtras}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -489,11 +489,29 @@ export interface RestaurantDetails {
|
|||||||
contact_number: string;
|
contact_number: string;
|
||||||
menu_url: string;
|
menu_url: string;
|
||||||
taxes: Tax[];
|
taxes: Tax[];
|
||||||
|
minimum: string;
|
||||||
|
instagram: string;
|
||||||
|
whatsapp_phone: string;
|
||||||
|
global_currency: string;
|
||||||
|
local_currency: string;
|
||||||
|
is_hotel: number;
|
||||||
|
primary_color: string;
|
||||||
|
TimeZone: string;
|
||||||
|
is_schedule_order_enabled: number;
|
||||||
|
is_call_waiter_enabled: number;
|
||||||
|
pickup_type: string;
|
||||||
|
menu_background: string;
|
||||||
|
email: string;
|
||||||
|
prepaid_percentage: number;
|
||||||
|
enable_apple_passkey: number;
|
||||||
|
map_url: string;
|
||||||
|
use_googlemaps_url: number;
|
||||||
|
self_deliver: number;
|
||||||
|
subdomain: string;
|
||||||
openingTime: string;
|
openingTime: string;
|
||||||
closingTime: string;
|
closingTime: string;
|
||||||
isOpened: boolean;
|
isOpened: boolean;
|
||||||
isFav: boolean;
|
isFav: boolean;
|
||||||
is_schedule_order_enabled: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Banner {
|
export interface Banner {
|
||||||
|
|||||||
Reference in New Issue
Block a user