import { useTranslation } from "react-i18next"; import Heading from "@/components/ui/heading"; import type { SectionConfig } from "@/components/config-form/sections"; import { ConfigSectionTemplate } from "@/components/config-form/sections"; import type { PolygonType } from "@/types/canvas"; export type SettingsPageProps = { selectedCamera?: string; setUnsavedChanges?: React.Dispatch>; selectedZoneMask?: PolygonType[]; }; export type SingleSectionPageOptions = { sectionKey: string; level: "global" | "camera"; sectionConfig?: SectionConfig; requiresRestart?: boolean; showOverrideIndicator?: boolean; }; export function createSingleSectionPage({ sectionKey, level, sectionConfig, requiresRestart, showOverrideIndicator = true, }: SingleSectionPageOptions) { return function SingleSectionPage({ selectedCamera, setUnsavedChanges, }: SettingsPageProps) { const sectionNamespace = level === "camera" ? "config/cameras" : "config/global"; const { t, i18n } = useTranslation([ sectionNamespace, "views/settings", "common", ]); if (level === "camera" && !selectedCamera) { return (
{t("configForm.camera.noCameras", { ns: "views/settings" })}
); } return (
{t(`${sectionKey}.label`, { ns: sectionNamespace })} {i18n.exists(`${sectionKey}.description`, { ns: sectionNamespace, }) && (

{t(`${sectionKey}.description`, { ns: sectionNamespace })}

)}
setUnsavedChanges?.(false)} showTitle={false} sectionConfig={sectionConfig} requiresRestart={requiresRestart} />
); }; }