diff --git a/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx b/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx index 5012549..6b4ad03 100644 --- a/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx +++ b/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx @@ -14,17 +14,17 @@ export function SyncLocalStorageWithCookie({ withRedirect = false, }: SyncLocalStorageWithCookieProps) { const [selectedSchool] = useAtom(selectedSchoolAtom); - + const { host } = selectedSchool || {}; useEffect(() => { - if (selectedSchool) { - Cookies.set('selectedSchool', selectedSchool.host); + if (host) { + Cookies.set('selectedSchool', host); if (withRedirect) { redirect('/'); } } else { Cookies.remove('selectedSchool'); } - }, [selectedSchool, withRedirect]); + }, [host, withRedirect]); return <>>; } diff --git a/src/app/settings/_libs/ui/settings-ui.tsx b/src/app/settings/_libs/ui/settings-ui.tsx index c6641f4..d25361b 100644 --- a/src/app/settings/_libs/ui/settings-ui.tsx +++ b/src/app/settings/_libs/ui/settings-ui.tsx @@ -3,6 +3,7 @@ import SchoolCustomization from '@/app/settings/_libs/components/school-customiz import SchoolAction from '@/app/settings/_libs/components/school-action'; import { SettingsConfig } from '@/app/_libs/types'; import JumpToFullscreen from '@/app/settings/_libs/components/jump-to-fullscreen'; +import { SyncLocalStorageWithCookie } from '@/app/settings/_libs/components/sync-localstorage-with-cookie'; export default async function SettingsUI({ mode = 'settings', @@ -10,6 +11,7 @@ export default async function SettingsUI({ }: SettingsConfig) { return (