Added handle method for the auth in the HomePage
This commit is contained in:
parent
d88697f282
commit
c4edfbd6de
@ -29,7 +29,7 @@ import MessageBus from "@/lib/4nk/MessageBus"
|
||||
import UserStore from "@/lib/4nk/UserStore"
|
||||
import Iframe from "@/components/4nk/Iframe"
|
||||
import EventBus from "@/lib/4nk/EventBus"
|
||||
// DebugInfo supprimé
|
||||
import { iframeUrl } from "../page"
|
||||
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
@ -46,7 +46,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
|
||||
const navigation = [
|
||||
{ name: "Tableau de bord", href: "/dashboard", icon: LayoutDashboard },
|
||||
@ -85,6 +84,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
messageBus.isReady().then(() => {
|
||||
messageBus.getMyProcesses().then((res: string[]) => {
|
||||
setMyProcesses(res);
|
||||
console.log("getMyProcesses", res);
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -168,8 +168,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
<Shield className="h-12 w-12 mx-auto mb-4 text-blue-600 animate-pulse" />
|
||||
<p className="text-gray-600">Vérification de l'authentification...</p>
|
||||
</div>
|
||||
{<Iframe iframeUrl={iframeUrl} />}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -351,7 +349,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
</div>
|
||||
)}
|
||||
|
||||
{<Iframe iframeUrl={iframeUrl} />}
|
||||
{isConnected && <Iframe iframeUrl={iframeUrl} />}
|
||||
|
||||
{/* Debug info retiré */}
|
||||
</div>
|
||||
|
||||
@ -26,7 +26,6 @@ import {
|
||||
HardDrive,
|
||||
X,
|
||||
} from "lucide-react"
|
||||
import MessageBus from "@/lib/4nk/MessageBus"
|
||||
import Link from "next/link"
|
||||
|
||||
export default function DashboardPage() {
|
||||
@ -54,11 +53,6 @@ export default function DashboardPage() {
|
||||
const [notifications, setNotifications] = useState<any[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
const messageBus = MessageBus.getInstance(iframeUrl)
|
||||
// const mockMode = messageBus.isInMockMode()
|
||||
// setIsMockMode(mockMode)
|
||||
|
||||
// Simuler le chargement des données
|
||||
if (true) {
|
||||
setStats({
|
||||
|
||||
36
app/page.tsx
36
app/page.tsx
@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import Link from "next/link"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@ -8,16 +8,25 @@ import { Badge } from "@/components/ui/badge"
|
||||
import { Shield, ArrowRight, Key, Zap, Users, Globe, Database, Code, CheckCircle } from "lucide-react"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import AuthModal from "@/components/4nk/AuthModal"
|
||||
import Iframe from "@/components/4nk/Iframe"
|
||||
import UserStore from "@/lib/4nk/UserStore"
|
||||
|
||||
export const iframeUrl = 'https://dev3.4nkweb.com'
|
||||
|
||||
export default function HomePage() {
|
||||
const [showLoginModal, setShowLoginModal] = useState(false)
|
||||
const [showAuthModal, setShowAuthModal] = useState(false)
|
||||
const [isConnected, setIsConnected] = useState(false)
|
||||
const [userPairingId, setUserPairingId] = useState<string | null>(null)
|
||||
|
||||
const handleAuthConnect = useCallback(() => {
|
||||
setIsConnected(true);
|
||||
setShowAuthModal(false);
|
||||
router.push("/dashboard")
|
||||
console.log('Auth Connect - Connexion établie, le useEffect se chargera de récupérer le userPairingId');
|
||||
}, []);
|
||||
|
||||
const handleAuthClose = useCallback(() => {
|
||||
setShowAuthModal(false);
|
||||
}, []);
|
||||
|
||||
const router = useRouter()
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-50 to-blue-50">
|
||||
@ -44,7 +53,7 @@ export default function HomePage() {
|
||||
<Link href="/formation">
|
||||
<Button variant="outline">Formation</Button>
|
||||
</Link>
|
||||
<Button onClick={() => setShowLoginModal(true)}>Connexion</Button>
|
||||
<Button onClick={() => setShowAuthModal(true)}>Connexion</Button>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
@ -76,20 +85,15 @@ export default function HomePage() {
|
||||
</section>
|
||||
|
||||
{/* Modal d’authentification */}
|
||||
{showLoginModal && (
|
||||
{showAuthModal && (
|
||||
<AuthModal
|
||||
isOpen={showLoginModal}
|
||||
onConnect={() => {
|
||||
setShowLoginModal(false)
|
||||
router.push("/dashboard") // ✅ redirection après login
|
||||
}}
|
||||
onClose={() => setShowLoginModal(false)}
|
||||
isOpen={showAuthModal}
|
||||
onConnect={handleAuthConnect}
|
||||
onClose={handleAuthClose}
|
||||
iframeUrl={iframeUrl}
|
||||
/>
|
||||
)}
|
||||
|
||||
{<Iframe iframeUrl={iframeUrl} />}
|
||||
|
||||
{/* Product Features */}
|
||||
<section id="produit" className="py-16 px-4 bg-white">
|
||||
<div className="container mx-auto">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user