caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

132 lines
3.9 KiB
TypeScript

'use client'
export const dynamic = 'force-dynamic'
import { Suspense, useState, useEffect } from 'react'
import { useRouter, useSearchParams } from 'next/navigation'
import Link from 'next/link'
import { authService } from '@/services/authService'
import { getErrorMessage } from '@/utils/error'
function ResetPasswordContent() {
const router = useRouter()
const searchParams = useSearchParams()
const token = searchParams.get('token')
const [password, setPassword] = useState('')
const [confirmPassword, setConfirmPassword] = useState('')
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
useEffect(() => {
if (!token) {
router.push('/forgot-password')
}
}, [token, router])
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError('')
if (password !== confirmPassword) {
setError('Passwords do not match')
return
}
if (password.length < 6) {
setError('Password must be at least 6 characters')
return
}
if (!token) return
setLoading(true)
try {
await authService.resetPassword(token, password)
setSuccess(true)
setTimeout(() => {
router.push('/login')
}, 2000)
} catch (err: unknown) {
setError(getErrorMessage(err))
} finally {
setLoading(false)
}
}
if (success) {
return (
<div className="w-full max-w-md mx-auto px-4 py-8 text-center">
<h1 className="text-2xl font-bold text-foreground mb-4">Password Reset</h1>
<p className="text-foreground/70 mb-6">Your password has been reset successfully!</p>
<p className="text-foreground/50">Redirecting to login...</p>
</div>
)
}
return (
<div className="w-full max-w-md mx-auto px-4 py-8">
<h1 className="text-3xl font-bold text-foreground mb-2">Reset Password</h1>
<p className="text-foreground/70 mb-8">Enter your new password</p>
<form onSubmit={handleSubmit} className="space-y-4">
{error && (
<div className="bg-red-500/10 border border-red-500 text-red-500 px-4 py-3 rounded">
{error}
</div>
)}
<div>
<label htmlFor="password" className="block text-sm font-medium text-foreground mb-2">
New Password
</label>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(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 htmlFor="confirmPassword" className="block text-sm font-medium text-foreground mb-2">
Confirm Password
</label>
<input
id="confirmPassword"
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(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>
<button
type="submit"
disabled={loading || !token}
className="w-full bg-accent text-white py-2 px-4 rounded-lg font-semibold hover:opacity-90 disabled:opacity-50"
>
{loading ? 'Resetting...' : 'Reset Password'}
</button>
</form>
<div className="mt-6 text-center">
<Link href="/login" className="text-accent hover:underline">
Back to login
</Link>
</div>
</div>
)
}
export default function ResetPasswordPage() {
return (
<Suspense fallback={<div className="min-h-screen bg-background" />}>
<ResetPasswordContent />
</Suspense>
)
}