mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
Move app to apps/web-react in pnpm workspace layout
This commit is contained in:
19
apps/web-react/app/features/settings/settings-utils.ts
Normal file
19
apps/web-react/app/features/settings/settings-utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { SETTINGS_TAB_SLUGS, type SettingsTabSlug } from "./settings-constants";
|
||||
|
||||
const PUBLIC_TABS = new Set<SettingsTabSlug>(["locale", "theme"]);
|
||||
|
||||
export function defaultTab(isLoggedIn: boolean): SettingsTabSlug {
|
||||
return isLoggedIn ? "match-profile" : "theme";
|
||||
}
|
||||
|
||||
export function resolveActiveTab(
|
||||
raw: string | null,
|
||||
isLoggedIn: boolean,
|
||||
): SettingsTabSlug {
|
||||
if (raw && (SETTINGS_TAB_SLUGS as readonly string[]).includes(raw)) {
|
||||
const slug = raw as SettingsTabSlug;
|
||||
if (!isLoggedIn && !PUBLIC_TABS.has(slug)) return defaultTab(false);
|
||||
return slug;
|
||||
}
|
||||
return defaultTab(isLoggedIn);
|
||||
}
|
||||
Reference in New Issue
Block a user