UNPKG

@defikitdotnet/x-ai-combat

Version:

XCombatAI - Social Media Engagement Template for the Agent Framework

28 lines 3.19 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import Link from 'next/link'; import { useAuth } from '../contexts/AuthContext'; /** * Navbar component with user info and navigation * Styled with Twitter-inspired light blue theme */ const Navbar = ({ agentId }) => { const { user, logout, isLoading } = useAuth(); const handleLogout = async (e) => { e.preventDefault(); await logout(); }; const handleConnectX = () => { // Sử dụng URL tuyệt đối và giá trị testAgentId này const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:3005'; const callbackUrl = `${window.location.origin}/auth/callback`; let loginPath = `/xaicombat/api/auth/twitter/login?callback=${encodeURIComponent(callbackUrl)}`; if (agentId) { loginPath += `&agentId=${encodeURIComponent(agentId)}`; } window.location.href = `${backendUrl}${loginPath}`; }; return (_jsx("nav", { className: "bg-brand-500 dark:bg-brand-600 text-text-dark shadow-md sticky top-0 z-50", children: _jsx("div", { className: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8", children: _jsxs("div", { className: "flex justify-between h-16", children: [_jsx("div", { className: "flex-shrink-0 flex items-center", children: _jsxs(Link, { href: "#", className: "text-xl font-bold flex items-center", children: [_jsx("svg", { className: "h-8 w-8 mr-2", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }), _jsx("span", { className: "font-extrabold tracking-tight", children: "X-AI Combat" })] }) }), _jsx("div", { className: "flex items-center", children: user ? (_jsxs("div", { className: "flex items-center", children: [_jsxs("div", { className: "flex items-center mr-2", children: [_jsx("div", { className: "flex-shrink-0 h-8 w-8 rounded-full bg-text-dark flex items-center justify-center mr-2", children: _jsx("span", { className: "text-sm font-bold text-brand-500", children: user.username.charAt(0).toUpperCase() }) }), _jsxs("span", { className: "font-medium hidden sm:inline", children: ["@", user.username] })] }), _jsx("button", { onClick: handleLogout, className: "inline-flex items-center px-3 py-1 border border-transparent text-sm font-medium rounded-full bg-text-dark/20 hover:bg-text-dark/30 text-text-dark transition-colors duration-150", children: "Sign out" })] })) : (_jsxs("button", { onClick: handleConnectX, className: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-full text-white bg-black hover:bg-gray-800 transition-colors duration-150 shadow-sm", children: [_jsx("svg", { className: "w-5 h-5 mr-2", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }), "Connect X"] })) })] }) }) })); }; export default Navbar; //# sourceMappingURL=Navbar.js.map