Provide dashboard layout with 4NK context
This commit is contained in:
parent
bdaf711fd7
commit
b9a996c11e
@ -31,9 +31,10 @@ import EventBus from "@/lib/4nk/EventBus"
|
||||
import AuthModal from "@/components/4nk/AuthModal"
|
||||
import Iframe from "@/components/4nk/Iframe"
|
||||
import { iframeUrl } from "../page"
|
||||
import { FourNKProvider } from "@/lib/contexts/FourNKContext";
|
||||
import { FourNKProvider, use4NK } from "@/lib/contexts/FourNKContext";
|
||||
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
// Composant interne qui utilise le contexte 4NK
|
||||
function DashboardLayoutContent({ children }: { children: React.ReactNode }) {
|
||||
const [isConnected, setIsConnected] = useState(false)
|
||||
const [userPairingId, setUserPairingId] = useState<string | null>(null)
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
@ -45,6 +46,9 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
const [showLogoutConfirm, setShowLogoutConfirm] = useState(false)
|
||||
const [isCopied, setIsCopied] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
// Récupérer les données du contexte 4NK
|
||||
const { userName } = use4NK()
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
@ -225,9 +229,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
|
||||
{/* Page content */}
|
||||
<main className="flex-1 overflow-hidden bg-gray-900">
|
||||
<FourNKProvider>
|
||||
{children}
|
||||
</FourNKProvider>
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@ -268,4 +270,15 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
{isConnected && <Iframe iframeUrl={iframeUrl} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Composant principal qui wrap avec le provider
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<FourNKProvider>
|
||||
<DashboardLayoutContent>
|
||||
{children}
|
||||
</DashboardLayoutContent>
|
||||
</FourNKProvider>
|
||||
)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user