1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
5export async function GET(request: NextRequest) {
7 // Verify authentication
8 const authData = await getStoredAuth();
9 if (!authData || !authData.authenticated) {
10 return NextResponse.json(
11 { error: 'Authentication required' },
16 const searchParams = request.nextUrl.searchParams;
17 const areas = searchParams.get('areas') || 'accounts,customers,other,products,staff,reference,security,technical';
19 const result = await fieldpineServerApi.buckApiCall({
20 "3": "retailmax.elink.advisor.eventlist",
24 return NextResponse.json({
29 } catch (error: any) {
30 console.error('Advisor API error:', error);
31 return NextResponse.json(
32 { success: false, error: error.message || 'Failed to fetch advisor data' },