Add comprehensive social media management system and improve admin pages

## Social Media Management System
- Add SocialMediaLink database model with platform, URL, icon, and ordering
- Create complete CRUD API endpoints for admin social media management
- Implement admin social media management page with Material-UI DataGrid
- Add "Social Media" menu item to admin navigation
- Update footer to dynamically load and display enabled social media links
- Support multiple platforms: Facebook, Twitter, Instagram, YouTube, LinkedIn, GitHub, TikTok
- Include proper icon mapping and fallback handling

## Admin Pages Improvements
- Replace broken TinyMCE editor with working WYSIWYG rich text editor
- Create SimpleRichEditor component with toolbar for formatting
- Fix admin authentication to use cookies instead of localStorage tokens
- Update all admin API calls to use credentials: 'include'
- Increase content editor height to 800px for better editing experience
- Add Lexical editor component as alternative (not currently used)

## Footer Pages System
- Create 8 comprehensive footer pages: About, Blog, Support, API Docs, Terms, Privacy, Cookies, GDPR
- Implement dynamic footer link management with smart categorization
- Separate Quick Links and Legal sections with automatic filtering
- Remove duplicate hardcoded links and use database-driven system
- All footer pages are fully written with professional content

## Database & Dependencies
- Add uuid package for ID generation
- Update Prisma schema with new SocialMediaLink model and relations
- Seed default social media links for Facebook, Twitter, Instagram, YouTube
- Add Lexical rich text editor packages (@lexical/react, etc.)

## Technical Improvements
- Fix async params compatibility for Next.js 15
- Update MUI DataGrid deprecated props
- Improve admin layout navigation structure
- Add proper TypeScript interfaces for all new components
- Implement proper error handling and user feedback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-24 12:08:01 +00:00
parent 3b34d7518b
commit 4adf1d286e
17 changed files with 1817 additions and 122 deletions

View File

@@ -0,0 +1,143 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db';
import { verifyAdminAuth } from '@/lib/admin-auth';
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const adminUser = await verifyAdminAuth(request);
if (!adminUser) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { id } = await params;
const socialMediaLink = await prisma.socialMediaLink.findUnique({
where: { id },
include: {
creator: { select: { name: true, email: true } },
updater: { select: { name: true, email: true } }
}
});
if (!socialMediaLink) {
return NextResponse.json(
{ success: false, error: 'Social media link not found' },
{ status: 404 }
);
}
return NextResponse.json({
success: true,
data: socialMediaLink
});
} catch (error) {
console.error('Error fetching social media link:', error);
return NextResponse.json(
{ success: false, error: 'Failed to fetch social media link' },
{ status: 500 }
);
}
}
export async function PUT(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const adminUser = await verifyAdminAuth(request);
if (!adminUser) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { id } = await params;
const body = await request.json();
const {
platform,
name,
url,
icon,
isEnabled,
order
} = body;
if (!platform || !name || !url || !icon) {
return NextResponse.json(
{ success: false, error: 'Platform, name, URL, and icon are required' },
{ status: 400 }
);
}
// Check if another link uses the same platform
const existingLink = await prisma.socialMediaLink.findFirst({
where: {
platform,
id: { not: id }
}
});
if (existingLink) {
return NextResponse.json(
{ success: false, error: 'Another social media link for this platform already exists' },
{ status: 400 }
);
}
const socialMediaLink = await prisma.socialMediaLink.update({
where: { id },
data: {
platform,
name,
url,
icon,
isEnabled,
order,
updatedBy: adminUser.id
},
include: {
creator: { select: { name: true, email: true } },
updater: { select: { name: true, email: true } }
}
});
return NextResponse.json({
success: true,
data: socialMediaLink
});
} catch (error) {
console.error('Error updating social media link:', error);
return NextResponse.json(
{ success: false, error: 'Failed to update social media link' },
{ status: 500 }
);
}
}
export async function DELETE(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const adminUser = await verifyAdminAuth(request);
if (!adminUser) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { id } = await params;
await prisma.socialMediaLink.delete({
where: { id }
});
return NextResponse.json({
success: true,
message: 'Social media link deleted successfully'
});
} catch (error) {
console.error('Error deleting social media link:', error);
return NextResponse.json(
{ success: false, error: 'Failed to delete social media link' },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,97 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db';
import { verifyAdminAuth } from '@/lib/admin-auth';
export async function GET(request: NextRequest) {
try {
const adminUser = await verifyAdminAuth(request);
if (!adminUser) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const socialMediaLinks = await prisma.socialMediaLink.findMany({
orderBy: { order: 'asc' },
include: {
creator: { select: { name: true, email: true } },
updater: { select: { name: true, email: true } }
}
});
return NextResponse.json({
success: true,
data: socialMediaLinks
});
} catch (error) {
console.error('Error fetching social media links:', error);
return NextResponse.json(
{ success: false, error: 'Failed to fetch social media links' },
{ status: 500 }
);
}
}
export async function POST(request: NextRequest) {
try {
const adminUser = await verifyAdminAuth(request);
if (!adminUser) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const body = await request.json();
const {
platform,
name,
url,
icon,
isEnabled = true,
order = 0
} = body;
if (!platform || !name || !url || !icon) {
return NextResponse.json(
{ success: false, error: 'Platform, name, URL, and icon are required' },
{ status: 400 }
);
}
// Check if platform already exists
const existingLink = await prisma.socialMediaLink.findUnique({
where: { platform }
});
if (existingLink) {
return NextResponse.json(
{ success: false, error: 'A social media link for this platform already exists' },
{ status: 400 }
);
}
const socialMediaLink = await prisma.socialMediaLink.create({
data: {
platform,
name,
url,
icon,
isEnabled,
order,
createdBy: adminUser.id,
updatedBy: adminUser.id
},
include: {
creator: { select: { name: true, email: true } },
updater: { select: { name: true, email: true } }
}
});
return NextResponse.json({
success: true,
data: socialMediaLink
});
} catch (error) {
console.error('Error creating social media link:', error);
return NextResponse.json(
{ success: false, error: 'Failed to create social media link' },
{ status: 500 }
);
}
}

View File

@@ -16,11 +16,10 @@ export async function GET(request: Request) {
let bibleVersion
const langCandidates = Array.from(new Set([locale, locale.toLowerCase(), locale.toUpperCase()]))
if (versionId) {
// Use specific version if provided
// Use specific version if provided (no language filter needed)
bibleVersion = await prisma.bibleVersion.findFirst({
where: {
id: versionId,
language: { in: langCandidates }
id: versionId
}
})
} else {

View File

@@ -7,12 +7,18 @@ export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url)
const locale = (searchParams.get('locale') || 'ro').toLowerCase()
const showAll = searchParams.get('all') === 'true'
const langCandidates = Array.from(new Set([locale, locale.toLowerCase(), locale.toUpperCase()]))
let whereClause = {}
if (!showAll) {
const langCandidates = Array.from(new Set([locale, locale.toLowerCase(), locale.toUpperCase()]))
whereClause = { language: { in: langCandidates } }
}
const versions = await prisma.bibleVersion.findMany({
where: { language: { in: langCandidates } },
orderBy: [{ isDefault: 'desc' }, { name: 'asc' }]
where: whereClause,
orderBy: [{ isDefault: 'desc' }, { language: 'asc' }, { name: 'asc' }]
})
return NextResponse.json({

View File

@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/db';
export async function GET(request: NextRequest) {
try {
const socialMediaLinks = await prisma.socialMediaLink.findMany({
where: { isEnabled: true },
orderBy: { order: 'asc' },
select: {
id: true,
platform: true,
name: true,
url: true,
icon: true,
order: true
}
});
return NextResponse.json({
success: true,
data: socialMediaLinks
});
} catch (error) {
console.error('Error fetching social media links:', error);
return NextResponse.json(
{ success: false, error: 'Failed to fetch social media links' },
{ status: 500 }
);
}
}