Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PortfolioSummary.tsx #938

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions components/dashboard/PortfolioSummary.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 = {
Expand Down Expand Up @@ -42,7 +44,16 @@ const ChartEntry: FunctionComponent<ChartItem> = ({
};

const PortfolioSummary: FunctionComponent<PortfolioSummaryProps> = ({ 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();
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? Why are you simulating a loading? Are you to understand the issue ?

GradleD marked this conversation as resolved.
Show resolved Hide resolved
const normalizeMinValue = (data: ChartItem[]) => {
return data.map(entry =>
Number(entry.itemValue) < totalBalance * minSlicePercentage ?
Expand Down Expand Up @@ -85,7 +96,10 @@ const PortfolioSummary: FunctionComponent<PortfolioSummaryProps> = ({ title, dat
const [showClaimModal, setShowClaimModal] = useState(false);
const [showSuccessModal, setShowSuccessModal] = useState(false);

return data.length > 0 ? (
return (
<Loading isLoading={loading} loadingType="skeleton" width="100%" height={300}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing this ? We want to make a skeleton loading for this part not rendering it randomly
image


{data.length > 0 ? (
<div className={styles.dashboard_portfolio_summary}>
<div className="flex flex-col md:flex-row w-full justify-between items-center mb-4">
<div className="mb-4 md:mb-1">
Expand Down Expand Up @@ -135,7 +149,9 @@ const PortfolioSummary: FunctionComponent<PortfolioSummaryProps> = ({ title, dat
</div>
</div>
</div>
) : null;
) : null}
</Loading>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

);
}

export default PortfolioSummary;
export default PortfolioSummary;