Skip to content

Commit

Permalink
fix: initial state for safe apps
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Mar 27, 2024
1 parent dda26d6 commit 5e2c3c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/PageLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ import { Header } from '@/components/Header'

import css from './styles.module.css'
import NavTabs from '../NavTabs'
import { AppRoutes, RoutesRequiringWallet, RoutesWithNavigation } from '@/config/routes'
import { AppRoutes, RoutesWithNavigation, RoutesRequiringWallet } from '@/config/routes'
import { useRouter } from 'next/router'
import { useWallet } from '@/hooks/useWallet'
import { useIsSafeApp } from '@/hooks/useIsSafeApp'

export const PageLayout = ({ children }: { children: ReactNode }): ReactElement => {
const router = useRouter()
const showNavigation = RoutesWithNavigation.includes(router.route)

const wallet = useWallet()
const isSafeApp = useIsSafeApp()

useEffect(() => {
if (!wallet && RoutesRequiringWallet.includes(router.route)) {
if (!wallet && !isSafeApp && RoutesRequiringWallet.includes(router.route)) {
router.push(AppRoutes.connect)
}
})
}, [isSafeApp, router, wallet])

return (
<>
Expand Down

0 comments on commit 5e2c3c2

Please sign in to comment.