import { config, type DataMode } from "../config"; import { getDataMode, setDataMode } from "../lib/mockData"; const LABELS: Record = { mock: "Mock Data", live: "Live API", }; export function initDataModeToggle(onChange: () => void): void { const container = document.querySelector("[data-role='data-mode-toggle']"); if (!container) return; const currentMode = getDataMode(); const isLive = currentMode === "live"; container.innerHTML = `
Data Mode:
`; const btn = document.getElementById("dataModeBtn") as HTMLButtonElement; if (btn) { btn.addEventListener("click", () => { const newMode = getDataMode() === "live" ? "mock" : "live"; setDataMode(newMode); // Reload the page to refresh data window.location.reload(); }); } } function renderControls(mode: DataMode): string { const options = (Object.keys(LABELS) as DataMode[]) .map((id) => ``) .join(""); return ` `; }