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>
196 lines
7.5 KiB
TypeScript
196 lines
7.5 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
import { useRouter } from 'next/navigation'
|
|
import Link from 'next/link'
|
|
import { useAuthStore } from '@/store/authStore'
|
|
import { useToast } from '@/components/ui/toast'
|
|
import { reelDraftService, ReelDraft } from '@/services/reelDraftService'
|
|
|
|
function formatDate(dateString: string): string {
|
|
const date = new Date(dateString)
|
|
const diffMs = Date.now() - date.getTime()
|
|
const diffMins = Math.floor(diffMs / 60000)
|
|
const diffHours = Math.floor(diffMs / 3600000)
|
|
const diffDays = Math.floor(diffMs / 86400000)
|
|
if (diffMins < 1) return 'Just now'
|
|
if (diffMins < 60) return `${diffMins}m ago`
|
|
if (diffHours < 24) return `${diffHours}h ago`
|
|
if (diffDays < 7) return `${diffDays}d ago`
|
|
return date.toLocaleDateString()
|
|
}
|
|
|
|
function DraftSkeleton() {
|
|
return (
|
|
<div
|
|
className="p-4 rounded-xl border animate-pulse"
|
|
style={{ background: '#1A1A2E', borderColor: 'rgba(124,58,237,0.1)' }}
|
|
>
|
|
<div className="flex justify-between mb-3">
|
|
<div className="h-4 w-40 rounded" style={{ background: '#2A2A3E' }} />
|
|
<div className="h-3 w-16 rounded" style={{ background: '#2A2A3E' }} />
|
|
</div>
|
|
<div className="h-2.5 w-full rounded mb-1.5" style={{ background: '#2A2A3E' }} />
|
|
<div className="h-2.5 w-3/4 rounded" style={{ background: '#2A2A3E' }} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default function ReelDraftsPage() {
|
|
const router = useRouter()
|
|
const { isAuthenticated, isInitialized } = useAuthStore()
|
|
const { showToast } = useToast()
|
|
|
|
const [drafts, setDrafts] = useState<ReelDraft[]>([])
|
|
const [loading, setLoading] = useState(true)
|
|
const [deletingId, setDeletingId] = useState<string | null>(null)
|
|
|
|
useEffect(() => {
|
|
if (!isInitialized) return
|
|
if (!isAuthenticated) {
|
|
router.push('/login')
|
|
return
|
|
}
|
|
setDrafts(reelDraftService.list())
|
|
setLoading(false)
|
|
}, [isInitialized, isAuthenticated, router])
|
|
|
|
const handleDelete = (id: string) => {
|
|
setDeletingId(id)
|
|
try {
|
|
reelDraftService.remove(id)
|
|
setDrafts((prev) => prev.filter((d) => d.id !== id))
|
|
showToast('Draft deleted', 'info')
|
|
} catch {
|
|
showToast('Failed to delete draft', 'error')
|
|
} finally {
|
|
setDeletingId(null)
|
|
}
|
|
}
|
|
|
|
const handleEdit = (id: string) => {
|
|
router.push(`/reels/create?draftId=${id}`)
|
|
}
|
|
|
|
if (!isInitialized) return null
|
|
if (!isAuthenticated) return null
|
|
|
|
return (
|
|
<div className="min-h-screen" style={{ background: '#0F0F1A' }}>
|
|
<div className="max-w-2xl mx-auto py-8 px-4">
|
|
<div className="flex items-center gap-4 mb-8">
|
|
<button
|
|
onClick={() => router.back()}
|
|
className="p-2 rounded-lg transition-colors"
|
|
style={{ color: '#98989d' }}
|
|
aria-label="Go back"
|
|
>
|
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
|
</svg>
|
|
</button>
|
|
<h1 className="text-2xl font-bold text-foreground">Reel Drafts</h1>
|
|
{!loading && drafts.length > 0 && (
|
|
<span
|
|
className="px-2 py-1 text-xs rounded-full"
|
|
style={{ background: 'rgba(124,58,237,0.15)', color: '#a78bfa' }}
|
|
>
|
|
{drafts.length}
|
|
</span>
|
|
)}
|
|
<Link
|
|
href="/reels/create"
|
|
className="ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-semibold text-white"
|
|
style={{ background: 'var(--primary)' }}
|
|
>
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
|
|
</svg>
|
|
New Reel
|
|
</Link>
|
|
</div>
|
|
|
|
{loading ? (
|
|
<div className="space-y-4">
|
|
{Array.from({ length: 3 }).map((_, i) => (
|
|
<DraftSkeleton key={i} />
|
|
))}
|
|
</div>
|
|
) : drafts.length === 0 ? (
|
|
<div className="text-center py-16">
|
|
<div
|
|
className="w-20 h-20 mx-auto mb-4 rounded-full flex items-center justify-center"
|
|
style={{ background: 'rgba(124,58,237,0.12)' }}
|
|
>
|
|
<svg className="w-10 h-10" fill="none" stroke="var(--primary)" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M15 10l4.553-2.069A1 1 0 0121 8.882v6.236a1 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>
|
|
</div>
|
|
<h2 className="text-xl font-semibold text-foreground mb-2">No reel drafts</h2>
|
|
<p className="text-sm text-foreground-secondary mb-4">
|
|
Reels you save while composing will appear here.
|
|
</p>
|
|
<Link
|
|
href="/reels/create"
|
|
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold text-white"
|
|
style={{ background: 'var(--primary)' }}
|
|
>
|
|
Create a Reel
|
|
</Link>
|
|
</div>
|
|
) : (
|
|
<div className="space-y-4">
|
|
{drafts.map((draft) => (
|
|
<div
|
|
key={draft.id}
|
|
className="p-4 rounded-xl border"
|
|
style={{ background: '#1A1A2E', borderColor: 'rgba(124,58,237,0.15)' }}
|
|
>
|
|
<div className="flex justify-between items-start mb-3 gap-3">
|
|
<div className="min-w-0">
|
|
<h3 className="text-sm font-semibold text-foreground truncate">
|
|
{draft.title.trim() || '(Untitled reel)'}
|
|
</h3>
|
|
<p className="text-xs text-foreground-secondary mt-0.5">
|
|
{draft.language} · Edited {formatDate(draft.updatedAt)}
|
|
</p>
|
|
</div>
|
|
<button
|
|
onClick={() => handleDelete(draft.id)}
|
|
disabled={deletingId === draft.id}
|
|
className="p-2 rounded-lg transition-colors disabled:opacity-50"
|
|
style={{ color: '#ff453a' }}
|
|
title="Delete draft"
|
|
aria-label="Delete draft"
|
|
>
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
{draft.code.trim() && (
|
|
<pre
|
|
className="px-3 py-2.5 text-xs font-mono overflow-hidden leading-5 rounded-lg mb-3"
|
|
style={{ color: '#98989d', background: 'rgba(0,0,0,0.3)' }}
|
|
>
|
|
{draft.code.split('\n').slice(0, 3).join('\n')}
|
|
</pre>
|
|
)}
|
|
|
|
<button
|
|
onClick={() => handleEdit(draft.id)}
|
|
className="w-full py-2 rounded-lg text-sm font-semibold text-white"
|
|
style={{ background: 'var(--primary)' }}
|
|
>
|
|
Continue Editing
|
|
</button>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|