"use client"
import React, { useState, useEffect, use } from "react"
import { useRouter } from "next/navigation"
export default function EditBlogPost({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = use(params) // ✅ unwrap the promise here
const [post, setPost] = useState<BlogPost | null>(null)
const [isLoading, setIsLoading] = useState(false)
const [content, setContent] = useState("")
const [formData, setFormData] = useState({
title: "",
description: "",
category: "",
image: "",
})
const router = useRouter()
useEffect(() => {
const fetchPost = async () => {
const post = await getPostBySlug(slug) // use unwrapped slug
setPost(post)
setFormData({
title: post.title,
description: post.description,
category: post.category,
image: post.image,
})
setContent(post.content)
}
fetchPost()
}, [slug, router])
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target
setFormData((prev) => ({ ...prev, [name]: value }))
}
return (
<div>
{/* your form UI */}
</div>
)
}