Add AI chat feature for verse explanations and fix login redirect handling
Bible Reader Enhancements: - Add chat icon to each verse for AI explanations - Implement handleVerseChat function with pre-filled contextual messages - Chat opens with message: "Explain in depth this verse [text] from [version], [book] [chapter:verse] and its meaning" - Visible to all users, redirects to login for unauthenticated users - Fix copy message translation from 'bible.copied' to 'copied' Login System Improvements: - Fix redirect parameter handling in login pages - Users are now properly redirected to /bible page after successful login - Preserve redirect URL parameters through login flow - Add Suspense boundaries for useSearchParams compliance - Ensure verse/chapter context is maintained after login Technical Changes: - Add Chat icon import from Material-UI - Implement floating chat event dispatch system - Fix Next.js 15 build warnings with proper Suspense wrapping - Maintain existing UX patterns (visible to all, functional for authenticated users) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useState, Suspense } from 'react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { useTranslations, useLocale } from 'next-intl'
|
||||
import {
|
||||
Container,
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
Link,
|
||||
Card,
|
||||
CardContent,
|
||||
Divider
|
||||
Divider,
|
||||
CircularProgress
|
||||
} from '@mui/material'
|
||||
import {
|
||||
MenuBook,
|
||||
@@ -23,14 +24,20 @@ import {
|
||||
import { LoginForm } from '@/components/auth/login-form'
|
||||
import { RegisterForm } from '@/components/auth/register-form'
|
||||
|
||||
export default function AuthPage() {
|
||||
function AuthContent() {
|
||||
const [activeTab, setActiveTab] = useState(0)
|
||||
const router = useRouter()
|
||||
const locale = useLocale()
|
||||
const searchParams = useSearchParams()
|
||||
const t = useTranslations('auth')
|
||||
|
||||
const handleAuthSuccess = () => {
|
||||
router.push(`/${locale}`)
|
||||
const redirect = searchParams.get('redirect')
|
||||
if (redirect) {
|
||||
router.push(redirect)
|
||||
} else {
|
||||
router.push(`/${locale}`)
|
||||
}
|
||||
}
|
||||
|
||||
const handleTabChange = (event: React.SyntheticEvent, newValue: number) => {
|
||||
@@ -130,4 +137,18 @@ export default function AuthPage() {
|
||||
</Card>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default function AuthPage() {
|
||||
return (
|
||||
<Suspense fallback={
|
||||
<Container maxWidth="sm" sx={{ mt: 8 }}>
|
||||
<Box display="flex" justifyContent="center" alignItems="center" minHeight="400px">
|
||||
<CircularProgress />
|
||||
</Box>
|
||||
</Container>
|
||||
}>
|
||||
<AuthContent />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user