"use client";

import { useApi } from "@/hooks/use-api";
import { Blog } from "@/types/types";
import { Loader2 } from "lucide-react";
import dynamic from "next/dynamic";
import { useParams } from "next/navigation";

const BlogEditor = dynamic(
	() => import("@/components/article/edit").then((mod) => mod.default),
	{
		ssr: false,
		loading: () => <Loader2 className="animate-spin" />,
	},
);

export default function Page() {
	const params = useParams<{ uuid: string }>();
	const {
		data: blog,
		error,
		mutate,
		success,
		isLoading,
	} = useApi<Blog>(`/blogs/${params.uuid}`, {}, false, false);
	return <BlogEditor blog={blog} />;
}
