import type {NextRequest} from 'next/server';
import {ok, parseQuery, requireApiSession, simulate} from '@/shared/services/apiRoute';
import {buildStaffSummary} from '@/features/staff/mock/staff.mock';

export const dynamic = 'force-dynamic';

export async function GET(req: NextRequest) {
  const denied = await requireApiSession();
  if (denied) return denied;
  const q = parseQuery(req);
  const simulated = await simulate(q);
  if (simulated) return simulated;
  return ok(buildStaffSummary(q.storeId, q.range), q);
}
