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