Safety backup before Path A fixes - fixing function mismatches and missing functions
This commit is contained in:
+2
-29
@@ -1,28 +1,6 @@
|
||||
// Header functionality
|
||||
|
||||
import { Alpine } from "./alpine";
|
||||
import { applyTheme } from "./theme";
|
||||
import { updateThemeIndicators } from "./themeDropdown";
|
||||
|
||||
const changeTheme = (theme: string): void => {
|
||||
// Apply the theme using the consolidated function from theme.ts
|
||||
applyTheme(theme);
|
||||
|
||||
// Save to server if logged in
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
fetch("/api/auth/theme", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({ theme }),
|
||||
}).catch((err) => console.log("Theme save failed", err));
|
||||
}
|
||||
|
||||
// Alpine closes dropdown automatically via template state
|
||||
};
|
||||
|
||||
const logout = (): void => {
|
||||
localStorage.removeItem("token");
|
||||
@@ -30,13 +8,8 @@ const logout = (): void => {
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
export { changeTheme, logout };
|
||||
export { logout };
|
||||
|
||||
Alpine.global("header", {
|
||||
Alpine.store("header", {
|
||||
logout,
|
||||
changeThemeTo: (theme: string) => {
|
||||
console.log("changeThemeTo called with:", theme);
|
||||
changeTheme(theme);
|
||||
updateThemeIndicators();
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user