'use client';

import type { Result } from '@/lib/contracts/Result';
import type { SponsorshipRequestsViewData } from '@/lib/view-data/SponsorshipRequestsViewData';
import { SponsorshipRequestsTemplate } from '@/templates/SponsorshipRequestsTemplate';

interface SponsorshipRequestsClientProps {
  viewData: SponsorshipRequestsViewData;
  onAccept: (requestId: string) => Promise<Result<void, string>>;
  onReject: (requestId: string, reason?: string) => Promise<Result<void, string>>;
}

export function SponsorshipRequestsClient({ viewData, onAccept, onReject }: SponsorshipRequestsClientProps) {
  const handleAccept = async (requestId: string) => {
    const result = await onAccept(requestId);
    if (result.isErr()) {
      console.error('Failed to accept request:', result.getError());
    }
  };

  const handleReject = async (requestId: string, reason?: string) => {
    const result = await onReject(requestId, reason);
    if (result.isErr()) {
      console.error('Failed to reject request:', result.getError());
    }
  };

  return (
    <SponsorshipRequestsTemplate
      viewData={viewData}
      onAccept={handleAccept}
      onReject={handleReject}
    />
  );
}
