diff --git a/app/[locale]/auth/login/page.tsx b/app/[locale]/auth/login/page.tsx
index f39d7f3..7f2fcd4 100644
--- a/app/[locale]/auth/login/page.tsx
+++ b/app/[locale]/auth/login/page.tsx
@@ -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() {
)
+}
+
+export default function AuthPage() {
+ return (
+
+
+
+
+
+ }>
+
+
+ )
}
\ No newline at end of file
diff --git a/app/[locale]/bible/reader.tsx b/app/[locale]/bible/reader.tsx
index f9fca6e..2b7c443 100644
--- a/app/[locale]/bible/reader.tsx
+++ b/app/[locale]/bible/reader.tsx
@@ -68,7 +68,8 @@ import {
ExpandMore,
MenuBook,
Visibility,
- Speed
+ Speed,
+ Chat
} from '@mui/icons-material'
interface BibleVerse {
@@ -664,11 +665,32 @@ export default function BibleReaderNew() {
navigator.clipboard.writeText(text).then(() => {
setCopyFeedback({
open: true,
- message: t('bible.copied')
+ message: t('copied')
})
})
}
+ const handleVerseChat = (verse: BibleVerse) => {
+ // If user is not authenticated, redirect to login
+ if (!user) {
+ router.push(`/${locale}/login?redirect=${encodeURIComponent(`/${locale}/bible?version=${selectedVersion}&book=${selectedBook}&chapter=${selectedChapter}&verse=${verse.verseNum}`)}`)
+ return
+ }
+
+ const versionName = versions.find(v => v.id === selectedVersion)?.name || selectedVersion
+ const bookName = currentBook?.name || 'Unknown Book'
+
+ const initialMessage = `Explain in depth this verse "${verse.text}" from ${versionName}, ${bookName} ${selectedChapter}:${verse.verseNum} and its meaning`
+
+ // Dispatch event to open floating chat with the pre-filled message
+ window.dispatchEvent(new CustomEvent('floating-chat:open', {
+ detail: {
+ initialMessage: initialMessage,
+ fullscreen: false
+ }
+ }))
+ }
+
const getThemeStyles = () => {
switch (preferences.theme) {
case 'dark':
@@ -765,6 +787,13 @@ export default function BibleReaderNew() {
>
+ handleVerseChat(verse)}
+ sx={{ color: 'action.active' }}
+ >
+
+
)}
diff --git a/app/[locale]/login/page.tsx b/app/[locale]/login/page.tsx
index 342671c..7c06d97 100644
--- a/app/[locale]/login/page.tsx
+++ b/app/[locale]/login/page.tsx
@@ -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 (
)
+}
+
+export default function LoginRedirectPage() {
+ return (
+
+
+
+ Loading...
+
+
+ }>
+
+
+ )
}
\ No newline at end of file