website refactor
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState, FormEvent } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import Input from '../ui/Input';
|
||||
import Button from '../ui/Button';
|
||||
import { useCreateDriver } from "@/lib/hooks/driver/useCreateDriver";
|
||||
@@ -70,7 +71,7 @@ export default function CreateDriverForm() {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.push('/profile');
|
||||
router.push(routes.protected.profile);
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error) => {
|
||||
|
||||
88
apps/website/components/drivers/DriverProfilePageClient.tsx
Normal file
88
apps/website/components/drivers/DriverProfilePageClient.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { DriverProfileTemplate } from '@/templates/DriverProfileTemplate';
|
||||
import type { DriverProfileViewModel } from '@/lib/view-models/DriverProfileViewModel';
|
||||
|
||||
interface DriverProfilePageClientProps {
|
||||
pageDto: DriverProfileViewModel | null;
|
||||
error?: string;
|
||||
empty?: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* DriverProfilePageClient
|
||||
*
|
||||
* Client component that:
|
||||
* 1. Handles UI state (tabs, friend requests)
|
||||
* 2. Passes ViewModel directly to Template
|
||||
*
|
||||
* No business logic or data transformation here.
|
||||
* All data transformation happens in the PageQuery and ViewModelBuilder.
|
||||
*/
|
||||
export function DriverProfilePageClient({ pageDto, error, empty }: DriverProfilePageClientProps) {
|
||||
const router = useRouter();
|
||||
|
||||
// UI State (UI-only concerns)
|
||||
const [activeTab, setActiveTab] = useState<'overview' | 'stats'>('overview');
|
||||
const [friendRequestSent, setFriendRequestSent] = useState(false);
|
||||
|
||||
// Event handlers (UI-only concerns)
|
||||
const handleAddFriend = () => {
|
||||
setFriendRequestSent(true);
|
||||
};
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.push('/drivers');
|
||||
};
|
||||
|
||||
// Handle error/empty states
|
||||
if (error) {
|
||||
return (
|
||||
<div className="max-w-6xl mx-auto px-4 py-12 text-center">
|
||||
<div className="text-red-400 mb-4">Error loading driver profile</div>
|
||||
<p className="text-gray-400">Please try again later</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!pageDto || !pageDto.currentDriver) {
|
||||
if (empty) {
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-4">
|
||||
<div className="text-center py-12">
|
||||
<h2 className="text-xl font-semibold text-white mb-2">{empty.title}</h2>
|
||||
<p className="text-gray-400">{empty.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Pass ViewModel directly to template
|
||||
return (
|
||||
<DriverProfileTemplate
|
||||
driverProfile={pageDto}
|
||||
allTeamMemberships={pageDto.teamMemberships.map(m => ({
|
||||
team: {
|
||||
id: m.teamId,
|
||||
name: m.teamName,
|
||||
},
|
||||
role: m.role,
|
||||
joinedAt: new Date(m.joinedAt),
|
||||
}))}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
onBackClick={handleBackClick}
|
||||
onAddFriend={handleAddFriend}
|
||||
friendRequestSent={friendRequestSent}
|
||||
activeTab={activeTab}
|
||||
setActiveTab={setActiveTab}
|
||||
/>
|
||||
);
|
||||
}
|
||||
50
apps/website/components/drivers/DriversPageClient.tsx
Normal file
50
apps/website/components/drivers/DriversPageClient.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { DriversTemplate } from '@/templates/DriversTemplate';
|
||||
import type { DriverLeaderboardViewModel } from '@/lib/view-models/DriverLeaderboardViewModel';
|
||||
|
||||
interface DriversPageClientProps {
|
||||
pageDto: DriverLeaderboardViewModel | null;
|
||||
error?: string;
|
||||
empty?: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* DriversPageClient
|
||||
*
|
||||
* Client component that:
|
||||
* 1. Passes ViewModel directly to Template
|
||||
*
|
||||
* No business logic, filtering, or sorting here.
|
||||
* All data transformation happens in the PageQuery and ViewModelBuilder.
|
||||
*/
|
||||
export function DriversPageClient({ pageDto, error, empty }: DriversPageClientProps) {
|
||||
// Handle error/empty states
|
||||
if (error) {
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-4 py-12 text-center">
|
||||
<div className="text-red-400 mb-4">Error loading drivers</div>
|
||||
<p className="text-gray-400">Please try again later</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!pageDto || pageDto.drivers.length === 0) {
|
||||
if (empty) {
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-4 py-12 text-center">
|
||||
<h2 className="text-xl font-semibold text-white mb-2">{empty.title}</h2>
|
||||
<p className="text-gray-400">{empty.description}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Pass ViewModel directly to template
|
||||
return <DriversTemplate data={pageDto} />;
|
||||
}
|
||||
@@ -30,19 +30,22 @@ export default function EmailCapture() {
|
||||
try {
|
||||
const result = await landingService.signup(email);
|
||||
|
||||
if (result.status === 'success') {
|
||||
setFeedback({ type: 'success', message: result.message });
|
||||
if (result.isOk()) {
|
||||
setFeedback({ type: 'success', message: 'Thanks! You\'re on the list.' });
|
||||
setEmail('');
|
||||
setTimeout(() => setFeedback({ type: 'idle' }), 5000);
|
||||
} else if (result.status === 'info') {
|
||||
setFeedback({ type: 'info', message: result.message });
|
||||
setTimeout(() => setFeedback({ type: 'idle' }), 4000);
|
||||
} else {
|
||||
setFeedback({
|
||||
type: 'error',
|
||||
message: result.message,
|
||||
canRetry: true
|
||||
});
|
||||
const error = result.getError();
|
||||
if (error.type === 'notImplemented') {
|
||||
setFeedback({ type: 'info', message: 'Signup feature coming soon!' });
|
||||
setTimeout(() => setFeedback({ type: 'idle' }), 4000);
|
||||
} else {
|
||||
setFeedback({
|
||||
type: 'error',
|
||||
message: error.message || 'Something broke. Try again?',
|
||||
canRetry: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
setFeedback({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Trophy, Crown, Flag, ChevronRight } from 'lucide-react';
|
||||
import Button from '@/components/ui/Button';
|
||||
import Image from 'next/image';
|
||||
@@ -17,6 +16,7 @@ interface DriverLeaderboardPreviewProps {
|
||||
position: number;
|
||||
}[];
|
||||
onDriverClick: (id: string) => void;
|
||||
onNavigateToDrivers: () => void;
|
||||
}
|
||||
|
||||
const SKILL_LEVELS = [
|
||||
@@ -26,8 +26,7 @@ const SKILL_LEVELS = [
|
||||
{ id: 'beginner', label: 'Beginner', color: 'text-green-400' },
|
||||
];
|
||||
|
||||
export default function DriverLeaderboardPreview({ drivers, onDriverClick }: DriverLeaderboardPreviewProps) {
|
||||
const router = useRouter();
|
||||
export function DriverLeaderboardPreview({ drivers, onDriverClick, onNavigateToDrivers }: DriverLeaderboardPreviewProps) {
|
||||
const top10 = drivers.slice(0, 10);
|
||||
|
||||
const getMedalColor = (position: number) => {
|
||||
@@ -50,7 +49,6 @@ export default function DriverLeaderboardPreview({ drivers, onDriverClick }: Dri
|
||||
|
||||
return (
|
||||
<div className="rounded-xl bg-iron-gray/30 border border-charcoal-outline overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-charcoal-outline bg-iron-gray/20">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-primary-blue/20 to-primary-blue/5 border border-primary-blue/20">
|
||||
@@ -63,7 +61,7 @@ export default function DriverLeaderboardPreview({ drivers, onDriverClick }: Dri
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => router.push('/leaderboards/drivers')}
|
||||
onClick={onNavigateToDrivers}
|
||||
className="flex items-center gap-2 text-sm"
|
||||
>
|
||||
View All
|
||||
@@ -71,7 +69,6 @@ export default function DriverLeaderboardPreview({ drivers, onDriverClick }: Dri
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Leaderboard Rows */}
|
||||
<div className="divide-y divide-charcoal-outline/50">
|
||||
{top10.map((driver, index) => {
|
||||
const levelConfig = SKILL_LEVELS.find((l) => l.id === driver.skillLevel);
|
||||
@@ -84,17 +81,14 @@ export default function DriverLeaderboardPreview({ drivers, onDriverClick }: Dri
|
||||
onClick={() => onDriverClick(driver.id)}
|
||||
className="flex items-center gap-4 px-5 py-3 w-full text-left hover:bg-iron-gray/30 transition-colors group"
|
||||
>
|
||||
{/* Position */}
|
||||
<div className={`flex h-8 w-8 items-center justify-center rounded-full text-xs font-bold border ${getMedalBg(position)} ${getMedalColor(position)}`}>
|
||||
{position <= 3 ? <Crown className="w-3.5 h-3.5" /> : position}
|
||||
</div>
|
||||
|
||||
{/* Avatar */}
|
||||
<div className="relative w-9 h-9 rounded-full overflow-hidden border-2 border-charcoal-outline">
|
||||
<Image src={driver.avatarUrl} alt={driver.name} fill className="object-cover" />
|
||||
</div>
|
||||
|
||||
{/* Info */}
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-medium truncate group-hover:text-primary-blue transition-colors">
|
||||
{driver.name}
|
||||
@@ -106,7 +100,6 @@ export default function DriverLeaderboardPreview({ drivers, onDriverClick }: Dri
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<div className="text-center">
|
||||
<p className="text-primary-blue font-mono font-semibold">{driver.rating.toLocaleString()}</p>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Image from 'next/image';
|
||||
import { Users, Crown, Shield, ChevronRight } from 'lucide-react';
|
||||
import Button from '@/components/ui/Button';
|
||||
@@ -17,6 +16,7 @@ interface TeamLeaderboardPreviewProps {
|
||||
position: number;
|
||||
}[];
|
||||
onTeamClick: (id: string) => void;
|
||||
onNavigateToTeams: () => void;
|
||||
}
|
||||
|
||||
const SKILL_LEVELS = [
|
||||
@@ -26,11 +26,8 @@ const SKILL_LEVELS = [
|
||||
{ id: 'beginner', label: 'Beginner', icon: Shield, color: 'text-green-400', bgColor: 'bg-green-400/10', borderColor: 'border-green-400/30' },
|
||||
];
|
||||
|
||||
export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeaderboardPreviewProps) {
|
||||
const router = useRouter();
|
||||
const top5 = [...teams]
|
||||
.sort((a, b) => b.memberCount - a.memberCount)
|
||||
.slice(0, 5);
|
||||
export function TeamLeaderboardPreview({ teams, onTeamClick, onNavigateToTeams }: TeamLeaderboardPreviewProps) {
|
||||
const top5 = teams.slice(0, 5);
|
||||
|
||||
const getMedalColor = (position: number) => {
|
||||
switch (position) {
|
||||
@@ -52,7 +49,6 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
|
||||
return (
|
||||
<div className="rounded-xl bg-iron-gray/30 border border-charcoal-outline overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-charcoal-outline bg-iron-gray/20">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-purple-500/20 to-purple-500/5 border border-purple-500/20">
|
||||
@@ -65,7 +61,7 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => router.push('/teams/leaderboard')}
|
||||
onClick={onNavigateToTeams}
|
||||
className="flex items-center gap-2 text-sm"
|
||||
>
|
||||
View All
|
||||
@@ -73,12 +69,11 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Leaderboard Rows */}
|
||||
<div className="divide-y divide-charcoal-outline/50">
|
||||
{top5.map((team, index) => {
|
||||
const levelConfig = SKILL_LEVELS.find((l) => l.id === team.category);
|
||||
const LevelIcon = levelConfig?.icon || Shield;
|
||||
const position = index + 1;
|
||||
const position = team.position;
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -87,12 +82,10 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
onClick={() => onTeamClick(team.id)}
|
||||
className="flex items-center gap-4 px-5 py-3 w-full text-left hover:bg-iron-gray/30 transition-colors group"
|
||||
>
|
||||
{/* Position */}
|
||||
<div className={`flex h-8 w-8 items-center justify-center rounded-full text-xs font-bold border ${getMedalBg(position)} ${getMedalColor(position)}`}>
|
||||
{position <= 3 ? <Crown className="w-3.5 h-3.5" /> : position}
|
||||
</div>
|
||||
|
||||
{/* Team Logo */}
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-charcoal-outline border border-charcoal-outline overflow-hidden">
|
||||
<Image
|
||||
src={team.logoUrl || getMediaUrl('team-logo', team.id)}
|
||||
@@ -103,7 +96,6 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Info */}
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-medium truncate group-hover:text-purple-400 transition-colors">
|
||||
{team.name}
|
||||
@@ -123,7 +115,6 @@ export default function TeamLeaderboardPreview({ teams, onTeamClick }: TeamLeade
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<div className="text-center">
|
||||
<p className="text-purple-400 font-mono font-semibold">{team.memberCount}</p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import DriverIdentity from '../drivers/DriverIdentity';
|
||||
import { DriverIdentity } from '../drivers/DriverIdentity';
|
||||
import { useEffectiveDriverId } from '@/lib/hooks/useEffectiveDriverId';
|
||||
import { useInject } from '@/lib/di/hooks/useInject';
|
||||
import { LEAGUE_MEMBERSHIP_SERVICE_TOKEN, DRIVER_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useEffectiveDriverId } from "@/lib/hooks/useEffectiveDriverId";
|
||||
import { useLeagueSeasons } from "@/lib/hooks/league/useLeagueSeasons";
|
||||
import { useSponsorshipRequests } from "@/lib/hooks/league/useSponsorshipRequests";
|
||||
import { useInject } from '@/lib/di/hooks/useInject';
|
||||
import { SPONSORSHIP_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import { SPONSOR_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
|
||||
interface SponsorshipSlot {
|
||||
tier: 'main' | 'secondary';
|
||||
@@ -32,7 +32,7 @@ export function LeagueSponsorshipsSection({
|
||||
readOnly = false
|
||||
}: LeagueSponsorshipsSectionProps) {
|
||||
const currentDriverId = useEffectiveDriverId();
|
||||
const sponsorshipService = useInject(SPONSORSHIP_SERVICE_TOKEN);
|
||||
const sponsorshipService = useInject(SPONSOR_SERVICE_TOKEN);
|
||||
|
||||
const [slots, setSlots] = useState<SponsorshipSlot[]>([
|
||||
{ tier: 'main', price: 500, isOccupied: false },
|
||||
|
||||
@@ -86,25 +86,32 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
};
|
||||
|
||||
return (
|
||||
// eslint-disable-next-line gridpilot-rules/no-raw-html-in-app
|
||||
<div className="space-y-6">
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div>
|
||||
<Heading level={2} className="text-xl mb-1 flex items-center gap-2">
|
||||
<Camera className="w-5 h-5 text-primary-blue" />
|
||||
Create Your Racing Avatar
|
||||
</Heading>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-sm text-gray-400">
|
||||
Upload a photo and we will generate a unique racing avatar for you
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Photo Upload */}
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<label className="block text-sm font-medium text-gray-300 mb-3">
|
||||
Upload Your Photo *
|
||||
</label>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="flex gap-6">
|
||||
{/* Upload Area */}
|
||||
<div
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
className={`relative flex-1 flex flex-col items-center justify-center p-6 rounded-xl border-2 border-dashed cursor-pointer transition-all ${
|
||||
avatarInfo.facePhoto
|
||||
@@ -125,10 +132,12 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
{avatarInfo.isValidating ? (
|
||||
<>
|
||||
<Loader2 className="w-10 h-10 text-primary-blue animate-spin mb-3" />
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-sm text-gray-400">Validating photo...</p>
|
||||
</>
|
||||
) : avatarInfo.facePhoto ? (
|
||||
<>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="w-24 h-24 rounded-xl overflow-hidden mb-3 ring-2 ring-performance-green">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
@@ -137,18 +146,22 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-sm text-performance-green flex items-center gap-1">
|
||||
<Check className="w-4 h-4" />
|
||||
Photo uploaded
|
||||
</p>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-xs text-gray-500 mt-1">Click to change</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Upload className="w-10 h-10 text-gray-500 mb-3" />
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-sm text-gray-300 font-medium mb-1">
|
||||
Drop your photo here or click to upload
|
||||
</p>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-xs text-gray-500">
|
||||
JPEG or PNG, max 5MB
|
||||
</p>
|
||||
@@ -157,7 +170,9 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
</div>
|
||||
|
||||
{/* Preview area */}
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="w-32 flex flex-col items-center justify-center">
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="w-24 h-24 rounded-xl bg-iron-gray border border-charcoal-outline flex items-center justify-center overflow-hidden">
|
||||
{(() => {
|
||||
const selectedAvatarUrl =
|
||||
@@ -175,6 +190,7 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="text-xs text-gray-500 mt-2 text-center">Your avatar</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -184,11 +200,14 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
</div>
|
||||
|
||||
{/* Suit Color Selection */}
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<label className="block text-sm font-medium text-gray-300 mb-3 flex items-center gap-2">
|
||||
<Palette className="w-4 h-4" />
|
||||
Racing Suit Color
|
||||
</label>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{SUIT_COLORS.map((color) => (
|
||||
<button
|
||||
@@ -211,6 +230,7 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<p className="mt-2 text-xs text-gray-500">
|
||||
Selected: {SUIT_COLORS.find(c => c.value === avatarInfo.suitColor)?.label}
|
||||
</p>
|
||||
@@ -244,9 +264,11 @@ export function AvatarStep({ avatarInfo, setAvatarInfo, errors, setErrors, onGen
|
||||
{/* Generated Avatars */}
|
||||
{avatarInfo.generatedAvatars.length > 0 && (
|
||||
<div>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<label className="block text-sm font-medium text-gray-300 mb-3">
|
||||
Choose Your Avatar *
|
||||
</label>
|
||||
{/* eslint-disable-next-line gridpilot-rules/no-raw-html-in-app */}
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
{avatarInfo.generatedAvatars.map((url, index) => (
|
||||
<button
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { useState, FormEvent } from 'react';
|
||||
import Card from '@/components/ui/Card';
|
||||
import Button from '@/components/ui/Button';
|
||||
import { StepIndicator } from '@/ui/StepIndicator';
|
||||
import { PersonalInfoStep, PersonalInfo } from './PersonalInfoStep';
|
||||
import { PersonalInfoStep, PersonalInfo } from '@/ui/onboarding/PersonalInfoStep';
|
||||
import { AvatarStep, AvatarInfo } from './AvatarStep';
|
||||
import { OnboardingHeader } from '@/ui/onboarding/OnboardingHeader';
|
||||
import { OnboardingHelpText } from '@/ui/onboarding/OnboardingHelpText';
|
||||
import { OnboardingError } from '@/ui/onboarding/OnboardingError';
|
||||
import { OnboardingNavigation } from '@/ui/onboarding/OnboardingNavigation';
|
||||
import { OnboardingContainer } from '@/ui/onboarding/OnboardingContainer';
|
||||
import { OnboardingCardAccent } from '@/ui/onboarding/OnboardingCardAccent';
|
||||
import { OnboardingForm } from '@/ui/onboarding/OnboardingForm';
|
||||
|
||||
type OnboardingStep = 1 | 2;
|
||||
|
||||
@@ -173,28 +179,19 @@ export function OnboardingWizard({ onCompleted, onCompleteOnboarding, onGenerate
|
||||
const loading = false; // This would be managed by the parent component
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto px-4 py-10">
|
||||
{/* Header */}
|
||||
<div className="text-center mb-8">
|
||||
<div className="flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-primary-blue/20 to-purple-600/10 border border-primary-blue/30 mx-auto mb-4">
|
||||
<span className="text-2xl">🏁</span>
|
||||
</div>
|
||||
<h1 className="text-4xl font-bold mb-2">Welcome to GridPilot</h1>
|
||||
<p className="text-gray-400">
|
||||
Let us set up your racing profile
|
||||
</p>
|
||||
</div>
|
||||
<OnboardingContainer>
|
||||
<OnboardingHeader
|
||||
title="Welcome to GridPilot"
|
||||
subtitle="Let us set up your racing profile"
|
||||
emoji="🏁"
|
||||
/>
|
||||
|
||||
{/* Progress Indicator */}
|
||||
<StepIndicator currentStep={step} />
|
||||
|
||||
{/* Form Card */}
|
||||
<Card className="relative overflow-hidden">
|
||||
{/* Background accent */}
|
||||
<div className="absolute top-0 right-0 w-40 h-40 bg-gradient-to-bl from-primary-blue/10 to-transparent rounded-bl-full" />
|
||||
<OnboardingCardAccent />
|
||||
|
||||
<form onSubmit={handleSubmit} className="relative">
|
||||
{/* Step 1: Personal Information */}
|
||||
<OnboardingForm onSubmit={handleSubmit}>
|
||||
{step === 1 && (
|
||||
<PersonalInfoStep
|
||||
personalInfo={personalInfo}
|
||||
@@ -204,7 +201,6 @@ export function OnboardingWizard({ onCompleted, onCompleteOnboarding, onGenerate
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Step 2: Avatar Generation */}
|
||||
{step === 2 && (
|
||||
<AvatarStep
|
||||
avatarInfo={avatarInfo}
|
||||
@@ -215,66 +211,19 @@ export function OnboardingWizard({ onCompleted, onCompleteOnboarding, onGenerate
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Error Message */}
|
||||
{errors.submit && (
|
||||
<div className="mt-6 flex items-start gap-3 p-4 rounded-xl bg-red-500/10 border border-red-500/30">
|
||||
<span className="text-red-400 flex-shrink-0 mt-0.5">⚠</span>
|
||||
<p className="text-sm text-red-400">{errors.submit}</p>
|
||||
</div>
|
||||
)}
|
||||
{errors.submit && <OnboardingError message={errors.submit} />}
|
||||
|
||||
{/* Navigation Buttons */}
|
||||
<div className="mt-8 flex items-center justify-between">
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={handleBack}
|
||||
disabled={step === 1 || loading}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<span>←</span>
|
||||
Back
|
||||
</Button>
|
||||
|
||||
{step < 2 ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="primary"
|
||||
onClick={handleNext}
|
||||
disabled={loading}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
Continue
|
||||
<span>→</span>
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={loading || avatarInfo.selectedAvatarIndex === null}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<span className="animate-spin">⟳</span>
|
||||
Creating Profile...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span>✓</span>
|
||||
Complete Setup
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
<OnboardingNavigation
|
||||
onBack={handleBack}
|
||||
onNext={step < 2 ? handleNext : undefined}
|
||||
isLastStep={step === 2}
|
||||
canSubmit={avatarInfo.selectedAvatarIndex !== null}
|
||||
loading={loading}
|
||||
/>
|
||||
</OnboardingForm>
|
||||
</Card>
|
||||
|
||||
{/* Help Text */}
|
||||
<p className="text-center text-xs text-gray-500 mt-6">
|
||||
Your avatar will be AI-generated based on your photo and chosen suit color
|
||||
</p>
|
||||
</div>
|
||||
<OnboardingHelpText />
|
||||
</OnboardingContainer>
|
||||
);
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import { User, Clock, ChevronRight } from 'lucide-react';
|
||||
import Input from '@/components/ui/Input';
|
||||
import Heading from '@/components/ui/Heading';
|
||||
import CountrySelect from '@/components/ui/CountrySelect';
|
||||
|
||||
export interface PersonalInfo {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
displayName: string;
|
||||
country: string;
|
||||
timezone: string;
|
||||
}
|
||||
|
||||
interface FormErrors {
|
||||
[key: string]: string | undefined;
|
||||
}
|
||||
|
||||
interface PersonalInfoStepProps {
|
||||
personalInfo: PersonalInfo;
|
||||
setPersonalInfo: (info: PersonalInfo) => void;
|
||||
errors: FormErrors;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
const TIMEZONES = [
|
||||
{ value: 'America/New_York', label: 'Eastern Time (ET)' },
|
||||
{ value: 'America/Chicago', label: 'Central Time (CT)' },
|
||||
{ value: 'America/Denver', label: 'Mountain Time (MT)' },
|
||||
{ value: 'America/Los_Angeles', label: 'Pacific Time (PT)' },
|
||||
{ value: 'Europe/London', label: 'Greenwich Mean Time (GMT)' },
|
||||
{ value: 'Europe/Berlin', label: 'Central European Time (CET)' },
|
||||
{ value: 'Europe/Paris', label: 'Central European Time (CET)' },
|
||||
{ value: 'Australia/Sydney', label: 'Australian Eastern Time (AET)' },
|
||||
{ value: 'Asia/Tokyo', label: 'Japan Standard Time (JST)' },
|
||||
{ value: 'America/Sao_Paulo', label: 'Brasília Time (BRT)' },
|
||||
];
|
||||
|
||||
export function PersonalInfoStep({ personalInfo, setPersonalInfo, errors, loading }: PersonalInfoStepProps) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<Heading level={2} className="text-xl mb-1 flex items-center gap-2">
|
||||
<User className="w-5 h-5 text-primary-blue" />
|
||||
Personal Information
|
||||
</Heading>
|
||||
<p className="text-sm text-gray-400">
|
||||
Tell us a bit about yourself
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label htmlFor="firstName" className="block text-sm font-medium text-gray-300 mb-2">
|
||||
First Name *
|
||||
</label>
|
||||
<Input
|
||||
id="firstName"
|
||||
type="text"
|
||||
value={personalInfo.firstName}
|
||||
onChange={(e) =>
|
||||
setPersonalInfo({ ...personalInfo, firstName: e.target.value })
|
||||
}
|
||||
error={!!errors.firstName}
|
||||
errorMessage={errors.firstName}
|
||||
placeholder="John"
|
||||
disabled={loading}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="lastName" className="block text-sm font-medium text-gray-300 mb-2">
|
||||
Last Name *
|
||||
</label>
|
||||
<Input
|
||||
id="lastName"
|
||||
type="text"
|
||||
value={personalInfo.lastName}
|
||||
onChange={(e) =>
|
||||
setPersonalInfo({ ...personalInfo, lastName: e.target.value })
|
||||
}
|
||||
error={!!errors.lastName}
|
||||
errorMessage={errors.lastName}
|
||||
placeholder="Racer"
|
||||
disabled={loading}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="displayName" className="block text-sm font-medium text-gray-300 mb-2">
|
||||
Display Name * <span className="text-gray-500 font-normal">(shown publicly)</span>
|
||||
</label>
|
||||
<Input
|
||||
id="displayName"
|
||||
type="text"
|
||||
value={personalInfo.displayName}
|
||||
onChange={(e) =>
|
||||
setPersonalInfo({ ...personalInfo, displayName: e.target.value })
|
||||
}
|
||||
error={!!errors.displayName}
|
||||
errorMessage={errors.displayName}
|
||||
placeholder="SpeedyRacer42"
|
||||
disabled={loading}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label htmlFor="country" className="block text-sm font-medium text-gray-300 mb-2">
|
||||
Country *
|
||||
</label>
|
||||
<CountrySelect
|
||||
value={personalInfo.country}
|
||||
onChange={(value) =>
|
||||
setPersonalInfo({ ...personalInfo, country: value })
|
||||
}
|
||||
error={!!errors.country}
|
||||
errorMessage={errors.country ?? ''}
|
||||
disabled={loading}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="timezone" className="block text-sm font-medium text-gray-300 mb-2">
|
||||
Timezone
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Clock className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 z-10" />
|
||||
<select
|
||||
id="timezone"
|
||||
value={personalInfo.timezone}
|
||||
onChange={(e) =>
|
||||
setPersonalInfo({ ...personalInfo, timezone: e.target.value })
|
||||
}
|
||||
className="block w-full rounded-md border-0 px-4 py-3 pl-10 bg-iron-gray text-white shadow-sm ring-1 ring-inset ring-charcoal-outline placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-primary-blue transition-all duration-150 sm:text-sm appearance-none cursor-pointer"
|
||||
disabled={loading}
|
||||
>
|
||||
<option value="">Select timezone</option>
|
||||
{TIMEZONES.map((tz) => (
|
||||
<option key={tz.value} value={tz.value}>
|
||||
{tz.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<ChevronRight className="absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 rotate-90" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
70
apps/website/components/sponsors/MetricBuilders.ts
Normal file
70
apps/website/components/sponsors/MetricBuilders.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { Eye, TrendingUp, Users, Star, Calendar, Zap } from 'lucide-react';
|
||||
|
||||
export interface SponsorMetric {
|
||||
icon: React.ElementType;
|
||||
label: string;
|
||||
value: string | number;
|
||||
color?: string;
|
||||
trend?: {
|
||||
value: number;
|
||||
isPositive: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export const MetricBuilders = {
|
||||
views: (value: number, label = 'Views'): SponsorMetric => ({
|
||||
icon: Eye,
|
||||
label,
|
||||
value,
|
||||
color: 'text-primary-blue',
|
||||
}),
|
||||
|
||||
engagement: (value: number | string): SponsorMetric => ({
|
||||
icon: TrendingUp,
|
||||
label: 'Engagement',
|
||||
value: typeof value === 'number' ? `${value}%` : value,
|
||||
color: 'text-performance-green',
|
||||
}),
|
||||
|
||||
reach: (value: number): SponsorMetric => ({
|
||||
icon: Users,
|
||||
label: 'Est. Reach',
|
||||
value,
|
||||
color: 'text-purple-400',
|
||||
}),
|
||||
|
||||
rating: (value: number | string, label = 'Rating'): SponsorMetric => ({
|
||||
icon: Star,
|
||||
label,
|
||||
value,
|
||||
color: 'text-warning-amber',
|
||||
}),
|
||||
|
||||
races: (value: number): SponsorMetric => ({
|
||||
icon: Calendar,
|
||||
label: 'Races',
|
||||
value,
|
||||
color: 'text-neon-aqua',
|
||||
}),
|
||||
|
||||
members: (value: number): SponsorMetric => ({
|
||||
icon: Users,
|
||||
label: 'Members',
|
||||
value,
|
||||
color: 'text-purple-400',
|
||||
}),
|
||||
|
||||
impressions: (value: number): SponsorMetric => ({
|
||||
icon: Eye,
|
||||
label: 'Impressions',
|
||||
value,
|
||||
color: 'text-primary-blue',
|
||||
}),
|
||||
|
||||
sof: (value: number | string): SponsorMetric => ({
|
||||
icon: Zap,
|
||||
label: 'Avg SOF',
|
||||
value,
|
||||
color: 'text-warning-amber',
|
||||
}),
|
||||
};
|
||||
63
apps/website/components/sponsors/SlotTemplates.ts
Normal file
63
apps/website/components/sponsors/SlotTemplates.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
export interface SponsorshipSlot {
|
||||
tier: 'main' | 'secondary';
|
||||
available: boolean;
|
||||
price: number;
|
||||
currency?: string;
|
||||
benefits: string[];
|
||||
}
|
||||
|
||||
export const SlotTemplates = {
|
||||
league: (mainAvailable: boolean, secondaryAvailable: number, mainPrice: number, secondaryPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Hood placement', 'League banner', 'Prominent logo'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable > 0,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Side logo placement', 'League page listing'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable > 1,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Side logo placement', 'League page listing'],
|
||||
},
|
||||
],
|
||||
|
||||
race: (mainAvailable: boolean, mainPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Race title sponsor', 'Stream overlay', 'Results banner'],
|
||||
},
|
||||
],
|
||||
|
||||
driver: (available: boolean, price: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available,
|
||||
price,
|
||||
benefits: ['Suit logo', 'Helmet branding', 'Social mentions'],
|
||||
},
|
||||
],
|
||||
|
||||
team: (mainAvailable: boolean, secondaryAvailable: boolean, mainPrice: number, secondaryPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Team name suffix', 'Car livery', 'All driver suits'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Team page logo', 'Minor livery placement'],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -2,26 +2,20 @@
|
||||
|
||||
import Button from '@/components/ui/Button';
|
||||
import Card from '@/components/ui/Card';
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
import { useInject } from '@/lib/di/hooks/useInject';
|
||||
import { SPONSORSHIP_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import { SPONSOR_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import {
|
||||
Activity,
|
||||
Calendar,
|
||||
Check,
|
||||
Eye,
|
||||
Loader2,
|
||||
MessageCircle,
|
||||
Shield,
|
||||
Star,
|
||||
Target,
|
||||
TrendingUp,
|
||||
Trophy,
|
||||
Users,
|
||||
Zap
|
||||
Target
|
||||
} from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { SponsorMetric, SponsorshipSlot } from './SponsorInsightsCardTypes';
|
||||
import { getTierStyles, getEntityLabel, getEntityIcon, getSponsorshipTagline } from './SponsorInsightsCardHelpers';
|
||||
|
||||
// ============================================================================
|
||||
// TYPES
|
||||
@@ -29,25 +23,6 @@ import React, { useCallback, useState } from 'react';
|
||||
|
||||
export type EntityType = 'league' | 'race' | 'driver' | 'team';
|
||||
|
||||
export interface SponsorMetric {
|
||||
icon: React.ElementType;
|
||||
label: string;
|
||||
value: string | number;
|
||||
color?: string;
|
||||
trend?: {
|
||||
value: number;
|
||||
isPositive: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SponsorshipSlot {
|
||||
tier: 'main' | 'secondary';
|
||||
available: boolean;
|
||||
price: number;
|
||||
currency?: string;
|
||||
benefits: string[];
|
||||
}
|
||||
|
||||
export interface SponsorInsightsProps {
|
||||
// Entity info
|
||||
entityType: EntityType;
|
||||
@@ -85,55 +60,6 @@ export interface SponsorInsightsProps {
|
||||
onSponsorshipRequested?: (tier: 'main' | 'secondary') => void;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HELPER FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
function getTierStyles(tier: SponsorInsightsProps['tier']) {
|
||||
switch (tier) {
|
||||
case 'premium':
|
||||
return {
|
||||
badge: 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30',
|
||||
gradient: 'from-yellow-500/10 via-transparent to-transparent',
|
||||
};
|
||||
case 'standard':
|
||||
return {
|
||||
badge: 'bg-blue-500/20 text-blue-400 border-blue-500/30',
|
||||
gradient: 'from-blue-500/10 via-transparent to-transparent',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
badge: 'bg-gray-500/20 text-gray-400 border-gray-500/30',
|
||||
gradient: 'from-gray-500/10 via-transparent to-transparent',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getEntityLabel(type: EntityType): string {
|
||||
switch (type) {
|
||||
case 'league': return 'League';
|
||||
case 'race': return 'Race';
|
||||
case 'driver': return 'Driver';
|
||||
case 'team': return 'Team';
|
||||
}
|
||||
}
|
||||
|
||||
function getEntityIcon(type: EntityType) {
|
||||
switch (type) {
|
||||
case 'league': return Trophy;
|
||||
case 'race': return Zap;
|
||||
case 'driver': return Users;
|
||||
case 'team': return Users;
|
||||
}
|
||||
}
|
||||
|
||||
function getSponsorshipTagline(type: EntityType): string {
|
||||
if (type === 'league') {
|
||||
return 'Reach engaged sim racers by sponsoring a season in this league.';
|
||||
}
|
||||
return `Reach engaged sim racers by sponsoring this ${getEntityLabel(type).toLowerCase()}`;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// COMPONENT
|
||||
// ============================================================================
|
||||
@@ -156,7 +82,7 @@ export default function SponsorInsightsCard({
|
||||
}: SponsorInsightsProps) {
|
||||
// TODO components should not fetch any data
|
||||
const router = useRouter();
|
||||
const sponsorshipService = useInject(SPONSORSHIP_SERVICE_TOKEN);
|
||||
const sponsorshipService = useInject(SPONSOR_SERVICE_TOKEN);
|
||||
const tierStyles = getTierStyles(tier);
|
||||
const EntityIcon = getEntityIcon(entityType);
|
||||
|
||||
@@ -254,9 +180,9 @@ export default function SponsorInsightsCard({
|
||||
{/* Key Metrics Grid */}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-3 mb-4">
|
||||
{metrics.slice(0, 4).map((metric, index) => {
|
||||
const Icon = metric.icon;
|
||||
const Icon = metric.icon as React.ComponentType<{ className?: string }>;
|
||||
return (
|
||||
<div
|
||||
<div
|
||||
key={index}
|
||||
className="bg-iron-gray/50 rounded-lg p-3 border border-charcoal-outline"
|
||||
>
|
||||
@@ -439,157 +365,4 @@ export default function SponsorInsightsCard({
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HELPER HOOK: useSponsorMode
|
||||
// ============================================================================
|
||||
|
||||
export function useSponsorMode(): boolean {
|
||||
const { session } = useAuth();
|
||||
const [isSponsor, setIsSponsor] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!session?.user) {
|
||||
setIsSponsor(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check session.user.role for sponsor
|
||||
const role = session.user?.role;
|
||||
if (role === 'sponsor') {
|
||||
setIsSponsor(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: check email patterns
|
||||
const email = session.user.email?.toLowerCase() || '';
|
||||
const displayName = session.user.displayName?.toLowerCase() || '';
|
||||
|
||||
setIsSponsor(email.includes('sponsor') || displayName.includes('sponsor'));
|
||||
}, [session]);
|
||||
|
||||
return isSponsor;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// COMMON METRIC BUILDERS
|
||||
// ============================================================================
|
||||
|
||||
export const MetricBuilders = {
|
||||
views: (value: number, label = 'Views'): SponsorMetric => ({
|
||||
icon: Eye,
|
||||
label,
|
||||
value,
|
||||
color: 'text-primary-blue',
|
||||
}),
|
||||
|
||||
engagement: (value: number | string): SponsorMetric => ({
|
||||
icon: TrendingUp,
|
||||
label: 'Engagement',
|
||||
value: typeof value === 'number' ? `${value}%` : value,
|
||||
color: 'text-performance-green',
|
||||
}),
|
||||
|
||||
reach: (value: number): SponsorMetric => ({
|
||||
icon: Users,
|
||||
label: 'Est. Reach',
|
||||
value,
|
||||
color: 'text-purple-400',
|
||||
}),
|
||||
|
||||
rating: (value: number | string, label = 'Rating'): SponsorMetric => ({
|
||||
icon: Star,
|
||||
label,
|
||||
value,
|
||||
color: 'text-warning-amber',
|
||||
}),
|
||||
|
||||
races: (value: number): SponsorMetric => ({
|
||||
icon: Calendar,
|
||||
label: 'Races',
|
||||
value,
|
||||
color: 'text-neon-aqua',
|
||||
}),
|
||||
|
||||
members: (value: number): SponsorMetric => ({
|
||||
icon: Users,
|
||||
label: 'Members',
|
||||
value,
|
||||
color: 'text-purple-400',
|
||||
}),
|
||||
|
||||
impressions: (value: number): SponsorMetric => ({
|
||||
icon: Eye,
|
||||
label: 'Impressions',
|
||||
value,
|
||||
color: 'text-primary-blue',
|
||||
}),
|
||||
|
||||
sof: (value: number | string): SponsorMetric => ({
|
||||
icon: Zap,
|
||||
label: 'Avg SOF',
|
||||
value,
|
||||
color: 'text-warning-amber',
|
||||
}),
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// SLOT TEMPLATES
|
||||
// ============================================================================
|
||||
|
||||
export const SlotTemplates = {
|
||||
league: (mainAvailable: boolean, secondaryAvailable: number, mainPrice: number, secondaryPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Hood placement', 'League banner', 'Prominent logo'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable > 0,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Side logo placement', 'League page listing'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable > 1,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Side logo placement', 'League page listing'],
|
||||
},
|
||||
],
|
||||
|
||||
race: (mainAvailable: boolean, mainPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Race title sponsor', 'Stream overlay', 'Results banner'],
|
||||
},
|
||||
],
|
||||
|
||||
driver: (available: boolean, price: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available,
|
||||
price,
|
||||
benefits: ['Suit logo', 'Helmet branding', 'Social mentions'],
|
||||
},
|
||||
],
|
||||
|
||||
team: (mainAvailable: boolean, secondaryAvailable: boolean, mainPrice: number, secondaryPrice: number): SponsorshipSlot[] => [
|
||||
{
|
||||
tier: 'main',
|
||||
available: mainAvailable,
|
||||
price: mainPrice,
|
||||
benefits: ['Team name suffix', 'Car livery', 'All driver suits'],
|
||||
},
|
||||
{
|
||||
tier: 'secondary',
|
||||
available: secondaryAvailable,
|
||||
price: secondaryPrice,
|
||||
benefits: ['Team page logo', 'Minor livery placement'],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { EntityType } from './SponsorInsightsCard';
|
||||
import { Trophy, Zap, Users, Eye, TrendingUp, Star, Calendar, MessageCircle, Activity, Shield, Target } from 'lucide-react';
|
||||
|
||||
export interface TierStyles {
|
||||
badge: string;
|
||||
gradient: string;
|
||||
}
|
||||
|
||||
export function getTierStyles(tier: 'premium' | 'standard' | 'starter'): TierStyles {
|
||||
switch (tier) {
|
||||
case 'premium':
|
||||
return {
|
||||
badge: 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30',
|
||||
gradient: 'from-yellow-500/10 via-transparent to-transparent',
|
||||
};
|
||||
case 'standard':
|
||||
return {
|
||||
badge: 'bg-blue-500/20 text-blue-400 border-blue-500/30',
|
||||
gradient: 'from-blue-500/10 via-transparent to-transparent',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
badge: 'bg-gray-500/20 text-gray-400 border-gray-500/30',
|
||||
gradient: 'from-gray-500/10 via-transparent to-transparent',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function getEntityLabel(type: EntityType): string {
|
||||
switch (type) {
|
||||
case 'league': return 'League';
|
||||
case 'race': return 'Race';
|
||||
case 'driver': return 'Driver';
|
||||
case 'team': return 'Team';
|
||||
}
|
||||
}
|
||||
|
||||
export function getEntityIcon(type: EntityType) {
|
||||
switch (type) {
|
||||
case 'league': return Trophy;
|
||||
case 'race': return Zap;
|
||||
case 'driver': return Users;
|
||||
case 'team': return Users;
|
||||
}
|
||||
}
|
||||
|
||||
export function getSponsorshipTagline(type: EntityType): string {
|
||||
if (type === 'league') {
|
||||
return 'Reach engaged sim racers by sponsoring a season in this league.';
|
||||
}
|
||||
return `Reach engaged sim racers by sponsoring this ${getEntityLabel(type).toLowerCase()}`;
|
||||
}
|
||||
20
apps/website/components/sponsors/SponsorInsightsCardTypes.ts
Normal file
20
apps/website/components/sponsors/SponsorInsightsCardTypes.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ComponentType } from 'react';
|
||||
|
||||
export interface SponsorMetric {
|
||||
icon: ComponentType;
|
||||
label: string;
|
||||
value: string | number;
|
||||
color?: string;
|
||||
trend?: {
|
||||
value: number;
|
||||
isPositive: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SponsorshipSlot {
|
||||
tier: 'main' | 'secondary';
|
||||
available: boolean;
|
||||
price: number;
|
||||
currency?: string;
|
||||
benefits: string[];
|
||||
}
|
||||
29
apps/website/components/sponsors/useSponsorMode.ts
Normal file
29
apps/website/components/sponsors/useSponsorMode.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
import React from 'react';
|
||||
|
||||
export function useSponsorMode(): boolean {
|
||||
const { session } = useAuth();
|
||||
const [isSponsor, setIsSponsor] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!session) {
|
||||
setIsSponsor(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check session.role for sponsor
|
||||
const role = session.role;
|
||||
if (role === 'sponsor') {
|
||||
setIsSponsor(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: check email patterns
|
||||
const email = session.email?.toLowerCase() || '';
|
||||
const displayName = session.displayName?.toLowerCase() || '';
|
||||
|
||||
setIsSponsor(email.includes('sponsor') || displayName.includes('sponsor'));
|
||||
}, [session]);
|
||||
|
||||
return isSponsor;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Image from 'next/image';
|
||||
import { Award, ChevronRight, Crown, Trophy, Users } from 'lucide-react';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import Button from '@/components/ui/Button';
|
||||
import { getMediaUrl } from '@/lib/utilities/media';
|
||||
|
||||
@@ -111,7 +112,7 @@ export default function TeamLeaderboardPreview({
|
||||
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => router.push('/teams/leaderboard')}
|
||||
onClick={() => router.push(routes.team.detail('leaderboard'))}
|
||||
className="flex items-center gap-2 text-sm"
|
||||
>
|
||||
View Full Leaderboard
|
||||
|
||||
18
apps/website/components/ui/AuthContainer.tsx
Normal file
18
apps/website/components/ui/AuthContainer.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* AuthContainer - UI component for auth page layouts
|
||||
*
|
||||
* Pure presentation component for auth page container.
|
||||
* Used by auth layout to provide consistent styling.
|
||||
*/
|
||||
|
||||
interface AuthContainerProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function AuthContainer({ children }: AuthContainerProps) {
|
||||
return (
|
||||
<div className="min-h-screen bg-deep-graphite flex items-center justify-center p-4">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
22
apps/website/components/ui/AuthError.tsx
Normal file
22
apps/website/components/ui/AuthError.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* AuthError - UI component for auth page error states
|
||||
*
|
||||
* Pure presentation component for displaying auth-related errors.
|
||||
* Used by page.tsx files to handle PageQuery errors.
|
||||
*/
|
||||
|
||||
import { ErrorBanner } from './ErrorBanner';
|
||||
|
||||
interface AuthErrorProps {
|
||||
action: string;
|
||||
}
|
||||
|
||||
export function AuthError({ action }: AuthErrorProps) {
|
||||
return (
|
||||
<ErrorBanner
|
||||
message={`Failed to load ${action} page`}
|
||||
title="Error"
|
||||
variant="error"
|
||||
/>
|
||||
);
|
||||
}
|
||||
24
apps/website/components/ui/AuthLoading.tsx
Normal file
24
apps/website/components/ui/AuthLoading.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* AuthLoading - UI component for auth page loading states
|
||||
*
|
||||
* Pure presentation component for displaying auth-related loading.
|
||||
* Used by LoginClient.tsx for authenticated redirect states.
|
||||
*/
|
||||
|
||||
import { LoadingWrapper } from '../shared/state/LoadingWrapper';
|
||||
|
||||
interface AuthLoadingProps {
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export function AuthLoading({ message = 'Authenticating...' }: AuthLoadingProps) {
|
||||
return (
|
||||
<main className="min-h-screen bg-deep-graphite flex items-center justify-center">
|
||||
<LoadingWrapper
|
||||
variant="spinner"
|
||||
message={message}
|
||||
size="lg"
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
31
apps/website/components/ui/ErrorBanner.tsx
Normal file
31
apps/website/components/ui/ErrorBanner.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* ErrorBanner - UI component for displaying error messages
|
||||
*
|
||||
* Pure UI element for error display in templates and components.
|
||||
* No business logic, just presentation.
|
||||
*/
|
||||
|
||||
export interface ErrorBannerProps {
|
||||
message: string;
|
||||
title?: string;
|
||||
variant?: 'error' | 'warning' | 'info';
|
||||
}
|
||||
|
||||
export function ErrorBanner({ message, title, variant = 'error' }: ErrorBannerProps) {
|
||||
const baseClasses = 'px-4 py-3 rounded-lg border flex items-start gap-3';
|
||||
|
||||
const variantClasses = {
|
||||
error: 'bg-racing-red/10 border-racing-red text-racing-red',
|
||||
warning: 'bg-yellow-500/10 border-yellow-500 text-yellow-300',
|
||||
info: 'bg-primary-blue/10 border-primary-blue text-primary-blue',
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`${baseClasses} ${variantClasses[variant]}`}>
|
||||
<div className="flex-1">
|
||||
{title && <div className="font-medium">{title}</div>}
|
||||
<div className="text-sm opacity-90">{message}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user