import { NextResponse } from 'next/server';

import { errorResponse } from '@/lib/errors';
import { logger } from '@/lib/logger';
import { withPortalAuth } from '@/lib/portal/helpers';
import { getClientInterests } from '@/lib/services/portal.service';

export const GET = withPortalAuth(async (_req, session) => {
  try {
    const data = await getClientInterests(session.clientId, session.portId);
    return NextResponse.json({ data });
  } catch (error) {
    logger.error({ err: error }, 'Portal interests fetch failed');
    return errorResponse(error);
  }
});
