1f60f1c908
- Add Course and Module models to Prisma schema - Create seed-learn.json with Daily Fiqh for Beginners (5 modules) - Create seed-learn.js with Hermes patch (strip id/courseId from create) - Add /learn page with course listing - Add /learn/[courseSlug]/[moduleId] page with content + quiz - Quiz data stored as JSON string per module - Content rendered as markdown with Key Concept, Details, Reflection, Action Step sections TODO: - Add audio player component for listen toggle - Add progress tracking per user - Add actual quiz scoring/validation - Connect to TTS pipeline for audio generation
55 lines
3.1 KiB
TypeScript
55 lines
3.1 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { prisma } from '@/lib/prisma'
|
|
import bcrypt from 'bcryptjs'
|
|
|
|
export async function POST() {
|
|
try {
|
|
const password = await bcrypt.hash('password123', 10)
|
|
|
|
const userData = [
|
|
{ email: 'ghazali@falahos.my', name: 'Abu Hamid Al-Ghazali', password, flhBalance: 5000 },
|
|
{ email: 'ibnabbas@falahos.my', name: 'Abdullah Ibn Abbas', password, flhBalance: 3000 },
|
|
{ email: 'rabia@falahos.my', name: "Rabi'a Al-Adawiyya", password, flhBalance: 2000 },
|
|
{ email: 'demo@falahos.my', name: 'Demo User', password, flhBalance: 500 },
|
|
]
|
|
|
|
const users: any[] = []
|
|
for (const u of userData) {
|
|
let user = await prisma.user.findUnique({ where: { email: u.email } })
|
|
if (!user) {
|
|
user = await prisma.user.create({ data: u })
|
|
}
|
|
users.push(user)
|
|
}
|
|
|
|
const listings = [
|
|
{ title: 'Digital Quran Study Planner', description: 'Comprehensive digital planner for Quran memorization tracking with daily logs and revision schedules.', category: 'E-Books', priceFlh: 150, sellerId: users[0].id },
|
|
{ title: 'Islamic Art Calligraphy Print', description: 'Beautiful "Bismillah" calligraphy print, handmade. High-quality 300gsm paper, A3 size.', category: 'Design', priceFlh: 250, sellerId: users[1].id },
|
|
{ title: 'Online Arabic Course - Beginner', description: '12-week structured Arabic course with weekly live sessions, worksheets, and community support.', category: 'Courses', priceFlh: 500, sellerId: users[2].id },
|
|
{ title: 'Halal Snack Box - Monthly Subscription', description: 'Curated box of halal-certified snacks delivered monthly. International treats included.', category: 'Other', priceFlh: 80, sellerId: users[3].id },
|
|
{ title: 'Digital Dhikr Counter App', description: 'Beautiful dhikr counter with daily adhkar tracking, goals, and badges.', category: 'Software', priceFlh: 30, sellerId: users[0].id },
|
|
{ title: 'Handcrafted Tasbih (Prayer Beads)', description: 'Premium olive wood tasbih, 33 beads with tassel. Handcrafted by artisans. Gift box included.', category: 'Other', priceFlh: 120, sellerId: users[1].id },
|
|
{ title: 'Islamic Parenting E-Book Bundle', description: '5 e-books on raising righteous children: discipline, faith, education, screen time, character.', category: 'E-Books', priceFlh: 45, sellerId: users[2].id },
|
|
{ title: 'Tajweed Mastery Video Course', description: 'Complete Tajweed rules with 20 video lessons, practice exercises, and progress quizzes.', category: 'Courses', priceFlh: 350, sellerId: users[0].id },
|
|
]
|
|
|
|
let created = 0
|
|
for (const l of listings) {
|
|
const existing = await prisma.listing.findFirst({ where: { title: l.title } })
|
|
if (!existing) {
|
|
await prisma.listing.create({ data: l })
|
|
created++
|
|
}
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: `Seeded: ${users.length} users, ${created} new listings`,
|
|
users: users.length,
|
|
listingsCreated: created,
|
|
})
|
|
} catch (e: any) {
|
|
return NextResponse.json({ error: e.message }, { status: 500 })
|
|
}
|
|
}
|