Files
holacompi/app/api/notifications/route.ts
T
Haitham Khalifa b538d84e17 Initial commit
2026-02-16 12:18:06 +01:00

33 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import {
getNotificationSettings,
updateNotificationSettings,
} from '@/lib/firestore';
export async function GET(request: NextRequest) {
try {
// TODO: Get userId from auth token
const userId = 'test-user-id'; // Replace with actual auth
const settings = await getNotificationSettings(userId);
return NextResponse.json({ settings });
} catch (error) {
console.error('Error fetching notification settings:', error);
return NextResponse.json({ error: 'Failed to fetch settings' }, { status: 500 });
}
}
export async function PUT(request: NextRequest) {
try {
const body = await request.json();
// TODO: Get userId from auth token
const userId = 'test-user-id'; // Replace with actual auth
await updateNotificationSettings(userId, body);
const settings = await getNotificationSettings(userId);
return NextResponse.json({ settings });
} catch (error) {
console.error('Error updating notification settings:', error);
return NextResponse.json({ error: 'Failed to update settings' }, { status: 500 });
}
}