From 438e1ac20fbce67f8973acc7ad5b2e4f32ffd92a Mon Sep 17 00:00:00 2001 From: Chloe Date: Wed, 8 May 2024 16:24:08 +0700 Subject: [PATCH] fix: close modal when variant is selected Signed-off-by: Chloe --- components/product/variant-selector.tsx | 55 ++++++++----------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/components/product/variant-selector.tsx b/components/product/variant-selector.tsx index b87788fc7..4ee9d46bc 100644 --- a/components/product/variant-selector.tsx +++ b/components/product/variant-selector.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Dialog, Transition } from '@headlessui/react'; +import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'; import { XMarkIcon } from '@heroicons/react/24/outline'; import clsx from 'clsx'; import Price from 'components/price'; @@ -8,7 +8,7 @@ import { CORE_VARIANT_ID_KEY, CORE_WAIVER } from 'lib/constants'; import { CoreChargeOption, Money, ProductOption, ProductVariant } from 'lib/shopify/types'; import { createUrl } from 'lib/utils'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; -import { Fragment, MouseEvent, useEffect, useState } from 'react'; +import { Fragment, useEffect, useState } from 'react'; type Combination = { id: string; @@ -74,18 +74,6 @@ export function VariantSelector({ const openModal = () => setIsOpen(true); const closeModal = () => setIsOpen(false); - const handleCoreChargeClick = ( - event: MouseEvent, - coreVariantId: string | null - ) => { - event.stopPropagation(); - if (!coreVariantId) return; - const optionSearchParams = new URLSearchParams(searchParams.toString()); - optionSearchParams.set(CORE_VARIANT_ID_KEY, coreVariantId); - const newUrl = createUrl(pathname, optionSearchParams); - router.replace(newUrl, { scroll: false }); - }; - return (
More Remanufactured and Used Options{' '} @@ -99,7 +87,7 @@ export function VariantSelector({ -
@@ -273,8 +252,8 @@ export function VariantSelector({ ); })}
- -
+ +