User Settings: - Add /api/user/settings endpoint for persisting theme and fontSize preferences - Update settings page with working save functionality - Add validation and localized error messages Reading Plans: - Add database schema with ReadingPlan, UserReadingPlan, and UserReadingProgress models - Create CRUD API endpoints for reading plans and progress tracking - Build UI for browsing available plans and managing user enrollments - Implement progress tracking with daily reading schedule - Add streak calculation and statistics display - Create seed data with 5 predefined plans (Bible in 1 year, 90 days, NT 30 days, Psalms 30, Gospels 30) - Add navigation link with internationalization support Technical: - Update to MUI v7 Grid API (using size prop instead of xs/sm/md and removing item prop) - Fix Next.js 15 dynamic route params (await params pattern) - Add translations for readingPlans in all languages (en, ro, es, it) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { prisma } from '@/lib/db'
|
|
|
|
export const runtime = 'nodejs'
|
|
|
|
/**
|
|
* GET /api/reading-plans
|
|
* Get all available predefined reading plans
|
|
*/
|
|
export async function GET(request: Request) {
|
|
try {
|
|
const url = new URL(request.url)
|
|
const language = url.searchParams.get('language') || 'en'
|
|
|
|
const plans = await prisma.readingPlan.findMany({
|
|
where: {
|
|
isActive: true,
|
|
type: 'PREDEFINED',
|
|
language: language
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
description: true,
|
|
duration: true,
|
|
difficulty: true,
|
|
language: true,
|
|
type: true,
|
|
createdAt: true
|
|
},
|
|
orderBy: {
|
|
duration: 'asc'
|
|
}
|
|
})
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
plans
|
|
})
|
|
|
|
} catch (error) {
|
|
console.error('Reading plans fetch error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch reading plans' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|