diff --git a/frontend/app/App.jsx b/frontend/app/App.jsx index dab21a5..eb5ec4a 100644 --- a/frontend/app/App.jsx +++ b/frontend/app/App.jsx @@ -71,7 +71,12 @@ export const App = (props) => { setColorPicker={setColorPicker} /> )} - {settingsPopup && } + {settingsPopup && ( + + )}
{props.children}
diff --git a/frontend/app/components/NavigationRail/NavigationRail.jsx b/frontend/app/components/NavigationRail/NavigationRail.jsx index 877bef0..97ae4a5 100644 --- a/frontend/app/components/NavigationRail/NavigationRail.jsx +++ b/frontend/app/components/NavigationRail/NavigationRail.jsx @@ -77,6 +77,15 @@ export const NavigationRail = (props) => { ); })} + {userStore.isAuth && ( + + )} + - - {userStore.isAuth ? ( - - ) : ( - "" - )} ); }; diff --git a/frontend/app/components/Settings/Settings.jsx b/frontend/app/components/Settings/Settings.jsx index 27861e3..5c19989 100644 --- a/frontend/app/components/Settings/Settings.jsx +++ b/frontend/app/components/Settings/Settings.jsx @@ -1,5 +1,8 @@ "use client"; +import { useUserStore } from "@/app/store/user-store"; +import { useSettingsStore } from "@/app/store/settings-store"; + function deleteAllSettings() { localStorage.removeItem("mode"); localStorage.removeItem("theme"); @@ -9,7 +12,10 @@ function deleteSearchHistory() { localStorage.removeItem("searches"); } -export default function Settings() { +export default function Settings(props) { + const userStore = useUserStore(); + const settingsStore = useSettingsStore(); + return ( <>
Настройки
- -
  • + {userStore.isAuth && ( + <> + +
  • + + )} +
    +
    ); diff --git a/frontend/app/store/settings-store.js b/frontend/app/store/settings-store.js new file mode 100644 index 0000000..141bb9c --- /dev/null +++ b/frontend/app/store/settings-store.js @@ -0,0 +1,25 @@ +"use client"; +import { create } from "zustand"; +import { persist, createJSONStorage } from "zustand/middleware"; + +function saveSettings(dict) { + localStorage.setItem("settings", JSON.stringify(dict)); +} + +function loadSettings() { + return JSON.parse(localStorage.getItem("settings")); +} + +export const useSettingsStore = create( + persist( + (set, get) => ({ + saveToHistory: true, + setSettings: (dict) => { + set(dict); + }, + }), + { + name: "settings", + }, + ), +);