'use client';
import { useState } from 'react';
import { motion, useReducedMotion } from 'framer-motion';
import { Card } from '@/ui/Card';
import { Button } from '@/ui/Button';
import { Input } from '@/ui/Input';
import { Toggle } from '@/ui/Toggle';
import { Box } from '@/ui/Box';
import { Stack } from '@/ui/Stack';
import { Text } from '@/ui/Text';
import { Heading } from '@/ui/Heading';
import { SectionHeader } from '@/ui/SectionHeader';
import { FormField } from '@/ui/FormField';
import { PageHeader } from '@/ui/PageHeader';
import { Image } from '@/ui/Image';
import {
Settings,
Building2,
Mail,
Globe,
Upload,
Save,
Bell,
Shield,
Eye,
Trash2,
CheckCircle,
User,
Phone,
MapPin,
FileText,
Link as LinkIcon,
Image as ImageIcon,
Lock,
Key,
Smartphone,
AlertCircle
} from 'lucide-react';
import { logoutAction } from '@/app/actions/logoutAction';
// ============================================================================
// Types
// ============================================================================
interface SponsorProfile {
companyName: string;
contactName: string;
contactEmail: string;
contactPhone: string;
website: string;
description: string;
logoUrl: string | null;
industry: string;
address: {
street: string;
city: string;
country: string;
postalCode: string;
};
taxId: string;
socialLinks: {
twitter: string;
linkedin: string;
instagram: string;
};
}
interface NotificationSettings {
emailNewSponsorships: boolean;
emailWeeklyReport: boolean;
emailRaceAlerts: boolean;
emailPaymentAlerts: boolean;
emailNewOpportunities: boolean;
emailContractExpiry: boolean;
}
interface PrivacySettings {
publicProfile: boolean;
showStats: boolean;
showActiveSponsorships: boolean;
allowDirectContact: boolean;
}
// ============================================================================
// Mock Data
// ============================================================================
const MOCK_PROFILE: SponsorProfile = {
companyName: 'Acme Racing Co.',
contactName: 'John Smith',
contactEmail: 'sponsor@acme-racing.com',
contactPhone: '+1 (555) 123-4567',
website: 'https://acme-racing.com',
description: 'Premium sim racing equipment and accessories for competitive drivers. We specialize in high-performance steering wheels, pedals, and cockpit systems used by professionals worldwide.',
logoUrl: null,
industry: 'Racing Equipment',
address: {
street: '123 Racing Boulevard',
city: 'Indianapolis',
country: 'United States',
postalCode: '46222',
},
taxId: 'US12-3456789',
socialLinks: {
twitter: '@acmeracing',
linkedin: 'acme-racing-co',
instagram: '@acmeracing',
},
};
const MOCK_NOTIFICATIONS: NotificationSettings = {
emailNewSponsorships: true,
emailWeeklyReport: true,
emailRaceAlerts: false,
emailPaymentAlerts: true,
emailNewOpportunities: true,
emailContractExpiry: true,
};
const MOCK_PRIVACY: PrivacySettings = {
publicProfile: true,
showStats: false,
showActiveSponsorships: true,
allowDirectContact: true,
};
const INDUSTRY_OPTIONS = [
'Racing Equipment',
'Automotive',
'Technology',
'Gaming & Esports',
'Energy Drinks',
'Apparel',
'Financial Services',
'Other',
];
// ============================================================================
// Components
// ============================================================================
function SavedIndicator({ visible }: { visible: boolean }) {
const shouldReduceMotion = useReducedMotion();
return (
Changes saved
);
}
// ============================================================================
// Main Component
// ============================================================================
export default function SponsorSettingsPage() {
const shouldReduceMotion = useReducedMotion();
const [profile, setProfile] = useState(MOCK_PROFILE);
const [notifications, setNotifications] = useState(MOCK_NOTIFICATIONS);
const [privacy, setPrivacy] = useState(MOCK_PRIVACY);
const [saving, setSaving] = useState(false);
const [saved, setSaved] = useState(false);
const handleSaveProfile = async () => {
setSaving(true);
await new Promise(resolve => setTimeout(resolve, 800));
setSaving(false);
setSaved(true);
setTimeout(() => setSaved(false), 3000);
};
const handleDeleteAccount = async () => {
if (confirm('Are you sure you want to delete your sponsor account? This action cannot be undone. All sponsorship data will be permanently removed.')) {
// Call the logout action and handle result
const result = await logoutAction();
if (result.isErr()) {
console.error('Logout failed:', result.getError());
// Could show error toast here
return;
}
// Redirect to login after successful logout
window.location.href = '/auth/login';
}
};
const containerVariants = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: {
staggerChildren: shouldReduceMotion ? 0 : 0.1,
},
},
};
const itemVariants = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 },
};
return (
{/* Header */}
}
/>
{/* Company Profile */}
{/* Company Basic Info */}
setProfile({ ...profile, companyName: e.target.value })}
placeholder="Your company name"
/>
) => setProfile({ ...profile, industry: e.target.value })}
w="full"
px={3}
py={2}
bg="bg-iron-gray"
border
borderColor="border-charcoal-outline"
rounded="lg"
color="text-white"
className="focus:outline-none focus:border-primary-blue"
>
{INDUSTRY_OPTIONS.map(industry => (
))}
{/* Contact Information */}
Contact Information
setProfile({ ...profile, contactName: e.target.value })}
placeholder="Full name"
/>
setProfile({ ...profile, contactEmail: e.target.value })}
placeholder="sponsor@company.com"
/>
setProfile({ ...profile, contactPhone: e.target.value })}
placeholder="+1 (555) 123-4567"
/>
setProfile({ ...profile, website: e.target.value })}
placeholder="https://company.com"
/>
{/* Address */}
Business Address
setProfile({
...profile,
address: { ...profile.address, street: e.target.value }
})}
placeholder="123 Main Street"
/>
setProfile({
...profile,
address: { ...profile.address, city: e.target.value }
})}
placeholder="City"
/>
setProfile({
...profile,
address: { ...profile.address, postalCode: e.target.value }
})}
placeholder="12345"
/>
setProfile({
...profile,
address: { ...profile.address, country: e.target.value }
})}
placeholder="Country"
/>
setProfile({ ...profile, taxId: e.target.value })}
placeholder="XX12-3456789"
/>
{/* Description */}
) => setProfile({ ...profile, description: e.target.value })}
placeholder="Tell potential sponsorship partners about your company, products, and what you're looking for in sponsorship opportunities..."
rows={4}
w="full"
px={4}
py={3}
bg="bg-iron-gray"
border
borderColor="border-charcoal-outline"
rounded="lg"
color="text-white"
className="placeholder-gray-500 focus:outline-none focus:border-primary-blue resize-none"
/>
This description appears on your public sponsor profile.
{/* Social Links */}
Social Media
setProfile({
...profile,
socialLinks: { ...profile.socialLinks, twitter: e.target.value }
})}
placeholder="@username"
/>
setProfile({
...profile,
socialLinks: { ...profile.socialLinks, linkedin: e.target.value }
})}
placeholder="company-name"
/>
setProfile({
...profile,
socialLinks: { ...profile.socialLinks, instagram: e.target.value }
})}
placeholder="@username"
/>
{/* Logo Upload */}
{profile.logoUrl ? (
) : (
)}
Upload Logo
{profile.logoUrl && (
)}
PNG, JPEG, or SVG. Max 2MB. Recommended size: 400x400px.
{/* Save Button */}
{/* Notification Preferences */}
setNotifications({ ...notifications, emailNewSponsorships: checked })}
label="Sponsorship Approvals"
description="Receive confirmation when your sponsorship requests are approved"
/>
setNotifications({ ...notifications, emailWeeklyReport: checked })}
label="Weekly Analytics Report"
description="Get a weekly summary of your sponsorship performance"
/>
setNotifications({ ...notifications, emailRaceAlerts: checked })}
label="Race Day Alerts"
description="Be notified when sponsored leagues have upcoming races"
/>
setNotifications({ ...notifications, emailPaymentAlerts: checked })}
label="Payment & Invoice Notifications"
description="Receive invoices and payment confirmations"
/>
setNotifications({ ...notifications, emailNewOpportunities: checked })}
label="New Sponsorship Opportunities"
description="Get notified about new leagues and drivers seeking sponsors"
/>
setNotifications({ ...notifications, emailContractExpiry: checked })}
label="Contract Expiry Reminders"
description="Receive reminders before your sponsorship contracts expire"
/>
{/* Privacy & Visibility */}
setPrivacy({ ...privacy, publicProfile: checked })}
label="Public Profile"
description="Allow leagues, teams, and drivers to view your sponsor profile"
/>
setPrivacy({ ...privacy, showStats: checked })}
label="Show Sponsorship Statistics"
description="Display your total sponsorships and investment amounts"
/>
setPrivacy({ ...privacy, showActiveSponsorships: checked })}
label="Show Active Sponsorships"
description="Let others see which leagues and teams you currently sponsor"
/>
setPrivacy({ ...privacy, allowDirectContact: checked })}
label="Allow Direct Contact"
description="Enable leagues and teams to send you sponsorship proposals"
/>
{/* Security */}
Password
Last changed 3 months ago
Two-Factor Authentication
Add an extra layer of security to your account
Active Sessions
Manage devices where you're logged in
{/* Danger Zone */}
}>
Danger Zone
Delete Sponsor Account
Permanently delete your account and all associated sponsorship data.
This action cannot be undone.
);
}