caelum0x aa848c66d0 fix(ritgram): Apple-design unslop pass + Rithub OAuth2 sign-in + critical login-redirect-loop fix
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>
2026-11-17 17:33:41 +03:00

112 lines
2.8 KiB
TypeScript

import Link from 'next/link'
import type { ReactNode } from 'react'
interface EmptyStateAction {
label: string
href?: string
onClick?: () => void
}
interface EmptyStateProps {
/** Emoji string or any custom node (e.g. an SVG icon). */
icon?: ReactNode
title: string
description?: string
action?: EmptyStateAction
}
export default function EmptyState({ icon = '', title, description, action }: EmptyStateProps) {
return (
<div className="flex flex-col items-center justify-center px-4 py-16 text-center">
<div className="mb-4 flex h-20 w-20 items-center justify-center rounded-full bg-[var(--surface)] text-4xl ring-1 ring-[var(--border)]">
{icon}
</div>
<h3 className="mb-2 text-xl font-semibold text-[var(--foreground)]">{title}</h3>
{description && (
<p className="mb-6 max-w-sm text-[var(--foreground-secondary)]">{description}</p>
)}
{action && <EmptyStateActionButton action={action} />}
</div>
)
}
function EmptyStateActionButton({ action }: { action: EmptyStateAction }) {
const className =
'inline-flex items-center justify-center rounded-lg bg-[var(--primary)] px-6 py-2.5 font-semibold text-white transition-opacity hover:opacity-90'
if (action.href) {
return (
<Link href={action.href} className={className}>
{action.label}
</Link>
)
}
return (
<button type="button" onClick={action.onClick} className={className}>
{action.label}
</button>
)
}
/* ---------------------------------------------------------------------------
* Preset variants for common zero-states.
* ------------------------------------------------------------------------- */
export function EmptyFeed({ action }: { action?: EmptyStateAction }) {
return (
<EmptyState
icon=""
title="Your feed is empty"
description="Follow developers and repositories to start seeing posts in your timeline."
action={action ?? { label: 'Explore', href: '/explore' }}
/>
)
}
export function EmptySearch({ query }: { query?: string }) {
return (
<EmptyState
icon=""
title="No results found"
description={
query
? `We couldn't find anything matching "${query}". Try a different search.`
: 'Try a different search term.'
}
/>
)
}
export function EmptyNotifications() {
return (
<EmptyState
icon=""
title="You're all caught up"
description="New likes, comments, and follows will show up here."
/>
)
}
export function EmptyMessages({ action }: { action?: EmptyStateAction }) {
return (
<EmptyState
icon=""
title="No conversations yet"
description="Start a conversation with a developer you follow."
action={action}
/>
)
}
export function EmptyRepos({ action }: { action?: EmptyStateAction }) {
return (
<EmptyState
icon=""
title="No repositories yet"
description="Connect your GitHub account to showcase your repositories."
action={action ?? { label: 'Connect GitHub', href: '/settings' }}
/>
)
}