import React, { useState, useEffect } from 'react' import { profileAPI, likeAPI, API_BASE_URL } from '../api' import '../styles/discover.css' export default function Discover() { const [profiles, setProfiles] = useState([]) const [currentIndex, setCurrentIndex] = useState(0) const [isLoading, setIsLoading] = useState(true) const [error, setError] = useState('') useEffect(() => { loadProfiles() }, []) const loadProfiles = async () => { try { setIsLoading(true) const response = await profileAPI.discoverProfiles() setProfiles(response.data || []) } catch (err) { setError('Failed to load profiles') } finally { setIsLoading(false) } } const handleLike = async () => { if (currentIndex >= profiles.length) return const profile = profiles[currentIndex] try { const response = await likeAPI.likeUser(profile.id) if (response.data.is_match) { alert(`It's a match with ${profile.display_name}!`) } nextProfile() } catch (err) { setError(err.response?.data?.detail || 'Failed to like profile') } } const handlePass = () => { nextProfile() } const nextProfile = () => { if (currentIndex < profiles.length - 1) { setCurrentIndex((prev) => prev + 1) } else { setError('No more profiles to discover') } } if (isLoading) { return
Come back later for new matches!
{profile.location}
{profile.bio &&{profile.bio}
} {profile.interests && profile.interests.length > 0 && (