Muhammad-Mehdi's picture
changes added
fa6e4a3
Raw History Blame Contribute Delete
1.16 kB
import { useState } from "react";
import type { Artifact } from "../../api/types";
import { ScheduleModal } from "../ScheduleModal";
/** What can go out on X / LinkedIn: images (a slide deck's slides too), videos and text. Not audio (neither platform
* takes audio files). */
const POSTABLE = new Set(["video", "quote_card", "carousel", "summary", "launch_kit", "mind_map", "slide_deck"]);
export function canPost(a: Artifact): boolean {
if (!POSTABLE.has(a.type)) return false;
if (a.provider === "blog2video") return Boolean((a.content as { video_url?: string } | null)?.video_url);
return a.status === "ready";
}
/** "Post": opens the composer with this item attached and its text filled in. */
export function PostButton({ artifactId, className = "btn btn-small", label = "Post" }: {
artifactId: string;
className?: string;
label?: string;
}) {
const [open, setOpen] = useState(false);
return (
<>
<button type="button" className={className} onClick={() => setOpen(true)}>{label}</button>
{open && <ScheduleModal platform="linkedin" posts={[]} artifactId={artifactId} onClose={() => setOpen(false)} />}
</>
);
}