"use client"; import { useMemo } from "react"; import { getCoursePlanGenerationErrorMessage, type CoursePlanGenerationError } from "./coursePlanApi"; interface LearnAnythingErrorStateProps { error: CoursePlanGenerationError; isGenerating: boolean; onRetry: () => void; canRetry: boolean; } /** * Error state display for the course-plan flow. * Shows appropriate error messages and retry options based on error type. */ export function LearnAnythingErrorState({ error, isGenerating, onRetry, canRetry, }: LearnAnythingErrorStateProps) { const message = useMemo(() => getCoursePlanGenerationErrorMessage(error), [error]); // Determine error type for styling const isAuthError = error.kind === "auth"; const isRateLimitError = error.kind === "rate-limit"; const isNetworkOrServerError = error.kind === "network" || error.kind === "server" || error.kind === "unknown"; return (
{message}
{/* Additional context for certain errors */} {isAuthError && (Authentication required to generate course plans
)} {isRateLimitError && (Free generation limit reached for now
)} {/* Retry button - only shown for retryable errors */} {canRetry && !isGenerating && (Please sign in to access course plan generation
Your starter outline is still available above
Error code: {error.status} {error.retryAfter && ` - Retry in ${error.retryAfter}s`}
)}