diff --git a/apps/storefront/src/hooks/dom/useMonitorBrowserBack.ts b/apps/storefront/src/hooks/dom/useMonitorBrowserBack.ts index c169ab38..71c5dce5 100644 --- a/apps/storefront/src/hooks/dom/useMonitorBrowserBack.ts +++ b/apps/storefront/src/hooks/dom/useMonitorBrowserBack.ts @@ -1,8 +1,7 @@ -import { useEffect } from 'react' +import { useEffect, useState } from 'react' import { useAppSelector } from '@/store' import { CustomerRole } from '@/types' -import { B3SStorage } from '@/utils' interface UseMonitorBrowserBackProps { isOpen: boolean @@ -13,16 +12,16 @@ const useMonitorBrowserBack = ({ isOpen }: UseMonitorBrowserBackProps) => { const history = window.location const isLogin = role !== CustomerRole.GUEST - useEffect(() => { - const isEnterB2BBuyerPortal = B3SStorage.get('isEnterB2BBuyerPortal') + const [isEnterB2BBuyerPortal, setIsEnterB2BBuyerPortal] = useState(false) + useEffect(() => { if (isOpen && !history.hash.includes('/pdp')) { - B3SStorage.set('isEnterB2BBuyerPortal', true) + setIsEnterB2BBuyerPortal(true) } if (!isOpen && isLogin && isEnterB2BBuyerPortal) { window.location.reload() - B3SStorage.set('isEnterB2BBuyerPortal', false) + setIsEnterB2BBuyerPortal(false) } // disabling to avoid unnecessary renders when adding the missing dependencies // eslint-disable-next-line react-hooks/exhaustive-deps