"use client"; import { format } from "date-fns"; import { Trash2, Edit2, Play } from "lucide-react"; import { useState } from "react"; import { useRouter } from "next/navigation"; export default function PostCard({ post, isPast }: { post: any, isPast?: boolean }) { const router = useRouter(); const [isDeleting, setIsDeleting] = useState(false); const handleDelete = async (e: React.MouseEvent) => { e.stopPropagation(); if (!confirm("Delete post?")) return; setIsDeleting(true); try { await fetch(`/api/posts?id=${post.id}`, { method: "DELETE" }); router.refresh(); } catch (e) { console.error(e); } finally { setIsDeleting(false); } }; return (
{/* Media */}
{post.mediaType === "VIDEO" ? (
) : ( )}
{post.status}
{/* Content */}
{post.accountProfilePictureUrl ? ( {post.accountUsername} ) : ( {(post.accountUsername || "U")[0].toUpperCase()} )}

@{post.accountUsername}

{post.scheduledAt ? format(new Date(post.scheduledAt), "MMM d") : "Draft"}

{post.caption || "No caption"}

{/* Actions */}
) }