import { getComponentName } from "@/utils/getComponentName";
import { fetchComponentData } from "@/utils/data";
import UI from "./UI";

const componentName = getComponentName(import.meta.url);

export default async function Component() {
  const result = await fetchComponentData(componentName);

  if (result.error || !result.data) {
    if (result.error) console.error(`Failed to fetch ${componentName} data:`, result.error);
    return null;
  }

  return <UI data={result.data} />;
}
