MSP-4164 add prevRoute to sessionStorage

This commit is contained in:
foxxy committed 2024-10-02 16:29:54 +03:00
1 parent 369b5b0785
commit 41d94162d0
1 file changed
+10
+10
View File
@@ -1,6 +1,7 @@
import { ConfigProvider } from 'antd'
import ruRu from 'antd/locale/ru_RU'
import { useEffect, useState } from 'react'
import { useLocation } from 'react-router-dom'
import { darkTheme, lightTheme } from '@constants/theme.ts'
@@ -18,6 +19,15 @@ const App = () => {
: true
)
const location = useLocation()
useEffect(() => {
const prevRoute = sessionStorage.getItem('prevRoute')
if (location.pathname !== prevRoute) {
sessionStorage.setItem('prevRoute', location.pathname)
}
}, [location])
useEffect(() => {
setTheme(() => (changeTheme ? darkTheme : lightTheme))
}, [changeTheme])