Spaces:
Runtime error
Runtime error
Download src/components/dashboard/PostCard.tsx from damndeepesh-dev/RippleWorkers: direct link, hf CLI and curl.
- Browser
- Download file 3.99 kB
-
https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/components/dashboard/PostCard.tsx
- Command line
-
hf download hf://spaces/damndeepesh-dev/RippleWorkers/src/components/dashboard/PostCard.tsx
-
curl -L -o PostCard.tsx https://huggingface.co/spaces/damndeepesh-dev/RippleWorkers/resolve/main/src/components/dashboard/PostCard.tsx
3.99 kB
| "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 ( | |
| <div className={`bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-shadow ${isPast ? 'opacity-75 grayscale-[0.3]' : ''}`}> | |
| {/* Media */} | |
| <div className="h-48 bg-gray-100 dark:bg-zinc-800 relative"> | |
| {post.mediaType === "VIDEO" ? ( | |
| <div className="w-full h-full flex items-center justify-center bg-black/5"> | |
| <Play className="text-gray-400" /> | |
| </div> | |
| ) : ( | |
| <img src={post.mediaUrl.split(',')[0]} alt="" className="w-full h-full object-cover" /> | |
| )} | |
| <div className="absolute top-2 right-2 flex gap-1"> | |
| <span className={`text-[10px] font-bold px-2 py-0.5 rounded border bg-white dark:bg-zinc-900 ${post.status === 'PUBLISHED' ? 'text-green-600 border-green-200' : 'text-gray-600 border-gray-200'}`}> | |
| {post.status} | |
| </span> | |
| </div> | |
| </div> | |
| {/* Content */} | |
| <div className="p-4"> | |
| <div className="flex justify-between items-start mb-2"> | |
| <div className="flex items-center gap-2"> | |
| <div className="w-6 h-6 rounded-full bg-gray-200 dark:bg-zinc-800 overflow-hidden flex items-center justify-center border border-gray-100 dark:border-zinc-700"> | |
| {post.accountProfilePictureUrl ? ( | |
| <img src={post.accountProfilePictureUrl} alt={post.accountUsername} className="w-full h-full object-cover" /> | |
| ) : ( | |
| <span className="text-[10px] font-bold text-gray-500">{(post.accountUsername || "U")[0].toUpperCase()}</span> | |
| )} | |
| </div> | |
| <p className="text-xs font-bold text-gray-500">@{post.accountUsername}</p> | |
| </div> | |
| <p className="text-xs text-gray-400"> | |
| {post.scheduledAt ? format(new Date(post.scheduledAt), "MMM d") : "Draft"} | |
| </p> | |
| </div> | |
| <p className="text-sm text-gray-900 dark:text-white line-clamp-2 min-h-[2.5rem]"> | |
| {post.caption || "No caption"} | |
| </p> | |
| {/* Actions */} | |
| <div className="mt-4 pt-4 border-t border-gray-100 dark:border-zinc-800 flex justify-end gap-2"> | |
| <button | |
| onClick={() => router.push(`/dashboard/create/editor?edit=${post.id}`)} | |
| className="px-3 py-1.5 text-xs text-gray-600 border border-gray-200 rounded hover:bg-gray-50" | |
| > | |
| Edit | |
| </button> | |
| <button | |
| onClick={handleDelete} | |
| className="px-3 py-1.5 text-xs text-red-600 border border-red-200 rounded hover:bg-red-50" | |
| > | |
| {isDeleting ? "..." : "Delete"} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ) | |
| } | |