✨ Major Features Added: - AI Chat with conversation memory and university-specific knowledge base - Multi-tenant university support with white-label capabilities - Professional admin interface for knowledge base management - Advanced database schema with Prisma ORM - Comprehensive documentation and guides - Modern Next.js 15 + React 19 architecture - Bilingual support (English/Arabic) - Role-based access control - Real-time chat interface with loading states 🔧 Technical Improvements: - Fixed all linter errors and TypeScript issues - Cleaned up codebase and removed legacy files - Added comprehensive .gitignore - Updated README with detailed setup instructions - Optimized database schema and migrations - Enhanced error handling and user experience 📚 Documentation: - AI Conversation Memory Guide - AI Enhancement Summary - Developer Guide - User Guide - Complete setup and deployment instructions 🚀 Ready for GitHub deployment and production use!
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/prisma';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const content = await prisma.UniversityContent.findMany({
|
|
orderBy: { createdAt: 'desc' },
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: content,
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching content:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch content' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const body = await request.json();
|
|
const { contentType, title, titleAr, content, contentAr, isPublished } = body;
|
|
|
|
if (!contentType || !title) {
|
|
return NextResponse.json(
|
|
{ error: 'Content type and title are required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
// For now, use a default university ID (you can enhance this later)
|
|
const defaultUniversity = await prisma.University.findFirst();
|
|
if (!defaultUniversity) {
|
|
return NextResponse.json(
|
|
{ error: 'No university found. Please create a university first.' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const newContent = await prisma.UniversityContent.create({
|
|
data: {
|
|
universityId: defaultUniversity.id,
|
|
contentType,
|
|
title,
|
|
titleAr,
|
|
content,
|
|
contentAr,
|
|
isPublished: isPublished || false,
|
|
metadata: {}
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: newContent,
|
|
message: 'Content created successfully',
|
|
});
|
|
} catch (error) {
|
|
console.error('Error creating content:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to create content' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|