import React, { useState } from "react"; import { createStation } from "../utils/StationsCreate"; import { useNavigate } from "react-router-dom"; function CreateStation() { const navigate = useNavigate(); const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [joinCode, setJoinCode] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); const [isCopied, setIsCopied] = useState(false); const handleCreateStation = async () => { if (!name.trim() || !description.trim()) { setError("Please fill in all fields"); return; } setIsLoading(true); setError(""); try { const code = await createStation(name, description); setJoinCode(code); } catch (error) { setError(error.message || "Failed to create station"); } finally { setIsLoading(false); } }; const handleGoToStation = () => { // Navigate to the station or home page navigate("/"); }; const handleCopyCode = async () => { try { await navigator.clipboard.writeText(joinCode); setIsCopied(true); // Reset the animation after 2 seconds setTimeout(() => { setIsCopied(false); }, 2000); } catch (err) { console.error('Failed to copy: ', err); } }; return (
{/* Left Section - Vinyl Animation */}
{/* Animated Music Notes */}
{/* Right Section - Create Station Form */}

Create a Station on Serena

Start your own collaborative music experience

{!joinCode ? (
e.preventDefault()}>
setName(e.target.value)} disabled={isLoading} />