Round 25: Substitute Teacher, School Newsletter, Career Guidance, Styling

- Substitute Teacher Management View: pool, absences, assignments, statistics, weekly schedule
- School Newsletter View: editor, templates, distribution, analytics, open/click tracking
- Student Career & Guidance View: career exploration, interest quiz, portfolio, goals, appointments
- 6 new Prisma models: SubstituteTeacher, TeacherAbsence, SubstitutionAssignment, CareerProfile, CareerGoal, CareerAppointment
- Enhanced Newsletter model with content, scheduling, and analytics fields
- Enhanced settings-view with gradient header, glassmorphism cards, danger zone
- Enhanced student-portal-view with animated welcome banner, quick action cards
- 16+ new API route files
- 300+ i18n keys added
- All views verified working in browser
This commit is contained in:
Mustafa Cetin committed 2026-07-30 06:36:34 +00:00
1 parent a159ed7fe6
commit 3d0d518bb9
57 files changed
+8370 -48

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { getSession } from '@/lib/auth';
// ── GET: Get single career goal ──────────────────────────────────────────
export async function GET(
_request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const { id } = await params;
const goal = await db.careerGoal.findUnique({ where: { id } });
if (!goal) {
return NextResponse.json({ error: 'Goal not found' }, { status: 404 });
}
return NextResponse.json(goal);
} catch (error) {
console.error('Career goal GET error:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}
// ── PUT: Update career goal ─────────────────────────────────────────────
export async function PUT(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const { id } = await params;
const body = await request.json();
const { title, description, category, targetDate, progress, status, milestones } = body;
const existing = await db.careerGoal.findUnique({ where: { id } });
if (!existing) {
return NextResponse.json({ error: 'Goal not found' }, { status: 404 });
}
const updateData: Record<string, unknown> = {};
if (title !== undefined) updateData.title = title;
if (description !== undefined) updateData.description = description;
if (category !== undefined) updateData.category = category;
if (targetDate !== undefined) updateData.targetDate = targetDate ? new Date(targetDate) : null;
if (progress !== undefined) updateData.progress = progress;
if (status !== undefined) updateData.status = status;
if (milestones !== undefined) updateData.milestones = JSON.stringify(milestones);
const goal = await db.careerGoal.update({
where: { id },
data: updateData,
});
return NextResponse.json(goal);
} catch (error) {
console.error('Career goal PUT error:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}
// ── DELETE: Delete career goal ──────────────────────────────────────────
export async function DELETE(
_request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const { id } = await params;
const existing = await db.careerGoal.findUnique({ where: { id } });
if (!existing) {
return NextResponse.json({ error: 'Goal not found' }, { status: 404 });
}
await db.careerGoal.delete({ where: { id } });
return NextResponse.json({ success: true });
} catch (error) {
console.error('Career goal DELETE error:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}
+73
View File
@@ -0,0 +1,73 @@
import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { getSession } from '@/lib/auth';
// ── GET: List career goals ───────────────────────────────────────────────
export async function GET(request: Request) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const { searchParams } = new URL(request.url);
const profileId = searchParams.get('profileId');
const category = searchParams.get('category');
const status = searchParams.get('status');
if (!profileId) {
return NextResponse.json({ error: 'profileId is required' }, { status: 400 });
}
const where: Record<string, unknown> = { profileId };
if (category) where.category = category;
if (status) where.status = status;
const goals = await db.careerGoal.findMany({
where,
orderBy: { createdAt: 'desc' },
});
return NextResponse.json(goals);
} catch (error) {
console.error('Career goals GET error:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}
// ── POST: Create career goal ────────────────────────────────────────────
export async function POST(request: Request) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const body = await request.json();
const { profileId, title, description, category, targetDate, progress, milestones } = body;
if (!profileId || !title || !category) {
return NextResponse.json(
{ error: 'profileId, title, and category are required' },
{ status: 400 }
);
}
const goal = await db.careerGoal.create({
data: {
profileId,
title,
description: description || null,
category,
targetDate: targetDate ? new Date(targetDate) : null,
progress: progress || 0,
milestones: milestones ? JSON.stringify(milestones) : null,
},
});
return NextResponse.json(goal, { status: 201 });
} catch (error) {
console.error('Career goals POST error:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}