Skip to content

Commit

Permalink
Added balance to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Dec 15, 2024
1 parent f7c7cfc commit f960710
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions packages/nextjs/app/profile/[address]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ const ProfilePage: NextPage = () => {
const [isEditing, setIsEditing] = useState(false); // New state for edit mode
const [isAnimating, setIsAnimating] = useState(false);

const observer = useRef<IntersectionObserver | null>(null);

const defaultProfilePicture = "/guest-profile.jpg";

const pathname = usePathname();
const address = pathname.split("/").pop();

const { address: connectedAddress } = useAccount();

const { data: usdcBalance } = useScaffoldReadContract({
contractName: "MockUSDC",
functionName: "balanceOf",
args: [address],
watch: true,
});

const formattedUsdcBalance = usdcBalance ? (Number(usdcBalance.toString()) / 1e6).toFixed(2) : "0.00";

const closeModal = () => {
setIsAnimating(true);
setTimeout(() => {
Expand All @@ -45,15 +63,6 @@ const ProfilePage: NextPage = () => {
setActiveTab(tab);
};

const observer = useRef<IntersectionObserver | null>(null);

const defaultProfilePicture = "/guest-profile.jpg";

const { address: connectedAddress } = useAccount();

const pathname = usePathname();
const address = pathname.split("/").pop();

const { data: punkProfile } = useScaffoldReadContract({
contractName: "PunkProfile",
functionName: "profiles",
Expand Down Expand Up @@ -193,10 +202,14 @@ const ProfilePage: NextPage = () => {
{punkProfile?.[1] && <p className="text-base-content">{punkProfile?.[1]}</p>}

<div className="mt-2">
<div className="text-base-content">
<div className="flex flex-col justify-center items-center">
<Address address={address} />
<div className="flex flex-row items-center">
<div className="flex flex-row items-center gap-2">
<span>Balance: </span>
<span className="hidden lg:flex items-center justify-center gap-1 text-blue-600 font-bold">
<Image src="/usdc-logo.png" alt="USDC" width={20} height={20} className="inline-block" />
{formattedUsdcBalance}
</span>
<Balance address={address} />
</div>
</div>
Expand Down

0 comments on commit f960710

Please sign in to comment.