Apple design (plans/gtm/APPLE-DESIGN-RULES-2026-11-17.md): rewrote theme tokens in globals.css/tailwind.config.js to neutral black/white + one accent (#0071E3), replacing the GitHub-dark blue+green dual-accent theme; mechanically swept every raw inline hex/rgba literal across app/components that bypassed the CSS vars (506 hex + 326 rgb(a) replacements) since most of the app hardcoded colors rather than using tokens; removed all emoji, decorative gradients (Tailwind bg-gradient-to-* and raw linear/radial- gradient() in inline styles), confetti, and glow/blur decorative orbs; converted Navbar/Navigation to icon-only with aria-label+title. Finished two stopped agents' in-progress work: deleted the fake AnimatedStats/ LiveActivity/ProjectShowcase/Testimonials auth-panel components and cleaned up the emoji-laden feature list in (auth)/layout.tsx. Removed remaining fabricated stats (topics/topics/[slug] posts-per-week/ contributors/followers) per the no-fake-numbers rule. Rithub sign-in: added "Continue with Rithub" as an icon-only OAuth2 button (RithubMark component) on login/register, hidden "Continue with GitHub" when GITHUB_CLIENT_ID is unset (confirmed unset in prod). Backend: authenticateWithGitea in oauthService.ts exchanges the Gitea OAuth2 code, resolves identity via the existing ForgeConnection table (no schema migration needed), issues the same JWT/session as GitHub/Google login. OAuth2 app created live on rithub.dev via its REST API as admin user caelum0x; client id/secret stored in railyard-box's compose file (env files don't ship to the runtime image, so the actual wiring lives in docker-compose.yml, not backend/.env) and in ~/products/.env. Critical bug found and fixed while verifying: services/api.ts's global 401 interceptor redirected every anonymous visitor to /login a couple seconds after ANY page load -- including /login and /register themselves -- because the AuthBootstrap's background GET /auth/me (expected to 401 for signed-out visitors) was treated the same as a real session-expiry 401, triggering a refresh attempt, another 401, and a hard window.location.href redirect, which re-ran AuthBootstrap and repeated. Fixed by excluding /auth/me and /auth/refresh from that redirect path. Verified live with a fresh, cookie-less browser: previously looped /register -> /login forever; now stable after 6s. Also fixed: production CORS/API origin mismatch -- the frontend was built with NEXT_PUBLIC_API_URL pointing at ritgram.ereboslab.com while served from ritgram.rithub.dev, so every API call (login, register, etc.) was blocked by CORS; rebuilt with rithub.dev as canonical and CORS_ORIGIN allowing both domains. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
110 lines
5.6 KiB
TypeScript
110 lines
5.6 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/navigation'
|
|
import { useAuthStore } from '@/store/authStore'
|
|
import { useToast } from './ui/toast'
|
|
import NotificationBell from './NotificationBell'
|
|
|
|
export default function Navbar() {
|
|
const router = useRouter()
|
|
const { user, isAuthenticated, logout } = useAuthStore()
|
|
const { showToast } = useToast()
|
|
|
|
const handleLogout = async () => {
|
|
try {
|
|
await logout()
|
|
showToast('Logged out successfully', 'success')
|
|
router.push('/login')
|
|
} catch (error) {
|
|
showToast('Failed to logout', 'error')
|
|
}
|
|
}
|
|
|
|
if (!isAuthenticated) return null
|
|
|
|
return (
|
|
<nav className="sticky top-0 z-50 bg-card border-b border-border">
|
|
<div className="max-w-7xl mx-auto px-4">
|
|
<div className="flex items-center justify-between h-16">
|
|
<Link href="/feed" className="text-2xl font-bold text-primary">
|
|
Ritgram
|
|
</Link>
|
|
|
|
<div className="flex items-center gap-6">
|
|
<Link href="/feed" className="hover:text-primary" aria-label="Feed" title="Feed">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
|
|
</svg>
|
|
</Link>
|
|
<Link href="/search" className="hover:text-primary" aria-label="Search" title="Search">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
</svg>
|
|
</Link>
|
|
<Link href="/reels" className="hover:text-primary" aria-label="Reels" title="Reels">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
|
</svg>
|
|
</Link>
|
|
<Link href="/messages" className="hover:text-primary" aria-label="Messages" title="Messages">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
|
|
</svg>
|
|
</Link>
|
|
<Link
|
|
href="/collaborate"
|
|
className="hover:text-primary"
|
|
aria-label="Talent graph"
|
|
title="Talent graph"
|
|
>
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<circle cx="6" cy="6" r="2.5" strokeWidth={2} />
|
|
<circle cx="18" cy="6" r="2.5" strokeWidth={2} />
|
|
<circle cx="12" cy="18" r="2.5" strokeWidth={2} />
|
|
<path strokeLinecap="round" strokeWidth={2} d="M8.2 7.2L11 16M15.8 7.2L13 16M8.5 6h7" />
|
|
</svg>
|
|
</Link>
|
|
<NotificationBell />
|
|
<Link href="/camera" className="hover:text-primary" aria-label="Camera" title="Camera">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
</svg>
|
|
</Link>
|
|
<Link href="/create" className="hover:text-primary" aria-label="Create post" title="Create post">
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
|
|
</svg>
|
|
</Link>
|
|
<Link
|
|
href={`/profile/${user?.username}`}
|
|
className="hover:text-primary"
|
|
aria-label="Your profile"
|
|
title="Your profile"
|
|
>
|
|
<div className="w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center">
|
|
{user?.avatar ? (
|
|
<img src={user.avatar} alt="" className="w-full h-full rounded-full object-cover" />
|
|
) : (
|
|
<span className="text-sm font-semibold" aria-hidden="true">{user?.username?.[0]?.toUpperCase()}</span>
|
|
)}
|
|
</div>
|
|
</Link>
|
|
<button
|
|
onClick={handleLogout}
|
|
className="hover:text-primary"
|
|
aria-label="Log out"
|
|
title="Log out"
|
|
>
|
|
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
)
|
|
}
|