Skip to content

Commit

Permalink
feat(frontend): avoid resolving all the kpi tokens at once
Browse files Browse the repository at this point in the history
  • Loading branch information
guerrap committed Jul 14, 2023
1 parent ab7edce commit dc9784e
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 209 deletions.
14 changes: 12 additions & 2 deletions packages/frontend/src/components/ui/kpi-token-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import {
Chip,
Typography,
Expand Down Expand Up @@ -43,11 +43,21 @@ const rootStyles = cva(
interface KPITokenCardProps {
kpiToken?: KPIToken | ResolvedKPIToken;
noBorder?: boolean;
onResolved?: (resolved: ResolvedKPIToken) => void;
}

export const KPITokenCard = ({ kpiToken, noBorder }: KPITokenCardProps) => {
export const KPITokenCard = ({
kpiToken,
noBorder,
onResolved,
}: KPITokenCardProps) => {
const { loading, resolvedKPIToken } = useResolvedKPIToken(kpiToken);

useEffect(() => {
if (loading || !resolvedKPIToken || !onResolved) return;
onResolved(resolvedKPIToken);
}, [loading, resolvedKPIToken, onResolved]);

return (
<Card className={{ root: rootStyles({ noBorder }) }}>
<CardTitle>
Expand Down
Loading

0 comments on commit dc9784e

Please sign in to comment.