'use client' import { useState, useEffect } from 'react' import { LabelProfileForm, LabelProfileFormData } from '@/components/LabelProfileForm' export default function LabelSettingsPage() { const [label, setLabel] = useState(null) const [loading, setLoading] = useState(true) const [isUpdating, setIsUpdating] = useState(false) useEffect(() => { fetchLabel() }, []) const fetchLabel = async () => { try { // Check authentication const userRes = await fetch('/api/users/me') if (!userRes.ok) { window.location.href = '/login' return } const userData = await userRes.json() // Fetch user's label const labelRes = await fetch(`/api/users/${userData.user.id}/label`) if (!labelRes.ok) { window.location.href = '/label/create' return } const labelData = await labelRes.json() setLabel(labelData.label) } catch (error) { console.error('Failed to fetch label:', error) } finally { setLoading(false) } } const handleSave = async (data: LabelProfileFormData) => { setIsUpdating(true) try { const res = await fetch(`/api/labels/${label.id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) if (res.ok) { const result = await res.json() setLabel(result.label) alert('Label profile updated successfully') } else { const error = await res.json() alert(error.error || 'Failed to update label') } } catch (error) { console.error('Failed to update label:', error) alert('Network error') } finally { setIsUpdating(false) } } const handleCancel = () => { window.location.href = '/label/dashboard' } if (loading) { return (

Loading settings...

) } if (!label) { return (

Label not found

Go to Dashboard
) } return (
{/* Header */}

Label Settings

Manage your label profile and information

{/* Profile Form */}

Profile Information

{/* Danger Zone */}

Danger Zone

Once you delete your label, all associated data will be permanently removed. Artists will be unlinked. This action cannot be undone.

) }