ProductPreviewDialog: close dialog after product adding
This commit is contained in:
@@ -28,7 +28,7 @@ export function ProductPreviewDialog({
|
|||||||
minWidth: "80vw",
|
minWidth: "80vw",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProductDetailPage />
|
<ProductDetailPage onClose={onClose} />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default function ProductFooter({
|
|||||||
selectedExtras,
|
selectedExtras,
|
||||||
selectedGroups,
|
selectedGroups,
|
||||||
quantity,
|
quantity,
|
||||||
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
product: Product;
|
product: Product;
|
||||||
isValid?: boolean;
|
isValid?: boolean;
|
||||||
@@ -27,6 +28,7 @@ export default function ProductFooter({
|
|||||||
selectedExtras: string[];
|
selectedExtras: string[];
|
||||||
selectedGroups: string[];
|
selectedGroups: string[];
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
onClose?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@@ -34,6 +36,7 @@ export default function ProductFooter({
|
|||||||
const { specialRequest } = useAppSelector(selectCart);
|
const { specialRequest } = useAppSelector(selectCart);
|
||||||
const [isSpecialRequestOpen, setIsSpecialRequestOpen] = useState(false);
|
const [isSpecialRequestOpen, setIsSpecialRequestOpen] = useState(false);
|
||||||
const { isMobile, isDesktop } = useBreakPoint();
|
const { isMobile, isDesktop } = useBreakPoint();
|
||||||
|
const { isRTL } = useAppSelector((state) => state.locale);
|
||||||
|
|
||||||
// Check if product has any customization options
|
// Check if product has any customization options
|
||||||
const hasCustomizationOptions = useMemo(() => {
|
const hasCustomizationOptions = useMemo(() => {
|
||||||
@@ -71,7 +74,10 @@ export default function ProductFooter({
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// Navigate back to menu - scroll position will be restored automatically
|
// Navigate back to menu - scroll position will be restored automatically
|
||||||
window.history.back();
|
if (!isDesktop) window.history.back();
|
||||||
|
else {
|
||||||
|
onClose?.();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,7 +107,7 @@ export default function ProductFooter({
|
|||||||
: {
|
: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
[isRTL ? "right" : "left"]: 0,
|
||||||
width: hasCustomizationOptions ? "50%" : "100%",
|
width: hasCustomizationOptions ? "50%" : "100%",
|
||||||
}),
|
}),
|
||||||
height: "10vh",
|
height: "10vh",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ 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";
|
||||||
|
|
||||||
export default function ProductDetailPage() {
|
export default function ProductDetailPage({ onClose }: { onClose: () => void }) {
|
||||||
const { isRTL } = useAppSelector((state) => state.locale);
|
const { isRTL } = useAppSelector((state) => state.locale);
|
||||||
const { isDesktop } = useBreakPoint();
|
const { isDesktop } = useBreakPoint();
|
||||||
const [quantity, setQuantity] = useState(1);
|
const [quantity, setQuantity] = useState(1);
|
||||||
@@ -277,6 +277,7 @@ export default function ProductDetailPage() {
|
|||||||
selectedExtras={selectedExtras}
|
selectedExtras={selectedExtras}
|
||||||
selectedGroups={Object.values(selectedExtrasByGroup).flat()}
|
selectedGroups={Object.values(selectedExtrasByGroup).flat()}
|
||||||
quantity={quantity}
|
quantity={quantity}
|
||||||
|
onClose={onClose}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user