mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-22 22:48:09 +02:00
Ajoute la gestion multi-comptes TikTok et permet d'envoyer la même vidéo sur plusieurs pages Facebook ET plusieurs comptes TikTok en une seule publication. Un compte TikTok vit dans social_pages comme une page Facebook : il hérite donc des permissions par utilisateur, de la planification et du calendrier. Trois particularités de l'API TikTok structurent l'implémentation : - pas de jeton saisi à la main : chaque compte passe par OAuth, et l'access token (24h) est renouvelé via le refresh token (1 an) avant chaque publication ; - la publication est asynchrone : l'upload rend un publish_id, et un poller récupère l'identifiant définitif du post ; - creator_info doit être interrogé avant chaque envoi pour ne demander qu'un niveau de confidentialité réellement autorisé sur le compte. Serveur : - service TikTok (OAuth, creator_info, upload FILE_UPLOAD par chunks, suivi de statut) et routes de connexion/configuration - schéma : platform 'tiktok', refresh token et scopes sur social_pages, publish_id/publish_status sur scheduled_posts, table tiktok_config - routage par plateforme dans les deux flux de reels et le planificateur - cron de suivi des publications, token manager et analytics adaptés Client : - connexion et reconnexion des comptes TikTok depuis « Pages gérées » - sélection combinée pages Facebook / comptes TikTok à la publication - configuration de l'application TikTok dans les paramètres (admin) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uUPZ1GNpEkYB1dpXHYPek
95 lines
4.2 KiB
TypeScript
95 lines
4.2 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { Users } from "lucide-react";
|
|
import { SiFacebook, SiInstagram, SiTiktok } from "react-icons/si";
|
|
|
|
export default function ManagedPages() {
|
|
const { data: pages, isLoading } = useQuery({
|
|
queryKey: ["/api/pages"],
|
|
});
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="bg-card rounded-2xl border border-border/50 p-8 shadow-lg">
|
|
<div className="skeleton h-8 w-48 mb-6 rounded-lg" />
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
{[1, 2, 3].map((i) => (
|
|
<div key={i} className="skeleton h-40 rounded-xl" />
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="bg-card rounded-2xl border border-border/50 overflow-hidden shadow-lg">
|
|
<div className="border-b border-border/50 p-6 bg-gradient-to-r from-primary/5 to-secondary/5">
|
|
<div className="flex items-center gap-4">
|
|
<div className="w-12 h-12 rounded-xl bg-gradient-to-br from-primary to-secondary flex items-center justify-center shadow-lg">
|
|
<Users className="text-white w-6 h-6" />
|
|
</div>
|
|
<div>
|
|
<h3 className="text-lg font-semibold text-foreground">Pages gérées</h3>
|
|
<p className="text-sm text-muted-foreground">
|
|
{(pages as any[])?.length || 0} page(s) connectée(s)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="p-8">
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
{pages && (pages as any[]).length > 0 ? (
|
|
(pages as any[]).map((page: any) => (
|
|
<div
|
|
key={page.id}
|
|
className="border border-border/50 rounded-2xl p-6 hover:shadow-xl hover:border-primary/30 transition-all cursor-pointer bg-card"
|
|
data-testid={`page-card-${page.id}`}
|
|
>
|
|
<div className="flex items-start justify-between mb-5">
|
|
<div className={`
|
|
w-14 h-14 rounded-xl flex items-center justify-center shadow-md
|
|
${page.platform === "facebook" ? "bg-[#1877F2]/10" : page.platform === "tiktok" ? "bg-foreground/10" : "bg-[#E4405F]/10"}
|
|
`}>
|
|
{page.platform === "facebook" ? (
|
|
<SiFacebook className="text-[#1877F2] text-2xl" />
|
|
) : page.platform === "tiktok" ? (
|
|
<SiTiktok className="text-foreground text-2xl" />
|
|
) : (
|
|
<SiInstagram className="text-[#E4405F] text-2xl" />
|
|
)}
|
|
</div>
|
|
<span className={`
|
|
inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold
|
|
${page.isActive === "true" ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"}
|
|
`}>
|
|
{page.isActive === "true" ? "Actif" : "Inactif"}
|
|
</span>
|
|
</div>
|
|
<h4 className="font-semibold text-foreground text-lg mb-2">{page.pageName}</h4>
|
|
<p className="text-sm text-muted-foreground mb-4 font-medium">
|
|
{page.platform === "facebook" ? "Facebook Page" : page.platform === "tiktok" ? "Compte TikTok" : "Instagram Business"}
|
|
</p>
|
|
<div className="flex items-center justify-between pt-4 border-t border-border/50">
|
|
<div className="flex items-center gap-2">
|
|
<Users className="w-4 h-4 text-muted-foreground" />
|
|
<span className="text-sm text-muted-foreground font-medium">
|
|
{page.followersCount?.toLocaleString() || 0} abonnés
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))
|
|
) : (
|
|
<div className="col-span-full text-center py-16">
|
|
<div className="w-20 h-20 rounded-2xl bg-muted/30 flex items-center justify-center mx-auto mb-6">
|
|
<Users className="w-10 h-10 text-muted-foreground opacity-50" />
|
|
</div>
|
|
<p className="text-muted-foreground text-lg">Aucune page connectée</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|