Skip to content

Commit

Permalink
✨ feat: simplify receive page code
Browse files Browse the repository at this point in the history
  • Loading branch information
rustin01 committed Aug 7, 2024
1 parent 322cd88 commit e25343b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion apps/wallet/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const App: FC = observer(() => {
<Route path="/account-manage" element={<AccountManagePage />} />
<Route path="/token/:addressOrSymbol" element={<TokenDetailPage />} />
<Route path="/send/:addressOrSymbol?" element={<SendTokenPage />} />
<Route path="/receive/:addressOrSymbol?" element={<ReceiveTokenPage />} />
<Route path="/receive" element={<ReceiveTokenPage />} />
</>
)}

Expand Down
24 changes: 3 additions & 21 deletions apps/wallet/src/pages/receive-token/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,24 @@ import { observer } from "mobx-react";
import { FC, useEffect, useState } from "react";
import hibitIdSession from "../../stores/session";
import QRCode from 'qrcode'
import { useNavigate, useParams } from "react-router-dom";
import { useTokenQuery } from "../../apis/react-query/token";
import PageLoading from "../../components/PageLoading";
import { useNavigate } from "react-router-dom";
import SvgGo from '../../assets/right-arrow.svg?react';
import { getChainByChainId } from "../../utils/chain";
import { ChainId } from "../../utils/basicTypes";
import CopyButton from "../../components/CopyButton";

const ReceiveTokenPage: FC = observer(() => {
const [canvas, setCanvas] = useState<HTMLCanvasElement | null>(null)
const { addressOrSymbol } = useParams()
const tokenQuery = useTokenQuery(addressOrSymbol ?? '')
const navigate = useNavigate()

const address = hibitIdSession.address
const chainInfo = hibitIdSession.chainInfo

useEffect(() => {
if (!canvas || !address) return;
QRCode.toCanvas(canvas, address, {
width: 164,
})
}, [canvas, address])

if (tokenQuery.isLoading || typeof tokenQuery.data === 'undefined') {
return <PageLoading />
}

if (tokenQuery.data === null) {
return (
<div>token not found</div>
)
}

const token = tokenQuery.data
const chainInfo = getChainByChainId(new ChainId(token.chain, token.chainNetwork))


return (
<div className="h-full px-6 overflow-auto">
<div>
Expand Down

0 comments on commit e25343b

Please sign in to comment.