import React from 'react'; import { Box, TextField, Button, Typography, CircularProgress } from '@mui/material'; import RateReviewIcon from '@mui/icons-material/RateReview'; import { analyzeSentiment } from '../lib/api'; function ReviewInput({ currentReview, setCurrentReview, isLoading, setIsLoading, setHasError, setErrorMessage, setAnalysisResult, addToPreviousAnalyses }) { const handleReviewChange = (e) => { setCurrentReview(e.target.value); }; const handleSubmit = async (e) => { e.preventDefault(); if (!currentReview) { setHasError(true); setErrorMessage('Please enter a review to analyze.'); return; } setIsLoading(true); setHasError(false); setErrorMessage(''); try { const result = await analyzeSentiment(currentReview); setAnalysisResult(result); addToPreviousAnalyses({ ...result, text: currentReview }); } catch (error) { console.error('Error analyzing sentiment:', error); setHasError(true); setErrorMessage( error.message || 'An error occurred while analyzing the review. Please try again.' ); } finally { setIsLoading(false); } }; return ( Enter Movie Review ); } export default ReviewInput;