"use client"; import type { PropsWithChildren } from "react"; import { createContext, useContext } from "react"; import type { DayOfWeek } from "@mantine/dates"; import type { RouterOutputs } from "@homarr/api"; import type { User } from "@homarr/db/schema"; import type { ServerSettings } from "@homarr/server-settings"; type SettingsContextProps = Pick< User, | "firstDayOfWeek" | "defaultSearchEngineId" | "homeBoardId" | "mobileHomeBoardId" | "openSearchInNewTab" | "pingIconsEnabled" >; interface PublicServerSettings { search: Pick; board: Pick; } const SettingsContext = createContext(null); export const SettingsProvider = ({ user, serverSettings, children, }: PropsWithChildren<{ user: RouterOutputs["user"]["getById"] | null; serverSettings: PublicServerSettings }>) => { return ( {children} ); }; export const useSettings = () => { const context = useContext(SettingsContext); if (!context) throw new Error("useSettingsContext must be used within a SettingsProvider"); return context; };