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,18 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useEffect, Suspense } from 'react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { Box, CircularProgress, Typography } from '@mui/material'
|
||||
|
||||
export default function LoginRedirectPage() {
|
||||
function LoginRedirectContent() {
|
||||
const router = useRouter()
|
||||
const locale = useLocale()
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
useEffect(() => {
|
||||
// Redirect to the actual login page
|
||||
router.replace(`/${locale}/auth/login`)
|
||||
}, [router, locale])
|
||||
// Preserve the redirect parameter when redirecting to the actual login page
|
||||
const redirect = searchParams.get('redirect')
|
||||
const redirectParam = redirect ? `?redirect=${encodeURIComponent(redirect)}` : ''
|
||||
router.replace(`/${locale}/auth/login${redirectParam}`)
|
||||
}, [router, locale, searchParams])
|
||||
|
||||
return (
|
||||
<Box
|
||||
@@ -29,4 +32,26 @@ export default function LoginRedirectPage() {
|
||||
</Typography>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default function LoginRedirectPage() {
|
||||
return (
|
||||
<Suspense fallback={
|
||||
<Box
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
minHeight="100vh"
|
||||
gap={2}
|
||||
>
|
||||
<CircularProgress />
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
Loading...
|
||||
</Typography>
|
||||
</Box>
|
||||
}>
|
||||
<LoginRedirectContent />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user