MSP-3486 update Context.Provider in App

This commit is contained in:
Anastasiia committed 2024-06-28 14:27:52 +07:00
1 parent af3da2fbd0
commit 8e975fa5d4
1 file changed
+12 -3
+12 -3
View File
@@ -1,8 +1,8 @@
import { ConfigProvider } from 'antd'
import ruRu from 'antd/locale/ru_RU'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { lightTheme } from '@constants/theme.ts'
import { darkTheme, lightTheme } from '@constants/theme.ts'
import { Context } from '@stores/index.tsx'
@@ -12,10 +12,19 @@ import './app.scss'
const App = () => {
const [themes, setTheme] = useState(lightTheme)
const [changeTheme, setChangeTheme] = useState(
localStorage.getItem('theme')
? JSON.parse(localStorage.getItem('theme') || '')
: true
)
useEffect(() => {
setTheme(() => (changeTheme ? darkTheme : lightTheme))
}, [changeTheme])
return (
<div className="app">
<Context.Provider value={{ setTheme }}>
<Context.Provider value={{ setTheme, setChangeTheme, changeTheme }}>
<ConfigProvider theme={themes} locale={ruRu}>
<Routers />
</ConfigProvider>