import { NextResponse } from 'next/server';

import { withAuth, withPermission } from '@/lib/api/helpers';
import { getUpcomingReminders } from '@/lib/services/reminders.service';
import { errorResponse } from '@/lib/errors';

export const GET = withAuth(
  withPermission('reminders', 'view_own', async (_req, ctx) => {
    try {
      const data = await getUpcomingReminders(ctx.portId);
      return NextResponse.json({ data });
    } catch (error) {
      return errorResponse(error);
    }
  }),
);
