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>
189 lines
5.0 KiB
TypeScript
189 lines
5.0 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
import Image from 'next/image'
|
|
import { useRouter } from 'next/navigation'
|
|
import api from '@/services/api'
|
|
import { useToast } from '@/components/ui/toast'
|
|
|
|
export default function CreateHighlightPage() {
|
|
const router = useRouter()
|
|
const { showToast } = useToast()
|
|
const [name, setName] = useState('')
|
|
const [coverImage, setCoverImage] = useState<File | null>(null)
|
|
const [storyIds, setStoryIds] = useState<string[]>([])
|
|
const [archives, setArchives] = useState<any[]>([])
|
|
const [loadingArchives, setLoadingArchives] = useState(true)
|
|
const [creating, setCreating] = useState(false)
|
|
|
|
useEffect(() => {
|
|
loadArchives()
|
|
}, [])
|
|
|
|
const loadArchives = async () => {
|
|
try {
|
|
const response = await api.get('/v1/stories/archives')
|
|
setArchives(response.data.archives || [])
|
|
} catch (error) {
|
|
console.error('Load archived stories error:', error)
|
|
showToast('Failed to load archived stories', 'error')
|
|
} finally {
|
|
setLoadingArchives(false)
|
|
}
|
|
}
|
|
|
|
const toggleArchive = (archiveId: string) => {
|
|
setStoryIds((prev) =>
|
|
prev.includes(archiveId)
|
|
? prev.filter((id) => id !== archiveId)
|
|
: [...prev, archiveId]
|
|
)
|
|
}
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault()
|
|
if (!name.trim()) {
|
|
showToast('Please enter a highlight name', 'warning')
|
|
return
|
|
}
|
|
if (storyIds.length === 0) {
|
|
showToast('Select at least one archived story', 'warning')
|
|
return
|
|
}
|
|
|
|
setCreating(true)
|
|
try {
|
|
const formData = new FormData()
|
|
formData.append('name', name.trim())
|
|
if (coverImage) formData.append('coverImage', coverImage)
|
|
storyIds.forEach((id) => formData.append('storyIds', id))
|
|
|
|
await api.post('/v1/stories/highlights', formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
router.push('/story/highlights')
|
|
} catch (error) {
|
|
console.error('Create highlight error:', error)
|
|
showToast('Failed to create highlight', 'error')
|
|
} finally {
|
|
setCreating(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
<div className="max-w-3xl mx-auto py-8 px-4">
|
|
<h1 className="text-2xl font-bold text-foreground mb-6">Create Highlight</h1>
|
|
|
|
<form onSubmit={handleSubmit} className="space-y-6">
|
|
<div>
|
|
<label className="block text-sm font-medium text-foreground mb-2">
|
|
Name *
|
|
</label>
|
|
<input
|
|
type="text"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
required
|
|
className="w-full px-4 py-2 bg-surface border border-border rounded-lg text-foreground focus:outline-none focus:ring-2 focus:ring-accent"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<label className="block text-sm font-medium text-foreground mb-2">
|
|
Cover Image
|
|
</label>
|
|
<input
|
|
type="file"
|
|
accept="image/*"
|
|
onChange={(e) => setCoverImage(e.target.files?.[0] || null)}
|
|
className="w-full px-4 py-2 bg-surface border border-border rounded-lg text-foreground focus:outline-none focus:ring-2 focus:ring-accent"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<div className="mb-2 flex items-center justify-between">
|
|
<label className="block text-sm font-medium text-foreground">
|
|
Archived Stories *
|
|
</label>
|
|
<span className="text-xs text-foreground/60">{storyIds.length} selected</span>
|
|
</div>
|
|
|
|
{loadingArchives ? (
|
|
<div className="rounded-lg border border-border bg-surface p-4 text-sm text-foreground/70">
|
|
Loading archived stories...
|
|
</div>
|
|
) : archives.length === 0 ? (
|
|
<div className="rounded-lg border border-border bg-surface p-4 text-sm text-foreground/70">
|
|
You do not have any archived stories yet.
|
|
</div>
|
|
) : (
|
|
<div className="grid grid-cols-2 md:grid-cols-3 gap-3">
|
|
{archives.map((archive) => {
|
|
const selected = storyIds.includes(archive.id)
|
|
return (
|
|
<button
|
|
key={archive.id}
|
|
type="button"
|
|
onClick={() => toggleArchive(archive.id)}
|
|
className={`relative aspect-[9/16] overflow-hidden rounded-lg border ${
|
|
selected ? 'border-accent ring-2 ring-accent/40' : 'border-border'
|
|
}`}
|
|
>
|
|
{archive.mediaUrl && archive.mediaType === 'image' ? (
|
|
<Image
|
|
src={archive.mediaUrl}
|
|
alt={archive.caption || 'Archived story'}
|
|
fill
|
|
className="object-cover"
|
|
/>
|
|
) : (
|
|
<div className="flex h-full w-full items-center justify-center bg-black/80 text-white text-sm font-semibold">
|
|
Video Archive
|
|
</div>
|
|
)}
|
|
<div className="absolute inset-x-0 bottom-0 bg-black/60 p-2 text-left">
|
|
<p className="line-clamp-2 text-xs text-white">
|
|
{archive.caption || 'Archived story'}
|
|
</p>
|
|
</div>
|
|
<div className="absolute right-2 top-2">
|
|
<div
|
|
className={`flex h-6 w-6 items-center justify-center rounded-full text-xs font-bold ${
|
|
selected ? 'bg-accent text-white' : 'bg-white/90 text-black'
|
|
}`}
|
|
>
|
|
{selected ? '' : '+'}
|
|
</div>
|
|
</div>
|
|
</button>
|
|
)
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
<div className="flex gap-4">
|
|
<button
|
|
type="submit"
|
|
disabled={creating}
|
|
className="px-6 py-2 bg-accent text-white rounded-lg font-semibold hover:opacity-90 disabled:opacity-50"
|
|
>
|
|
{creating ? 'Creating...' : 'Create Highlight'}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => router.back()}
|
|
className="px-6 py-2 bg-surface border border-border rounded-lg text-foreground hover:bg-surface/80"
|
|
>
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|