Skip to content

Commit

Permalink
renamed tokenGroup to tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Apr 6, 2024
1 parent d63ee44 commit ddd13ab
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
24 changes: 11 additions & 13 deletions packages/nextjs/app/rep-tokens-demo/_components/RepTokensDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ import { useScaffoldContract, useScaffoldContractWrite } from "~~/hooks/scaffold
export function RepTokensDemo() {
const { address } = useAccount();

const { data: faucet } = useScaffoldContract({ contractName: "ReputationFaucet" });

const { data: reputationTokens } = useScaffoldContract({ contractName: "ReputationTokens" });
const { token, refetchBalance } = useGetRepToken(address, BigInt(0), "nftstorage");
const { tokensData: tokens, refetchBalances: refetchUserBalances } = useRepTokens(address, "nftstorage");
const { tokens: userTokens, refetchBalances: refetchUserBalances } = useRepTokens(address, "nftstorage");
const { writeAsync: claim } = useScaffoldContractWrite({
contractName: "ReputationFaucet",
functionName: "claim",
});
const { tokensData: faucetTokens, refetchBalances: refetchFaucetBalances } = useRepTokens(
faucet?.address,
"nftstorage",
);

const { data: faucet } = useScaffoldContract({ contractName: "ReputationFaucet" });
const { tokens: faucetTokens, refetchBalances: refetchFaucetBalances } = useRepTokens(faucet?.address, "nftstorage");

return (
<>
Expand All @@ -48,24 +46,24 @@ export function RepTokensDemo() {
<TabPanel>
<p className="text-center text-4xl">Multi-Card</p>
<ReputationTokenGroupCard
tokens={tokens}
preChildren={<AddressCard address={tokens.address} isGroup={true} />}
tokens={userTokens}
preChildren={<AddressCard address={reputationTokens?.address} isGroup={true} />}
/>
</TabPanel>

<TabPanel>
<p className="text-center text-4xl">Multi-Card w/ Overlay</p>
<ReputationTokenGroupCard
tokens={tokens}
tokens={userTokens}
isBalanceOverlayed={true}
preChildren={<AddressCard address={tokens.address} isGroup={true} />}
preChildren={<AddressCard address={reputationTokens?.address} isGroup={true} />}
/>
</TabPanel>

<TabPanel>
<p className="text-center text-4xl">Small</p>
<ReputationTokenGroupCard
tokens={tokens}
tokens={userTokens}
components={["Balance", "Image"]}
isBalanceOverlayed={true}
size="sm"
Expand All @@ -75,7 +73,7 @@ export function RepTokensDemo() {
<TabPanel>
<p className="text-center text-4xl">Widget</p>
<ReputationTokenGroupCard
tokens={tokens}
tokens={userTokens}
components={["Balance", "Image"]}
isBalanceOverlayed={true}
size="xs"
Expand Down
13 changes: 4 additions & 9 deletions packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export const Header = () => {

const { address } = useAccount();

const { tokensData } = useRepTokens(address);
const { tokens } = useRepTokens(address);

for (let i = 0; i < tokensData.tokens.length; i++) {
tokensData.tokens[i].image = tokensData.tokens[i].image?.replace("ipfs://", "https://ipfs.io/ipfs/");
for (let i = 0; i < tokens.length; i++) {
tokens[i].image = tokens[i].image?.replace("ipfs://", "https://ipfs.io/ipfs/");
}

const widgetComponents: ReputationComponent[] = ["Balance", "Image"];
Expand Down Expand Up @@ -120,12 +120,7 @@ export const Header = () => {
</ul>
</div>
<div className="navbar-end flex-grow mr-4">
<ReputationTokenGroupCard
tokens={tokensData}
components={widgetComponents}
isBalanceOverlayed={true}
size="xs"
/>
<ReputationTokenGroupCard tokens={tokens} components={widgetComponents} isBalanceOverlayed={true} size="xs" />
<RainbowKitCustomConnectButton />
<FaucetButton />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TokenGroup } from "../hooks/Hooks";
// import { TokenGroup } from "../hooks/Hooks";
import { Token } from "../hooks/Hooks";
import { ReputationTokenCard } from "./ReputationTokenCard";

export interface TokenCardInternalProps {
tokens: TokenGroup;
tokens: Token[];
components?: ReputationComponent[];
isBalanceOverlayed?: boolean;
size?: "xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "3xl";
Expand Down Expand Up @@ -39,12 +40,12 @@ export const ReputationTokenGroupCard = ({
}: TokenCardInternalProps) => {
const output: any[] = [];

for (let i = 0; i < tokens?.tokens?.length; i++) {
for (let i = 0; i < tokens?.length; i++) {
const card = (
<ReputationTokenCard
key={i}
size={size}
token={tokens.tokens[i]}
token={tokens[i]}
components={components}
isBalanceOverlayed={isBalanceOverlayed}
/>
Expand Down
12 changes: 6 additions & 6 deletions packages/nextjs/components/rep-tokens/hooks/Hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ export const useRepTokens = (address?: string, replacementType: ReplacementType
tokens.push(token);
}

const addr = repTokensInstance?.address ?? "";
// const addr = repTokensInstance?.address ?? "";

return { tokensData: { address: addr, tokens: tokens } as TokenGroup, refetchBalances };
return { tokens: tokens, refetchBalances };
};

export type TokenGroup = {
address: string;
tokens: Token[];
};
// export type TokenGroup = {
// address: string;
// tokens: Token[];
// };

0 comments on commit ddd13ab

Please sign in to comment.