import { NextResponse } from "next/server";
import axios from "axios";

export async function POST(request) {
  try {
    const body = await request.json();
    
    const headers = { 'Authorization': `Bearer ${body.token}` };
    const loginRes = await axios.get(
      `${process.env.NEXT_PUBLIC_API_BASE_URL}/kiosk/getDashboardData?kiosk_id=${body.kioskId}`,
      { headers }
    );

    // console.log("Login response:", loginRes.data);


    return NextResponse.json(loginRes.data);
  } catch (error) {

    // console.error(
    //   "Login Error:",
    //   error?.response?.data || error.message || error
    // );
    return NextResponse.json(
      { error: "Something went wrong", detail: error.message },
      { status: error.status }
    );
  }
}