diff --git a/wallets/react-wallet-v2/public/icons/arrow-right-icon.svg b/wallets/react-wallet-v2/public/icons/arrow-right-icon.svg new file mode 100644 index 0000000..6c5acea --- /dev/null +++ b/wallets/react-wallet-v2/public/icons/arrow-right-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/wallets/react-wallet-v2/src/components/SessionCard.tsx b/wallets/react-wallet-v2/src/components/SessionCard.tsx index 5976aab..750710f 100644 --- a/wallets/react-wallet-v2/src/components/SessionCard.tsx +++ b/wallets/react-wallet-v2/src/components/SessionCard.tsx @@ -1,54 +1,55 @@ import { truncate } from '@/utils/HelperUtil' -import { Avatar, Button, Card, Link, Text, Tooltip } from '@nextui-org/react' +import { Avatar, Card, Link, Text } from '@nextui-org/react' import Image from 'next/image' +import NextLink from 'next/link' /** * Types */ interface IProps { + topic?: string logo?: string name?: string url?: string - onDelete: () => Promise } /** * Component */ -export default function SessionCard({ logo, name, url, onDelete }: IProps) { +export default function SessionCard({ logo, name, url, topic }: IProps) { return ( - - + - - - - {name} - - - {truncate(url?.split('https://')[1] ?? 'Unknown', 23)} - - - - - - - - - + + + + + {name} + + + {truncate(url?.split('https://')[1] ?? 'Unknown', 23)} + + + + + + + ) } diff --git a/wallets/react-wallet-v2/src/pages/session.tsx b/wallets/react-wallet-v2/src/pages/session.tsx new file mode 100644 index 0000000..2e7cc19 --- /dev/null +++ b/wallets/react-wallet-v2/src/pages/session.tsx @@ -0,0 +1,59 @@ +import PageHeader from '@/components/PageHeader' +import { truncate } from '@/utils/HelperUtil' +import { walletConnectClient } from '@/utils/WalletConnectUtil' +import { Avatar, Col, Link, Row, Text } from '@nextui-org/react' +import { useRouter } from 'next/router' +import { Fragment, useEffect, useState } from 'react' + +/** + * Component + */ +export default function SessionPage() { + const [topic, setTopic] = useState('') + const { query } = useRouter() + + useEffect(() => { + if (query?.topic) { + setTopic(query.topic as string) + } + }, [query]) + + // async function onDelete(topic: string) { + // await walletConnectClient.session.delete({ + // topic, + // reason: ERROR.DELETED.format() + // }) + // const newSessions = sessions.filter(sessions => sessions.topic !== topic) + // setSessions(newSessions) + // } + + const session = walletConnectClient.session.values.find(s => s.topic === topic) + + console.log(session) + + if (!session) { + return null + } + + const { name, url, icons, description } = session.peer.metadata + + return ( + + + + + + + + + {name} + + {truncate(url?.split('https://')[1] ?? 'Unknown', 23)} + + + + + {description} + + ) +} diff --git a/wallets/react-wallet-v2/src/pages/sessions.tsx b/wallets/react-wallet-v2/src/pages/sessions.tsx index 951a107..e544a04 100644 --- a/wallets/react-wallet-v2/src/pages/sessions.tsx +++ b/wallets/react-wallet-v2/src/pages/sessions.tsx @@ -2,21 +2,11 @@ import PageHeader from '@/components/PageHeader' import SessionCard from '@/components/SessionCard' import { walletConnectClient } from '@/utils/WalletConnectUtil' import { Text } from '@nextui-org/react' -import { ERROR } from '@walletconnect/utils' import { Fragment, useState } from 'react' export default function SessionsPage() { const [sessions, setSessions] = useState(walletConnectClient.session.values) - async function onDelete(topic: string) { - await walletConnectClient.session.delete({ - topic, - reason: ERROR.DELETED.format() - }) - const newSessions = sessions.filter(sessions => sessions.topic !== topic) - setSessions(newSessions) - } - return ( @@ -27,10 +17,10 @@ export default function SessionsPage() { return ( onDelete(session.topic)} /> ) })