import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; interface Detail { token: string; gains: number; price_at_creation: number; price_now: number; } const Modal: React.FC<{ isOpen: boolean; onClose: () => void; item: { username: string; points: number } }> = ({ isOpen, onClose, item }) => { const [details, setDetails] = useState(null); // Specify null as the initial type useEffect(() => { if (isOpen && item) { const fetchDetails = async () => { try { const response = await fetch(`https://api.callfi.io/get_user_callouts.php?tag=${item.username}`); if (!response.ok) { throw new Error('Network response was not ok'); } const data = await response.json(); setDetails(data); } catch (error) { console.error('Failed to fetch user details:', error); } }; fetchDetails(); } }, [isOpen, item]); if (!isOpen) return null; return (

{item.username}s Callouts

0 ? 'text-green-500' : 'text-red-500' }`} > Total Gains : {item.points.toFixed(2)} x

{details !== null ? (
{details.map((detail) => (

0 ? 'text-green-500' : 'text-red-400' }`} > {detail.token}: {detail.gains.toFixed(2)}x [ {detail.price_at_creation.toFixed(8) + ' => ' + detail.price_now.toFixed(8)} ]

))}
) : (

Loading...

)}
); }; export default Modal;