Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Receive functionality for dashboard #135

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sixty-dragons-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"abstraxion-dashboard": minor
---

Added receive functionality to dashboard
2 changes: 1 addition & 1 deletion apps/abstraxion-dashboard/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Home() {
<h3 className="ui-font-akkuratLL ui-mb-4 ui-text-2xl ui-text-white ui-font-bold">
Overview
</h3>
<Overview />
<Overview account={account as AbstraxionAccount} />
<h3 className="ui-font-akkuratLL ui-mb-4 ui-mt-8 ui-text-2xl ui-font-bold ui-text-white">
Account Info
</h3>
Expand Down
16 changes: 14 additions & 2 deletions apps/abstraxion-dashboard/components/Overview.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { formatBalance, getCommaSeperatedNumber } from "@/utils";
import { useAccountBalance } from "@/hooks/useAccountBalance";
import { RightArrowIcon } from "./Icons";
import { RightArrowIcon, ScanIcon } from "./Icons";
import { WalletSend } from "./WalletSend/WalletSend";
import { WalletReceive } from "./WalletReceive";
import { AbstraxionAccount } from "@/hooks";

export const XION_TO_USDC_CONVERSION = 50;

export const Overview = () => {
export const Overview = ({ account }: { account?: AbstraxionAccount }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for pulling this in as prop as opposed to getting value from context or useAccount hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily a huge reason for one over the other. I could switch it so there is less prop drilling, was just following what was already done in AccountInfo component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just curious. I had prop drilled because I couldn't get the parent component to update the balance after performing a send tx in the child component so was curious if you were seeing similar stale data issues. All good though

const { balanceInfo: accountBalance, sendTokens } = useAccountBalance();

const xionBalance = accountBalance?.balances.find(
Expand Down Expand Up @@ -42,6 +44,16 @@ export const Overview = () => {
{/* <div className="w-12 h-12 bg-black rounded-full flex justify-center items-center mr-6">
<ScanIcon color="white" />
</div> */}
{account?.id && (
<WalletReceive
xionAddress={account.id}
trigger={
<div className="ui-mr-4 ui-flex ui-h-12 ui-w-12 ui-items-center ui-justify-center ui-rounded-full ui-bg-black hover:ui-cursor-pointer">
<ScanIcon color="white" />
</div>
}
/>
)}
<WalletSend
balanceInfo={accountBalance}
sendTokens={sendTokens}
Expand Down
60 changes: 60 additions & 0 deletions apps/abstraxion-dashboard/components/WalletReceive/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ReactElement, useState } from "react";
import { Button, Dialog, DialogContent, DialogTrigger } from "@burnt-labs/ui";
import { DialogClose } from "@burnt-labs/ui";
import { CloseIcon } from "@burnt-labs/ui";
import { truncateAddress } from "@/utils";
import { CopyIcon } from "../Icons";
import { QRCodeSVG } from "qrcode.react";

export function WalletReceive({
trigger,
xionAddress,
}: {
trigger: ReactElement;
xionAddress: string;
}) {
const [isOpen, setIsOpen] = useState(false);

const copyXionAddress = () => {
if (xionAddress) {
navigator.clipboard.writeText(xionAddress);
}
};

return (
<Dialog onOpenChange={setIsOpen} open={isOpen}>
<DialogTrigger>{trigger}</DialogTrigger>
<DialogContent
className="ui-text-white"
onPointerDownOutside={(e: any) => e.preventDefault()}
>
<DialogClose className="ui-absolute ui-top-5 ui-right-10">
<CloseIcon className="ui-stroke-white/50" />
</DialogClose>
<div className="ui-flex ui-flex-col ui-pt-8">
<h1 className="ui-w-full ui-text-center ui-text-3xl ui-font-akkuratLL ui-font-thin">
RECEIVE
</h1>
<h3 className="ui-text-white ui-text-sm ui-font-bold ui-font-akkuratLL ui-leading-none ui-my-6">
XION Address
</h3>
<div
onClick={copyXionAddress}
className="ui-flex ui-cursor-pointer ui-items-center ui-justify-between ui-px-4 ui-w-full ui-h-16 ui-bg-black ui-rounded-lg"
>
<p className="ui-text-white ui-text-base ui-font-normal ui-font-akkuratLL ui-leading-normal">
{truncateAddress(xionAddress)}
</p>
<CopyIcon color="white" />
</div>
<div className="ui-flex ui-items-center ui-justify-center ui-my-6 ui-p-6 ui-w-full ui-bg-black ui-rounded-lg">
<QRCodeSVG value={"uxion:" + xionAddress} />
</div>
<Button onClick={() => setIsOpen(false)} fullWidth>
Close
</Button>
</div>
</DialogContent>
</Dialog>
);
}
1 change: 1 addition & 0 deletions apps/abstraxion-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"graz": "^0.0.51",
"jose": "^5.1.3",
"next": "^14.0.3",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
Loading
Loading