diff --git a/client/src/components/recent-publications.tsx b/client/src/components/recent-publications.tsx new file mode 100644 index 0000000..ffb83c4 --- /dev/null +++ b/client/src/components/recent-publications.tsx @@ -0,0 +1,113 @@ +import { useQuery } from "@tanstack/react-query"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Facebook, Instagram, Clock, CheckCircle2, XCircle } from "lucide-react"; +import { format } from "date-fns"; +import { fr } from "date-fns/locale"; +import type { ScheduledPost, SocialPage, Post } from "@shared/schema"; + +type ScheduledPostWithRelations = ScheduledPost & { + post?: Post; + page?: SocialPage; +}; + +export default function RecentPublications() { + const { data: scheduledPosts = [], isLoading } = useQuery({ + queryKey: ['/api/scheduled-posts'], + }); + + // Filter and sort published posts + const recentPublished = scheduledPosts + .filter(sp => sp.publishedAt) + .sort((a, b) => new Date(b.publishedAt!).getTime() - new Date(a.publishedAt!).getTime()) + .slice(0, 10); + + return ( + + + Historique des publications + + Vos 10 dernières publications sur les réseaux sociaux + + + + {isLoading ? ( +
+ {[1, 2, 3].map((i) => ( +
+ ))} +
+ ) : recentPublished.length === 0 ? ( +
+ +

Aucune publication pour le moment

+
+ ) : ( +
+ {recentPublished.map((scheduledPost) => ( +
+ {/* Platform icon */} +
+ {scheduledPost.page?.platform === 'facebook' ? ( + + ) : ( + + )} +
+ + {/* Content */} +
+
+
+

+ {scheduledPost.page?.pageName || 'Page inconnue'} +

+

+ {scheduledPost.post?.content ? ( + {scheduledPost.post.content} + ) : ( + Aucun texte + )} +

+
+
+ {scheduledPost.error ? ( + + ) : ( + + )} +
+
+ +
+ + {scheduledPost.postType === 'feed' ? 'Publication' : + scheduledPost.postType === 'story' ? 'Story' : scheduledPost.postType} + + • + + {format(new Date(scheduledPost.publishedAt!), "d MMM yyyy 'à' HH:mm", { locale: fr })} + + {scheduledPost.error && ( + <> + • + Erreur + + )} +
+
+
+ ))} +
+ )} + + + ); +} diff --git a/client/src/pages/dashboard.tsx b/client/src/pages/dashboard.tsx index 6ab3e6e..e930508 100644 --- a/client/src/pages/dashboard.tsx +++ b/client/src/pages/dashboard.tsx @@ -1,7 +1,7 @@ import Sidebar from "@/components/sidebar"; import TopBar from "@/components/topbar"; import StatsCards from "@/components/stats-cards"; -import CalendarView from "@/components/calendar-view"; +import RecentPublications from "@/components/recent-publications"; import ManagedPages from "@/components/managed-pages"; import { useState } from "react"; @@ -30,7 +30,7 @@ export default function Dashboard() {
- +