import { NextResponse } from 'next/server';
import { withErrorHandler } from '@server/middleware/withErrorHandler';
import { withAuth, AuthedRequest } from '@server/middleware/withAuth';
import { markAllNotificationsRead } from '@server/services/notifications.service';

export const PATCH = withErrorHandler(
  withAuth(async (req: AuthedRequest) => {
    const { restaurantId, userId } = req.session;
    const result = await markAllNotificationsRead(restaurantId!, userId);
    return NextResponse.json(result);
  })
);
