a9480ad9aa
- replace the legacy client-only Vite bootstrap with TanStack Router routes, Start SSR, and Nitro output - compose the reusable layout, navigation, appearance, chats, and notifications blocks with application-owned data - persist UI preferences through server functions and initialize theme, sidebar, and breakpoint state before hydration - add React Query, hotkey, toaster, and responsive dashboard integration - add application-owned Lingui configuration and catalogs, mount the runtime provider, and lazily enable I18nDevtool in development - remove superseded HTML, main entry, theme provider, and application ESLint configuration
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import "@tanstack/react-start/server-only"
|
|
import { getCookie, setCookie } from "@tanstack/react-start/server"
|
|
import {
|
|
type UiState,
|
|
type UiStateKey,
|
|
uiStateDefinitions,
|
|
} from "@workspace/blocks/appearance"
|
|
|
|
const LEGACY_THEME_COOKIE = "simple-shop-admin-theme"
|
|
|
|
export function readUiState(): UiState {
|
|
return {
|
|
"main-compacted": uiStateDefinitions["main-compacted"].parse(
|
|
getCookie(uiStateDefinitions["main-compacted"].cookie)
|
|
),
|
|
"sidebar-collapsed": uiStateDefinitions["sidebar-collapsed"].parse(
|
|
getCookie(uiStateDefinitions["sidebar-collapsed"].cookie)
|
|
),
|
|
"theme-mode": uiStateDefinitions["theme-mode"].parse(
|
|
getCookie(uiStateDefinitions["theme-mode"].cookie) ??
|
|
getCookie(LEGACY_THEME_COOKIE)
|
|
),
|
|
"theme-light": uiStateDefinitions["theme-light"].parse(
|
|
getCookie(uiStateDefinitions["theme-light"].cookie)
|
|
),
|
|
"theme-dark": uiStateDefinitions["theme-dark"].parse(
|
|
getCookie(uiStateDefinitions["theme-dark"].cookie)
|
|
),
|
|
}
|
|
}
|
|
|
|
export function writeUiState<K extends UiStateKey>(key: K, value: UiState[K]) {
|
|
const definition = uiStateDefinitions[key]
|
|
setCookie(definition.cookie, definition.serialize(value), {
|
|
path: "/",
|
|
sameSite: "lax",
|
|
maxAge: 60 * 60 * 24 * 365,
|
|
})
|
|
}
|