diff --git a/src/app/dashboard/components/UserOrganizations.tsx b/src/app/dashboard/components/UserOrganizations.tsx index 7b89a73..c35e0fd 100644 --- a/src/app/dashboard/components/UserOrganizations.tsx +++ b/src/app/dashboard/components/UserOrganizations.tsx @@ -23,10 +23,12 @@ const fetcher: Fetcher, string> = async ( if (!res.ok) { const message = (await res.json()).message; const status = res.status; - log.warn(message); + if (status >= 500) { + log.error(message); + } + } else { + return res.json(); } - - return res.json(); }; const backgroundColors = ['bg-emerald-400', 'bg-amber-400', 'bg-fuchsia-400']; @@ -46,9 +48,7 @@ export default function UserOrganizations() { useEffect(() => { setIsLoading(true); - trigger() - .catch((e) => log.warn('could not load user organizations', e)) - .finally(() => setIsLoading(false)); + trigger().finally(() => setIsLoading(false)); }, [trigger]); let userOrganizations; diff --git a/src/app/dashboard/dashboard-layout.tsx b/src/app/dashboard/dashboard-layout.tsx index ce60e04..2f69a1b 100644 --- a/src/app/dashboard/dashboard-layout.tsx +++ b/src/app/dashboard/dashboard-layout.tsx @@ -53,10 +53,13 @@ export default function DashboardLayout({ const [isCollapsed, setIsCollapsed] = useState(); const [userSettings, setUserSettings] = useState< UserSettingsType | undefined - >(getItemFromLocalStorage(generateUserSettingsKey(session))); + >(); useEffect(() => { if (!userSettings) { + setUserSettings( + getItemFromLocalStorage(generateUserSettingsKey(session)), + ); return; } if (userSettings.darkMode) { diff --git a/src/app/dashboard/settings/components/UserSettings.tsx b/src/app/dashboard/settings/components/UserSettings.tsx index 3700745..65511e3 100644 --- a/src/app/dashboard/settings/components/UserSettings.tsx +++ b/src/app/dashboard/settings/components/UserSettings.tsx @@ -18,6 +18,7 @@ export default function UserSettings() {
{ setUserSettings({ ...userSettings, diff --git a/src/app/util/local-storage.ts b/src/app/util/local-storage.ts index 21b8d8d..9f76f4c 100644 --- a/src/app/util/local-storage.ts +++ b/src/app/util/local-storage.ts @@ -4,7 +4,7 @@ const log = logger.child({ module: 'localStorageUtil' }); export const getItemFromLocalStorage = (key: string): any | undefined => { let currentValue; - if (!localStorage) { + if (typeof window === 'undefined') { return undefined; } try {