diff --git a/components/dashboard/PortfolioSummary.tsx b/components/dashboard/PortfolioSummary.tsx index ea5daf56..5b14994d 100644 --- a/components/dashboard/PortfolioSummary.tsx +++ b/components/dashboard/PortfolioSummary.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent, useMemo, useState } from "react"; +import React, { FunctionComponent, useMemo, useState, useEffect } from "react"; import { TEXT_TYPE } from "@constants/typography"; import Typography from "@components/UI/typography/typography"; import { Doughnut } from "react-chartjs-2"; @@ -10,6 +10,8 @@ import cursor from '../../public/icons/cursor.png'; import cursorPointer from '../../public/icons/pointer-cursor.png'; import ClaimModal from "../discover/claimModal"; import SuccessModal from "../discover/successModal"; +import Loading from "@components/skeletons/loading"; + Chart.register(ArcElement, DoughnutController, Tooltip); type PortfolioSummaryProps = { @@ -42,7 +44,16 @@ const ChartEntry: FunctionComponent = ({ }; const PortfolioSummary: FunctionComponent = ({ title, data, totalBalance, isProtocol, minSlicePercentage = 0.05 }) => { - +const [loading, setLoading] = useState(true); // Add loading state + // Simulate data fetching + useEffect(() => { + const fetchData = async () => { + // Simulate an API call + await new Promise(resolve => setTimeout(resolve, 2000)); // Simulate delay + setLoading(false); + }; + fetchData(); + }, []); const normalizeMinValue = (data: ChartItem[]) => { return data.map(entry => Number(entry.itemValue) < totalBalance * minSlicePercentage ? @@ -85,7 +96,10 @@ const PortfolioSummary: FunctionComponent = ({ title, dat const [showClaimModal, setShowClaimModal] = useState(false); const [showSuccessModal, setShowSuccessModal] = useState(false); - return data.length > 0 ? ( + return ( + + + {data.length > 0 ? (
@@ -135,7 +149,9 @@ const PortfolioSummary: FunctionComponent = ({ title, dat
- ) : null; + ) : null} +
+ ); } -export default PortfolioSummary; \ No newline at end of file +export default PortfolioSummary;