Skip to content

Commit

Permalink
fix: padrões de código/ DRY 🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1t3h47 committed Oct 15, 2023
1 parent f5e0596 commit bb88c91
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/components/pages/ChartsDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,56 @@ const ChartsDashboard = () => {
useState<JSX.Element | null>(null);

useEffect(() => {
const errHandler = (error: Error) => {
console.error(error);
setImportLoading(false);
};

import("../organisms/PartyDistributionBarChart")
.then((module) => {
setPartyDistributionChart(<module.PartyDistributionBarChart />);
})
.then(() => {
import("../organisms/TopContributingBarChart").then((module) => {
setTopContributingChart(<module.TopContributingBarChart />);
});
import("../organisms/TopContributingBarChart")
.then((module) => {
setTopContributingChart(<module.TopContributingBarChart />);
})
.catch(errHandler);
})
.then(() => {
import("../organisms/BitcoinNegotiationsParetoChart").then((module) => {
setBitcoinNegotiationsChart(
<module.BitcoinNegotiationsParetoChart />
);
setImportLoading(false);
});
import("../organisms/BitcoinNegotiationsParetoChart")
.then((module) => {
setBitcoinNegotiationsChart(
<module.BitcoinNegotiationsParetoChart />
);
setImportLoading(false);
})
.catch(errHandler);
})
.catch((error) => {
console.error(error);
setImportLoading(false);
});
.catch(errHandler);
}, []);

const isLoading = importLoading || loading || btcLoading;
const isLoadingSenator = importLoading || loading;
const isLoadingBitcoin = importLoading || btcLoading;

return (
<div className="flex flex-wrap justify-center">
<Card
title="Distribuição de partidos ocupando
posições no senado (EUA):"
{...{ isLoading }}
{...{ isLoading: isLoadingSenator }}
>
{partyDistributionChart}
</Card>
<Card title="Top 5 contribuidores no senado (EUA):" {...{ isLoading }}>
<Card
title="Top 5 contribuidores no senado (EUA):"
{...{ isLoading: isLoadingSenator }}
>
{topContributingChart}
</Card>
<Card
title="Distribuição de volume de negociações por criptomoeda:"
{...{ isLoading }}
{...{ isLoading: isLoadingBitcoin }}
>
{bitcoinNegotiationsChart}
</Card>
Expand Down

0 comments on commit bb88c91

Please sign in to comment.