fix context error

This commit is contained in:
2025-08-03 14:04:10 +02:00
parent 7ad74db834
commit 28ee97782c
4 changed files with 26 additions and 20 deletions
+2 -18
View File
@@ -1,29 +1,13 @@
"use client"; "use client";
import "./style.css"; import "./style.css";
import { useState, createContext, useContext } from "react"; import { useState } from "react";
import { AuthProvider } from "react-oidc-context"; import { AuthProvider } from "react-oidc-context";
import { oidcConfig, userManager } from "muzak/config/auth"; import { oidcConfig, userManager } from "muzak/config/auth";
import { Source_Sans_3, Nunito } from "next/font/google"; import { Source_Sans_3, Nunito } from "next/font/google";
import AuthStatus from "muzak/components/AuthStatus"; import AuthStatus from "muzak/components/AuthStatus";
import NavigationBar from "muzak/components/NavigationBar"; import NavigationBar from "muzak/components/NavigationBar";
import Quota from "muzak/components/Quota"; import Quota from "muzak/components/Quota";
import { AnimationContext } from "muzak/contexts/AnimationContext";
interface AnimationContextType {
isAnimate: boolean;
setIsAnimate: React.Dispatch<React.SetStateAction<boolean>>;
}
const AnimationContext = createContext<AnimationContextType | undefined>(
undefined,
);
export const useAnimation = () => {
const context = useContext(AnimationContext);
if (context === undefined) {
throw new Error("useAnimation must be used within an AnimationProvider");
}
return context;
};
const nunito = Nunito({ const nunito = Nunito({
subsets: ["latin"], subsets: ["latin"],
+1 -1
View File
@@ -2,7 +2,7 @@
import { useState } from "react"; import { useState } from "react";
import { Nunito } from "next/font/google"; import { Nunito } from "next/font/google";
import { api } from "muzak/data/fetcher"; import { api } from "muzak/data/fetcher";
import { useAnimation } from "../layout"; import { useAnimation } from "muzak/contexts/AnimationContext";
const nunito = Nunito({ const nunito = Nunito({
weight: "900", weight: "900",
@@ -0,0 +1,21 @@
"use client";
import { createContext, useContext } from "react";
interface AnimationContextType {
isAnimate: boolean;
setIsAnimate: React.Dispatch<React.SetStateAction<boolean>>;
}
const AnimationContext = createContext<AnimationContextType | undefined>(
undefined,
);
export const useAnimation = () => {
const context = useContext(AnimationContext);
if (context === undefined) {
throw new Error("useAnimation must be used within an AnimationProvider");
}
return context;
};
export { AnimationContext };
+2 -1
View File
@@ -9,7 +9,8 @@
"muzak/config/*": ["./src/config/*"], "muzak/config/*": ["./src/config/*"],
"muzak/data/*": ["./src/data/*"], "muzak/data/*": ["./src/data/*"],
"muzak/app/*": ["./src/app/*"], "muzak/app/*": ["./src/app/*"],
"muzak/components/*": ["./src/components/*"] "muzak/components/*": ["./src/components/*"],
"muzak/contexts/*": ["./src/contexts/*"]
}, },
"allowJs": false, "allowJs": false,