export default function MainLayout({ children }: Props) {
const router = useRouter()
const [sidebarOpen, setSidebarOpen] = useState(false)
// save current route to determine if we are going back or forward
const [currentRoute, setCurrentRoute] = useState(router.route)
// check if we are going back or forward
router.events.on('routeChangeStart', (url) => {
if (url === currentRoute) {
setCurrentRoute(url)
}
})
const getMotion = () => {
// if going back to previous page, use left slide
if (currentRoute === router.route) {
return (
<LeftSlideMotion className="mun-h-screen">{children}</LeftSlideMotion>
)
}
return (
<RightSlideMotion className="min-h-screen">{children}</RightSlideMotion>
)
}
export default function MainLayout({ children }: Props) {
const router = useRouter()
const [sidebarOpen, setSidebarOpen] = useState(false)
// save current route to determine if we are going back or forward
const [currentRoute, setCurrentRoute] = useState(router.route)
// check if we are going back or forward
router.events.on('routeChangeStart', (url) => {
if (url === currentRoute) {
setCurrentRoute(url)
}
})
const getMotion = () => {
// if going back to previous page, use left slide
if (currentRoute === router.route) {
return (
<LeftSlideMotion className="mun-h-screen">{children}</LeftSlideMotion>
)
}
return (
<RightSlideMotion className="min-h-screen">{children}</RightSlideMotion>
)
}