From ded74c076b51c15bbfeeed044769ff986b2fe836 Mon Sep 17 00:00:00 2001 From: jinhojang6 Date: Thu, 24 Oct 2024 01:36:16 +0900 Subject: [PATCH] feat: update dashboard --- .../Dashboard/OperatorPanel/OperatorPanel.tsx | 6 +++--- .../Dashboard/ProgressBar/ProgressBar.tsx | 4 ++-- src/components/HamburgerMenu/HamburgerMenu.tsx | 6 +----- src/components/WalletConnect/WalletConnect.tsx | 17 +++++++++++------ src/components/WalletConnect/unisat.ts | 1 + 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/components/Dashboard/OperatorPanel/OperatorPanel.tsx b/src/components/Dashboard/OperatorPanel/OperatorPanel.tsx index fa5c3134b8..643ffc3888 100644 --- a/src/components/Dashboard/OperatorPanel/OperatorPanel.tsx +++ b/src/components/Dashboard/OperatorPanel/OperatorPanel.tsx @@ -68,18 +68,18 @@ const OperatorPanel: React.FC = () => { - RagingBull + Edit callsign - Operator + {user?.id && 'Operator'} - #{user?.id} + {user?.id && `#${user?.id}`} diff --git a/src/components/Dashboard/ProgressBar/ProgressBar.tsx b/src/components/Dashboard/ProgressBar/ProgressBar.tsx index c30864f229..77eab24bea 100644 --- a/src/components/Dashboard/ProgressBar/ProgressBar.tsx +++ b/src/components/Dashboard/ProgressBar/ProgressBar.tsx @@ -61,13 +61,13 @@ const ProgressBar: React.FC = ({ - {`${numberWithCommas(user?.total_xp)}`} + {`${numberWithCommas(user?.total_xp) || 0}`} - {`${numberWithCommas(5020)}`} + {`${numberWithCommas(0)}`} diff --git a/src/components/HamburgerMenu/HamburgerMenu.tsx b/src/components/HamburgerMenu/HamburgerMenu.tsx index d173f25d5b..0de532194b 100644 --- a/src/components/HamburgerMenu/HamburgerMenu.tsx +++ b/src/components/HamburgerMenu/HamburgerMenu.tsx @@ -71,11 +71,7 @@ const HamburguerMenu = () => { {isOpen && ( - + Gitbook diff --git a/src/components/WalletConnect/WalletConnect.tsx b/src/components/WalletConnect/WalletConnect.tsx index d666e69e68..b752336759 100644 --- a/src/components/WalletConnect/WalletConnect.tsx +++ b/src/components/WalletConnect/WalletConnect.tsx @@ -1,6 +1,6 @@ -import { truncateString } from '@/utils/general.utils' +import { numberWithCommas, truncateString } from '@/utils/general.utils' import styled from '@emotion/styled' -import { useAtom, useSetAtom } from 'jotai' +import { useAtom } from 'jotai' import React, { useEffect, useRef, useState } from 'react' import { userInfoAtom } from '../../../atoms/userInfo' import { walletAddressAtom } from '../../../atoms/wallet' @@ -22,7 +22,7 @@ const Dropdown: React.FC = () => { const [isExpanded, setIsExpanded] = useState(false) const [walletAddress, setWalletAddress] = useAtom(walletAddressAtom) - const setUserInfo = useSetAtom(userInfoAtom) + const [userInfo, setUserInfo] = useAtom(userInfoAtom) const walletHandlers = { okx: getOKXAddressAndSignature, @@ -51,8 +51,11 @@ const Dropdown: React.FC = () => { sessionStorage.setItem('refreshToken', refresh) sessionStorage.setItem('walletAddress', address) } - } catch (error) { - console.error('Failed to connect or disconnect wallet:', error) + } catch (error: any) { + console.log('Failed to connect or disconnect wallet:', error) + alert(error.message) + + setWalletAddress(null) } } @@ -128,7 +131,9 @@ const Dropdown: React.FC = () => { {walletAddress && ( - 4,278 XP + + {`${numberWithCommas(userInfo?.total_xp) || 0}`} XP + )} diff --git a/src/components/WalletConnect/unisat.ts b/src/components/WalletConnect/unisat.ts index b5dbc7efb6..634d1ccb7d 100644 --- a/src/components/WalletConnect/unisat.ts +++ b/src/components/WalletConnect/unisat.ts @@ -10,5 +10,6 @@ export const getUnisatAddressAndSignature = async () => { WALLET_SIGN_MESSAGE_REQUEST, 'bip322-simple', ) + return { addr, sig } }