diff --git a/src/app/(store)/components/layout/header/cart/index.tsx b/src/app/(store)/components/layout/header/cart/index.tsx index baa9327..e610d17 100644 --- a/src/app/(store)/components/layout/header/cart/index.tsx +++ b/src/app/(store)/components/layout/header/cart/index.tsx @@ -106,7 +106,6 @@ const Cart = () => { setDialogOpen(null)} > Descubre nuestras catas @@ -143,11 +142,6 @@ const Cart = () => { items.length === 0 && 'pointer-events-none cursor-not-allowed opacity-50' }`} - onClick={() => { - if (items.length !== 0) { - setDialogOpen(null) - } - }} > Finalizar compra diff --git a/src/app/contexts/dialogs.tsx b/src/app/contexts/dialogs.tsx index 4a4c08e..63ad7d4 100644 --- a/src/app/contexts/dialogs.tsx +++ b/src/app/contexts/dialogs.tsx @@ -5,9 +5,12 @@ import React, { Dispatch, SetStateAction, useContext, + useEffect, useState } from 'react' +import { usePathname } from 'next/navigation' + export enum Dialogs { Menu, Cart @@ -23,6 +26,15 @@ const DialogContext = createContext(undefined) export function DialogProvider({ children }: { children: React.ReactNode }) { const [dialogOpen, setDialogOpen] = useState(null) + const pathname = usePathname() + useEffect(() => { + setDialogOpen(null) + + return () => { + setDialogOpen(null) + } + }, [pathname]) + return ( {children}