import { getMachineId } from "@/shared/utils/machine";
import { cookies } from "next/headers";
import { verifyToken } from "@/lib/auth/jwt";
import EndpointPageClient from "./EndpointPageClient";

export default async function EndpointPage() {
  const machineId = await getMachineId();
  
  const cookieStore = await cookies();
  const token = cookieStore.get("auth_token")?.value;
  let isAdmin = false;
  if (token) {
    const payload = await verifyToken(token);
    isAdmin = payload?.role === "admin";
  }
  
  return <EndpointPageClient machineId={machineId} isAdmin={isAdmin} />;
}
