refactor(web): split config hook/context (.ts) from provider (.tsx) to clear react-refresh lint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 15:01:33 +02:00
parent de11292203
commit 04e9c95c52
4 changed files with 22 additions and 18 deletions
+2 -1
View File
@@ -2,7 +2,8 @@ import { expect, test, beforeEach } from "vitest";
import { screen, waitFor, render } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import i18n, { LOCALE_KEY } from "../i18n";
import { ConfigProvider, useConfig } from "./config-context";
import { ConfigProvider } from "./config-provider";
import { useConfig } from "./config-context";
function Probe() {
const config = useConfig();
+17
View File
@@ -0,0 +1,17 @@
import { createContext, useContext } from "react";
import type { components } from "../api/schema";
export type ConfigView = components["schemas"]["ConfigView"];
export const DEFAULTS: ConfigView = {
app_name: "Collection Management System",
default_language: "sv",
default_timezone: "Europe/Stockholm",
};
export const ConfigContext = createContext<ConfigView>(DEFAULTS);
export function useConfig(): ConfigView {
return useContext(ConfigContext);
}
@@ -1,23 +1,9 @@
import { createContext, useContext, useEffect, type ReactNode } from "react";
import { useEffect, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import type { components } from "../api/schema";
import { api } from "../api/client";
import i18n, { LOCALE_KEY } from "../i18n";
type ConfigView = components["schemas"]["ConfigView"];
const DEFAULTS: ConfigView = {
app_name: "Collection Management System",
default_language: "sv",
default_timezone: "Europe/Stockholm",
};
const ConfigContext = createContext<ConfigView>(DEFAULTS);
export function useConfig(): ConfigView {
return useContext(ConfigContext);
}
import { ConfigContext, DEFAULTS, type ConfigView } from "./config-context";
export function ConfigProvider({ children }: { children: ReactNode }) {
const { data } = useQuery({
+1 -1
View File
@@ -3,7 +3,7 @@ import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { App } from "./app";
import { ConfigProvider } from "./config/config-context";
import { ConfigProvider } from "./config/config-provider";
import "./index.css";
import "./i18n";