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>
97 lines
2.9 KiB
TypeScript
97 lines
2.9 KiB
TypeScript
'use client'
|
|
import { useEffect, useState } from 'react'
|
|
import { useRouter } from 'next/navigation'
|
|
import { useAuthStore } from '@/store/authStore'
|
|
import { githubService } from '@/services/githubService'
|
|
import { useToast } from '@/components/ui/toast'
|
|
|
|
export default function ProjectsPage() {
|
|
const router = useRouter()
|
|
const { isAuthenticated, user } = useAuthStore()
|
|
const { showToast } = useToast()
|
|
const [projects, setProjects] = useState<any[]>([])
|
|
const [loading, setLoading] = useState(true)
|
|
const [syncing, setSyncing] = useState(false)
|
|
|
|
useEffect(() => {
|
|
if (!isAuthenticated) { router.push('/login'); return }
|
|
loadProjects()
|
|
}, [isAuthenticated])
|
|
|
|
const loadProjects = async () => {
|
|
try {
|
|
const data = await githubService.getProjects()
|
|
setProjects(data.projects || data)
|
|
} catch (error) {
|
|
showToast('Failed to load projects', 'error')
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
const handleSync = async () => {
|
|
setSyncing(true)
|
|
try {
|
|
await githubService.syncProjects()
|
|
await loadProjects()
|
|
showToast('Projects synced! ', 'success')
|
|
} catch (error) {
|
|
showToast('Failed to sync projects', 'error')
|
|
} finally {
|
|
setSyncing(false)
|
|
}
|
|
}
|
|
|
|
const handleConnect = () => {
|
|
githubService.connectGitHub()
|
|
}
|
|
|
|
if (!isAuthenticated) return null
|
|
|
|
if (!user?.githubUsername) {
|
|
return (
|
|
<div className="max-w-4xl mx-auto py-16 px-4 text-center">
|
|
<div className="text-6xl mb-6"></div>
|
|
<h1 className="text-4xl font-bold mb-4">Connect GitHub</h1>
|
|
<p className="text-xl text-muted mb-8">Connect your GitHub account to share your projects and engage with the community.</p>
|
|
<button onClick={handleConnect} className="px-8 py-4 bg-primary text-white rounded-lg hover:bg-primary/90 text-lg font-semibold">
|
|
Connect GitHub Account
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="max-w-6xl mx-auto py-8 px-4">
|
|
<div className="flex items-center justify-between mb-8">
|
|
<h1 className="text-3xl font-bold">My Projects</h1>
|
|
<button onClick={handleSync} disabled={syncing} className="px-6 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 disabled:opacity-50">
|
|
{syncing ? 'Syncing...' : ' Sync Projects'}
|
|
</button>
|
|
</div>
|
|
|
|
{loading ? (
|
|
<div className="text-center py-12">Loading projects...</div>
|
|
) : projects.length === 0 ? (
|
|
<div className="text-center py-12 text-muted">
|
|
<p className="mb-4">No projects found. Click "Sync Projects" to import from GitHub.</p>
|
|
</div>
|
|
) : (
|
|
<div className="grid grid-cols-2 gap-4">
|
|
{projects.map(p => (
|
|
<div key={p.id} onClick={() => router.push(`/project/${p.owner}/${p.name}`)} className="p-6 bg-card border border-border rounded-lg hover:bg-muted/50 cursor-pointer">
|
|
<h3 className="text-xl font-bold mb-2">{p.name}</h3>
|
|
<p className="text-sm text-muted mb-4">{p.description || 'No description'}</p>
|
|
<div className="flex items-center gap-4 text-sm text-muted">
|
|
<span> {p.stars || 0}</span>
|
|
<span> {p.forks || 0}</span>
|
|
<span>{p.language}</span>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|