import { useLinkTo } from "@react-navigation/native"; import { Button, Text, useRequestBetaAccess, useTheme, View, zero, type BetaStatus, } from "@streamplace/components"; import { Clapperboard, Clock } from "lucide-react-native"; import { useState } from "react"; // Shown on the upload page when the logged-in account hasn't been granted VOD // upload access. For "none" it offers a request button that publishes a // place.stream.beta.request; for "requested" it confirms the request is on // file and points users at the app, where the grant notification lands. export default function BetaAccessGate({ feature, status, onRequested, }: { feature: string; status: Exclude; onRequested: () => void; }) { const { theme } = useTheme(); const linkTo = useLinkTo(); const requestAccess = useRequestBetaAccess(feature); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); const handleRequest = async () => { setSubmitting(true); setError(null); try { await requestAccess(); onRequested(); } catch (e: any) { console.error("failed to request beta access", e); setError(e?.message ?? "Something went wrong. Please try again."); } finally { setSubmitting(false); } }; const requested = status === "requested"; const Icon = requested ? Clock : Clapperboard; return ( {requested ? "Access requested!" : "Video uploads are in beta"} {requested ? ( <> Download and log in to{" "} linkTo("/download")} style={{ color: theme.colors.primary, textDecorationLine: "underline", }} > the Streamplace app {" "} to get notified the moment that you get access. ) : ( "Uploading videos to Streamplace is invite-only for the moment. Request access and we'll notify you when you're off the waitlist." )} {!requested && ( )} {error && ( {error} )} ); }