import getData from "@/utils/fetch";
import { Metadata } from "next";
import CommunicationGatewayContent from "./content";

export const metadata: Metadata = {
  title: "Communication Gateways",
};

export default async function CommunicationGatewayPage(context: any) {
  const { searchParams } = context;
  const gatewayId = searchParams?.id;
  const gateway = gatewayId ? await fetchGateway(gatewayId) : undefined;
  return <CommunicationGatewayContent gateway={gateway} />;
}

const fetchGateway = async (id: string) => {
  const { data } = await getData(`/api/v1/communication-gateways/${id}`);
  return data;
};
