'use client'; import React, { useState, useEffect } from 'react'; import Card from '@/components/ui/Card'; import Button from '@/components/ui/Button'; import { Clock, Check, X, DollarSign, MessageCircle, User, Building } from 'lucide-react'; export interface PendingRequestDTO { id: string; sponsorId: string; sponsorName: string; sponsorLogo?: string; tier: 'main' | 'secondary'; offeredAmount: number; currency: string; formattedAmount: string; message?: string; createdAt: Date; platformFee: number; netAmount: number; } interface PendingSponsorshipRequestsProps { entityType: 'driver' | 'team' | 'race' | 'season'; entityId: string; entityName: string; requests: PendingRequestDTO[]; onAccept: (requestId: string) => Promise; onReject: (requestId: string, reason?: string) => Promise; isLoading?: boolean; } export default function PendingSponsorshipRequests({ entityType, entityId, entityName, requests, onAccept, onReject, isLoading = false, }: PendingSponsorshipRequestsProps) { const [processingId, setProcessingId] = useState(null); const [rejectModalId, setRejectModalId] = useState(null); const [rejectReason, setRejectReason] = useState(''); const handleAccept = async (requestId: string) => { setProcessingId(requestId); try { await onAccept(requestId); } finally { setProcessingId(null); } }; const handleReject = async (requestId: string) => { setProcessingId(requestId); try { await onReject(requestId, rejectReason || undefined); setRejectModalId(null); setRejectReason(''); } finally { setProcessingId(null); } }; if (isLoading) { return (
Loading sponsorship requests...
); } if (requests.length === 0) { return (

No pending sponsorship requests

When sponsors apply to sponsor this {entityType}, their requests will appear here. Sponsorships are attached to seasons, so you can change partners from season to season.

); } return (

Sponsorship Requests

{requests.length} pending
{requests.map((request) => { const isProcessing = processingId === request.id; const isRejecting = rejectModalId === request.id; return (
{/* Reject Modal */} {isRejecting && (

Reject sponsorship from {request.sponsorName}?