import { Head, Link, router, useForm } from '@inertiajs/react'; import { Copy, KeyRound, Radio, RotateCw, Save, StopCircle, Video, } from 'lucide-react'; import type { FormEvent } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { useClipboard } from '@/hooks/use-clipboard'; import { dashboard as dashboardRoute } from '@/routes'; import { show as showChannel } from '@/routes/channels'; import { stop as stopBroadcastRoute, store as storeBroadcastRoute, } from '@/routes/creator/broadcasts'; import { store as storeChannelRoute, update as updateChannelRoute, } from '@/routes/creator/channel'; import { rotate as rotateStreamKeyRoute } from '@/routes/creator/stream-key'; import type { BroadcastSummary, Category } from '@/types'; type CreatorChannel = { id: number; slug: string; display_name: string; description: string | null; is_live: boolean; viewer_count: number; stream_key_last_used_at: string | null; category_id: number | null; live_broadcast: BroadcastSummary | null; }; type Props = { channel: CreatorChannel | null; plainStreamKey: string | null; streaming: { ingestServer: string; tokenizedPath: string | null; }; categories: Category[]; recentBroadcasts: BroadcastSummary[]; }; export default function Dashboard({ channel, plainStreamKey, streaming, categories, recentBroadcasts, }: Props) { const [, copy] = useClipboard(); const liveBroadcast = channel?.live_broadcast ?? null; const createForm = useForm({ display_name: '', slug: '', description: '', category_id: '', }); const channelForm = useForm({ display_name: channel?.display_name ?? '', slug: channel?.slug ?? '', description: channel?.description ?? '', category_id: channel?.category_id ? String(channel.category_id) : '', }); const broadcastForm = useForm({ title: '', recording_enabled: false, }); function createChannel(event: FormEvent) { event.preventDefault(); createForm.submit(storeChannelRoute()); } function updateChannel(event: FormEvent) { event.preventDefault(); channelForm.submit(updateChannelRoute()); } function createBroadcast(event: FormEvent) { event.preventDefault(); broadcastForm.submit(storeBroadcastRoute(), { onSuccess: () => broadcastForm.reset('title', 'recording_enabled'), }); } return ( <>

Creator Studio

Manage your channel, stream key, and OBS broadcast sessions.

{channel && ( )}
{!channel ? (

Create your channel

Each account can own one channel in this version.

createForm.setData( 'display_name', event.target.value, ) } placeholder="Nyone Live" /> createForm.setData( 'slug', event.target.value.toLowerCase(), ) } placeholder="nyone-live" /> createForm.setData('category_id', value) } />