"use client"; import { loginWithDiscord } from "@/app/login/actions"; import gsap from "gsap"; import { useEffect, useRef } from "react"; import { SiDiscord } from "react-icons/si"; interface LoginContentProps { error?: string; } export function LoginContent({ error }: LoginContentProps) { const containerRef = useRef(null); const cardRef = useRef(null); const dotsRef = useRef(null); const titleRef = useRef(null); const buttonRef = useRef(null); const errorRef = useRef(null); const bgOrb1Ref = useRef(null); const bgOrb2Ref = useRef(null); const getErrorMessage = (code?: string) => { if (!code) return null; if (code === "unauthorized") { return "Cet utilisateur Discord n'est pas autorisé."; } if (code === "oauth_failed") { return "La connexion avec Discord a échoué. Réessaie."; } return "Une erreur est survenue."; }; const errorMessage = getErrorMessage(error); useEffect(() => { const ctx = gsap.context(() => { const tl = gsap.timeline({ defaults: { ease: "power3.out" } }); gsap.to(bgOrb1Ref.current, { x: 50, y: 30, duration: 8, repeat: -1, yoyo: true, ease: "sine.inOut", }); gsap.to(bgOrb2Ref.current, { x: -40, y: -20, duration: 6, repeat: -1, yoyo: true, ease: "sine.inOut", }); tl.fromTo( cardRef.current, { opacity: 0, y: 40, scale: 0.95 }, { opacity: 1, y: 0, scale: 1, duration: 0.8 } ); tl.fromTo( dotsRef.current?.children || [], { scale: 0, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.4, stagger: 0.1, ease: "back.out(1.7)", }, "-=0.4" ); tl.fromTo( titleRef.current, { opacity: 0, clipPath: "inset(0 100% 0 0)" }, { opacity: 1, clipPath: "inset(0 0% 0 0)", duration: 0.6 }, "-=0.2" ); if (errorRef.current) { tl.fromTo( errorRef.current, { opacity: 0, x: -20 }, { opacity: 1, x: 0, duration: 0.4 }, "-=0.2" ); } tl.fromTo( buttonRef.current, { opacity: 0, y: 20 }, { opacity: 1, y: 0, duration: 0.5 }, "-=0.2" ); gsap.to(buttonRef.current, { boxShadow: "0 0 20px rgba(99, 102, 241, 0.3)", duration: 1.5, repeat: -1, yoyo: true, ease: "sine.inOut", }); }, containerRef); return () => ctx.revert(); }, []); const handleButtonHover = () => { gsap.to(buttonRef.current, { scale: 1.02, duration: 0.3, ease: "power2.out", }); }; const handleButtonLeave = () => { gsap.to(buttonRef.current, { scale: 1, duration: 0.3, ease: "power2.out", }); }; return (
{/* Effets de fond */}
{/* Contenu */}
{/* Header type terminal */}
~/auth/login/

Connexion

{/* Message d'erreur éventuel */} {errorMessage && (
{errorMessage}
)} {/* Bouton Discord */}
); }