import { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { wpApi } from "../api/wp-api"; import ReviewPrompt from "../components/ReviewPrompt"; interface ActivityItem { postId: number; title: string; date: string; editUrl: string; permalink: string; successCount: number; errorCount: number; channels: { type: string; status: string }[]; } interface ActivityResponse { items: ActivityItem[]; total: number; perPage: number; currentPage: number; totalPages: number; } const PLATFORM_ICONS: Record = { Facebook: "๐Ÿ“˜", Instagram: "๐Ÿ“ท", TikTok: "๐ŸŽต", Twitter: "๐•", LinkedIn: "๐Ÿ’ผ", Pinterest: "๐Ÿ“Œ", YouTube: "โ–ถ๏ธ", Threads: "๐Ÿงต", Bluesky: "๐Ÿฆ‹", Mastodon: "๐Ÿ˜", }; export default function Activity() { const [page, setPage] = useState(1); const { data, isLoading } = useQuery({ queryKey: ["activity", page], queryFn: () => wpApi.get(`activity?page=${page}`), }); return (
{/* Review prompt โ€” shows after user has shared posts */} {data?.items && data.items.length > 0 && }

Activity Log

History of blog posts shared to social media.

{isLoading ? (
Loading activity...
) : data?.items.length ? ( <>
{data.items.map((item) => (
{/* Post info */}

{item.title}

{item.date}

{/* Status badge */} {item.errorCount === 0 ? `โœ“ ${item.successCount} sent` : item.successCount === 0 ? `โœ• ${item.errorCount} failed` : `${item.successCount} sent, ${item.errorCount} failed`}
{/* Channel pills */}
{item.channels.map((ch, i) => ( {PLATFORM_ICONS[ch.type] || "๐ŸŒ"} {ch.type} ))}
))}
{/* Pagination */} {data.totalPages > 1 && (
Page {data.currentPage} of {data.totalPages}
)} ) : (

No Activity Yet

Posts shared to social media will appear here. Enable Blog to Social or use the Share button to get started.

)}
); }