Fix Edge-incompatible middleware; set Node runtime on Prisma/pg routes; add full Romanian Bible import + converter; import data JSON; resync RO bookKeys; stabilize /api/bible/books locale fallback; restart dev server.

This commit is contained in:
andupetcu
2025-09-20 18:01:04 +03:00
parent 500066450d
commit 88b251c100
28 changed files with 127926 additions and 175 deletions

View File

@@ -30,6 +30,7 @@ import {
Share,
} from '@mui/icons-material'
import { useState, useEffect } from 'react'
import { useTranslations, useLocale } from 'next-intl'
interface BibleVerse {
id: string
@@ -44,26 +45,33 @@ interface BibleChapter {
}
interface BibleBook {
id: number
id: string
name: string
testament: string
orderNum: number
bookKey: string
chapters: BibleChapter[]
}
export default function BiblePage() {
const theme = useTheme()
const t = useTranslations('pages.bible')
const locale = useLocale()
const [books, setBooks] = useState<BibleBook[]>([])
const [selectedBook, setSelectedBook] = useState<number>(1)
const [selectedBook, setSelectedBook] = useState<string>('')
const [selectedChapter, setSelectedChapter] = useState<number>(1)
const [verses, setVerses] = useState<BibleVerse[]>([])
const [loading, setLoading] = useState(true)
// Fetch available books
useEffect(() => {
fetch('/api/bible/books')
fetch(`/api/bible/books?locale=${locale}`)
.then(res => res.json())
.then(data => {
setBooks(data.books || [])
if (data.books && data.books.length > 0) {
setSelectedBook(data.books[0].id)
}
setLoading(false)
})
.catch(err => {
@@ -120,7 +128,7 @@ export default function BiblePage() {
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }}>
<CircularProgress size={48} />
<Typography variant="h6" color="text.secondary">
Se încarcă cărțile...
{t('loading')}
</Typography>
</Box>
</Container>
@@ -136,10 +144,10 @@ export default function BiblePage() {
<Box sx={{ mb: 4, textAlign: 'center' }}>
<Typography variant="h3" component="h1" gutterBottom>
<MenuBook sx={{ fontSize: 40, mr: 2, verticalAlign: 'middle' }} />
Citește Biblia
{t('title')}
</Typography>
<Typography variant="body1" color="text.secondary">
Explorează Scriptura cu o interfață modernă și intuitivă
{t('subtitle')}
</Typography>
</Box>
@@ -149,16 +157,16 @@ export default function BiblePage() {
<Card>
<CardContent>
<Typography variant="h6" gutterBottom>
Selectează cartea
{t('selectBook')}
</Typography>
<FormControl fullWidth sx={{ mb: 2 }}>
<InputLabel>Cartea</InputLabel>
<InputLabel>{t('book')}</InputLabel>
<Select
value={selectedBook}
label="Cartea"
label={t('book')}
onChange={(e) => {
setSelectedBook(Number(e.target.value))
setSelectedBook(e.target.value)
setSelectedChapter(1)
}}
>
@@ -171,15 +179,15 @@ export default function BiblePage() {
</FormControl>
<FormControl fullWidth>
<InputLabel>Capitolul</InputLabel>
<InputLabel>{t('chapter')}</InputLabel>
<Select
value={selectedChapter}
label="Capitolul"
label={t('chapter')}
onChange={(e) => setSelectedChapter(Number(e.target.value))}
>
{Array.from({ length: maxChapters }, (_, i) => (
<MenuItem key={i + 1} value={i + 1}>
Capitolul {i + 1}
{t('chapter')} {i + 1}
</MenuItem>
))}
</Select>
@@ -208,7 +216,7 @@ export default function BiblePage() {
{currentBook?.name || 'Geneza'} {selectedChapter}
</Typography>
<Typography variant="body2" color="text.secondary">
{verses.length} versete
{verses.length} {t('verses')}
</Typography>
</Box>
@@ -218,14 +226,14 @@ export default function BiblePage() {
variant="outlined"
size="small"
>
Salvează
{t('save')}
</Button>
<Button
startIcon={<Share />}
variant="outlined"
size="small"
>
Partajează
{t('share')}
</Button>
</Box>
</Box>
@@ -280,7 +288,7 @@ export default function BiblePage() {
</Box>
) : (
<Typography textAlign="center" color="text.secondary">
Nu s-au găsit versete pentru această selecție.
{t('noVerses')}
</Typography>
)}
@@ -291,7 +299,7 @@ export default function BiblePage() {
onClick={handlePreviousChapter}
disabled={selectedBook === 1 && selectedChapter === 1}
>
Capitolul anterior
{t('previousChapter')}
</Button>
<Typography variant="body2" color="text.secondary" sx={{ alignSelf: 'center' }}>
@@ -303,7 +311,7 @@ export default function BiblePage() {
onClick={handleNextChapter}
disabled={selectedBook === books.length && selectedChapter === maxChapters}
>
Capitolul următor
{t('nextChapter')}
</Button>
</Box>
</CardContent>