import React, { useState, useEffect, useCallback } from 'react'; import Card from './components/Card'; import Loader from './components/Loader'; import Button from './components/Button'; import WeatherIcon from './components/WeatherIcon'; import { generateWeatherForecast, getOutfitSuggestion, generateOutfitImage } from './services/geminiService'; import type { Weather, OutfitSuggestion } from './types'; const App: React.FC = () => { const [location, setLocation] = useState(null); const [weather, setWeather] = useState(null); const [wardrobe, setWardrobe] = useState('- A pair of blue jeans\n- A white cotton t-shirt\n- Black denim jeans\n- A pair of sneakers\n- A warm wool sweater\n- Linen shorts\n- A waterproof rain jacket'); const [suggestion, setSuggestion] = useState(null); const [outfitImage, setOutfitImage] = useState(null); const [isLoading, setIsLoading] = useState(true); const [isGenerating, setIsGenerating] = useState(false); const [error, setError] = useState(null); const fetchWeather = useCallback(async (coords: GeolocationCoordinates) => { setIsLoading(true); setError(null); try { const weatherData = await generateWeatherForecast(coords.latitude, coords.longitude); setWeather(weatherData); } catch (err) { setError('Could not fetch weather data. Please try again later.'); console.error(err); } finally { setIsLoading(false); } }, []); useEffect(() => { navigator.geolocation.getCurrentPosition( (position) => { setLocation(position.coords); fetchWeather(position.coords); }, (geoError) => { setError('Geolocation is required. Please enable it in your browser settings.'); console.error(geoError); setIsLoading(false); } ); // eslint-disable-next-line react-hooks/exhaustive-deps }, [fetchWeather]); const handleGenerateSuggestion = async () => { if (!weather || !wardrobe.trim()) { setError("Weather data and wardrobe inventory are required."); return; } setIsGenerating(true); setError(null); setSuggestion(null); setOutfitImage(null); try { const outfitSuggestion = await getOutfitSuggestion(weather, wardrobe); setSuggestion(outfitSuggestion); if (outfitSuggestion.outfit) { const imageUrl = await generateOutfitImage(outfitSuggestion.outfit); setOutfitImage(imageUrl); } } catch (err) { setError('Failed to generate outfit suggestion. The model may be busy. Please try again.'); console.error(err); } finally { setIsGenerating(false); } }; return (

ClothCast

Your AI-Powered Outfit Forecaster

{/* Left Column: Inputs */}
} >

List the clothes you have available. Be as descriptive as you like!