import React, { useEffect, useState } from "react"; import { Play, Download, Clock, AlertCircle, ExternalLink, Loader2, } from "lucide-react"; import { getShareInfo, getShareDownloadUrl, formatExpiresIn, isShareExpired, type ShareInfo, } from "../services/share-service"; interface SharePageProps { shareId: string; } type PageStatus = "loading" | "ready" | "expired" | "not-found" | "error"; export const SharePage: React.FC = ({ shareId }) => { const [status, setStatus] = useState("loading"); const [shareInfo, setShareInfo] = useState(null); const [error, setError] = useState(null); useEffect(() => { const loadShareInfo = async () => { try { const info = await getShareInfo(shareId); if (!info) { setStatus("not-found"); return; } if (isShareExpired(info.expiresAt)) { setStatus("expired"); return; } setShareInfo(info); setStatus("ready"); } catch (err) { if (err instanceof Error && err.message.includes("expired")) { setStatus("expired"); } else { setError(err instanceof Error ? err.message : "Failed to load share"); setStatus("error"); } } }; loadShareInfo(); }, [shareId]); const downloadUrl = getShareDownloadUrl(shareId); const handleCreateProject = () => { window.location.hash = "#/editor"; }; if (status === "loading") { return (

Loading video...

); } if (status === "not-found") { return (

Video Not Found

This video doesn't exist or the link is invalid.

); } if (status === "expired") { return (

Link Expired

This share link has expired. Share links are only valid for 24 hours.

); } if (status === "error") { return (

Error

{error || "Something went wrong"}

); } return (

{shareInfo?.filename || "Shared Video"}

{shareInfo && (
{(shareInfo.size / (1024 * 1024)).toFixed(1)} MB
{formatExpiresIn(shareInfo.expiresAt)}
)}
Download

Made with{" "} Open Reel Video

); };