Files
userbase/app/src/ui/client/schema/system/use-bknd-system.ts
T
2025-02-06 15:00:54 +01:00

42 lines
986 B
TypeScript

import { useBknd } from "ui/client/bknd";
import { useTheme } from "ui/client/use-theme";
export function useBkndSystem() {
const { config, schema, actions: bkndActions } = useBknd();
const { theme } = useTheme();
const actions = {
theme: {
set: async (scheme: "light" | "dark") => {
return await bkndActions.patch("server", "admin", {
color_scheme: scheme
});
},
toggle: async () => {
return await bkndActions.patch("server", "admin", {
color_scheme: theme === "light" ? "dark" : "light"
});
}
}
};
const $system = {};
return {
$system,
config: config.server,
schema: schema.server,
theme,
actions
};
}
export function useBkndSystemTheme() {
const $sys = useBkndSystem();
return {
theme: $sys.theme,
set: $sys.actions.theme.set,
toggle: () => $sys.actions.theme.toggle()
};
}