Skip to content

Commit

Permalink
fixed single card loading
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Feb 23, 2024
1 parent 9216b44 commit 940b95b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,37 @@ export const TokenCard = ({ props }: TokenCardInternalProps) => {
</>
);

let isDoneLoading = true;

if (props) {
if (props.isPrettyLoading) {
if (props.valuesProps) {
if (Object.keys(props.valuesProps).length === 0) {
isDoneLoading &&= false;
}
let t: keyof typeof props.valuesProps;
for (t in props.valuesProps) {
if (props.valuesProps[t]) {
if (props.valuesProps[t]?.value === undefined) {
isDoneLoading &&= false;
}
} else {
isDoneLoading &&= false;
}
}
} else {
isDoneLoading &&= false;
}
}
}

return (
<>
<div className={props?.cardClasses}>
{props?.isPrettyLoading ? (
props?.valuesProps?.imageProps?.value !== undefined &&
props?.valuesProps?.balanceProps?.value !== undefined &&
props?.valuesProps?.nameProps?.value !== undefined &&
props?.valuesProps?.descriptionProps?.value !== undefined &&
props?.valuesProps?.addressProps?.value !== undefined ? (
<div>{output}</div>
) : (
<p className={props?.isPrettyLoading?.classes}>{props?.isPrettyLoading?.message}</p>
)
) : (
{isDoneLoading ? (
<div>{output}</div>
) : (
<p className={props?.isPrettyLoading?.classes}>{props?.isPrettyLoading?.message}</p>
)}
</div>
</>
Expand Down
17 changes: 9 additions & 8 deletions packages/nextjs/components/rep-tokens/utils/buildTokensCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,33 @@ export function buildTokenCard(token: Token, address?: string, tokenCardProps?:
if (tokenCardProps?.cardClasses) obj.cardClasses = tokenCardProps?.cardClasses;

if (tokenCardProps?.valuesProps) {
obj.valueProps = {};
obj.valuesProps = {};

if (tokenCardProps?.valuesProps?.balanceConfigProps)
obj.valueProps.balanceProps = buildBalanceCard(token.balance, tokenCardProps?.valuesProps?.balanceConfigProps);
obj.valuesProps.balanceProps = buildBalanceCard(token.balance, tokenCardProps?.valuesProps?.balanceConfigProps);

if (tokenCardProps?.valuesProps?.nameConfigProps)
obj.valueProps.nameProps = buildStringCard(token.name, tokenCardProps?.valuesProps?.nameConfigProps);
obj.valuesProps.nameProps = buildStringCard(token.name, tokenCardProps?.valuesProps?.nameConfigProps);

if (tokenCardProps?.valuesProps?.descriptionConfigProps)
obj.valueProps.descriptionProps = buildStringCard(
obj.valuesProps.descriptionProps = buildStringCard(
token.description,
tokenCardProps?.valuesProps?.descriptionConfigProps,
);

if (tokenCardProps?.valuesProps?.imageConfigProps)
obj.valueProps.imageProps = buildImageCard(token.image, tokenCardProps?.valuesProps?.imageConfigProps);
obj.valuesProps.imageProps = buildImageCard(token.image, tokenCardProps?.valuesProps?.imageConfigProps);

if (tokenCardProps?.valuesProps?.addressConfigProps)
obj.valueProps.addressProps = buildStringCard(address, tokenCardProps?.valuesProps?.addressConfigProps);
obj.valuesProps.addressProps = buildStringCard(address, tokenCardProps?.valuesProps?.addressConfigProps);

if (tokenCardProps?.valuesProps?.isTradeableConfigProps)
obj.valueProps.isTradeableProps = buildStringCard(
obj.valuesProps.isTradeableProps = buildStringCard(
`Is Tradeable: ${token.properties.isTradeable}`,
tokenCardProps?.valuesProps?.isTradeableConfigProps,
);
if (tokenCardProps?.valuesProps?.maxMintAmountConfigProps)
obj.valueProps.maxMintAmountProps = buildStringCard(
obj.valuesProps.maxMintAmountProps = buildStringCard(
`Max Mint Amount Per Tx: ${token.properties.maxMintAmountPerTx}`,
tokenCardProps?.valuesProps?.maxMintAmountConfigProps,
);
Expand Down

0 comments on commit 940b95b

Please sign in to comment.