Merge branch 'main' into trade-chart-styling

This commit is contained in:
saml33 2022-12-26 21:13:46 +11:00
commit 743a96f88c
14 changed files with 86 additions and 73 deletions

View File

@ -36,14 +36,14 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => {
}, [publicKey])
useEffect(() => {
if (profile.profile_image_url) {
if (profile?.profile_image_url) {
setSelectedProfile(profile.profile_image_url)
}
}, [profile])
const saveProfileImage = async () => {
const name = profile.profile_name.toLowerCase()
const traderCategory = profile.trader_category
const name = profile?.profile_name.toLowerCase()
const traderCategory = profile?.trader_category
try {
if (!publicKey) throw new Error('Wallet not connected!')
if (!signMessage)
@ -88,8 +88,8 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => {
}
const removeProfileImage = async () => {
const name = profile.profile_name.toLowerCase()
const traderCategory = profile.trader_category
const name = profile?.profile_name.toLowerCase()
const traderCategory = profile?.trader_category
try {
if (!publicKey) throw new Error('Wallet not connected!')
if (!signMessage)
@ -147,7 +147,7 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => {
<Button disabled={!selectedProfile} onClick={saveProfileImage}>
{t('save')}
</Button>
{profile.profile_image_url ? (
{profile?.profile_image_url ? (
<LinkButton className="text-sm" onClick={removeProfileImage}>
{t('profile:remove')}
</LinkButton>

View File

@ -129,12 +129,21 @@ const EditProfileForm = ({
<InlineNotification type="error" desc={updateError} />
</div>
) : null}
{!profile ? (
<div className="py-3">
<InlineNotification
type="error"
desc={t('profile:profile-api-error')}
/>
</div>
) : null}
<div className="my-6 flex justify-center">
<div className="relative ">
<IconButton
className="absolute -top-2 -right-2 bg-th-button md:hover:bg-th-button-hover"
size="small"
onClick={onEditProfileImage}
disabled={!profile}
>
{profile?.profile_image_url ? (
<PencilIcon className="h-4 w-4" />
@ -186,7 +195,8 @@ const EditProfileForm = ({
disabled={
!!Object.keys(inputError).length ||
loadUniquenessCheck ||
!profileName
!profileName ||
!profile
}
onClick={saveProfile}
size="large"

View File

@ -14,10 +14,10 @@ const ProfileImage = ({
}) => {
const profile = mangoStore((s) => s.profile.details)
return imageUrl || (isOwnerProfile && profile.profile_image_url) ? (
return imageUrl || (isOwnerProfile && profile?.profile_image_url) ? (
<img
alt=""
src={imageUrl ? imageUrl : profile.profile_image_url}
src={imageUrl ? imageUrl : profile?.profile_image_url}
className={`default-transition rounded-full`}
style={{ width: `${imageSize}px`, height: `${imageSize}px` }}
/>

View File

@ -54,7 +54,7 @@ const TokenStats = () => {
}, [group])
const totalValues = useMemo(() => {
if (!tokenStats.length) return []
if (!tokenStats?.length) return []
const values: TotalValueItem[] = tokenStats.reduce(
(a: TotalValueItem[], c: TokenStatsItem) => {
const hasDate = a.find((d: TotalValueItem) => d.date === c.date_hour)

View File

@ -26,7 +26,7 @@ const ChartTabs = ({ token }: { token: string }) => {
}, [group])
const statsHistory = useMemo(() => {
if (!tokenStats.length) return []
if (!tokenStats?.length) return []
return tokenStats.reduce((a: TokenStatsItem[], c: TokenStatsItem) => {
if (c.symbol === token) {
const copy = { ...c }

View File

@ -93,15 +93,17 @@ const TradingViewChart = () => {
})
useEffect(() => {
// if (tvWidgetRef.current && chartReady && selectedMarketName) {
// tvWidgetRef.current.setSymbol(
// selectedMarketName!,
// tvWidgetRef.current.activeChart().resolution(),
// () => {
// return
// }
// )
// }
const group = mangoStore.getState().group
if (tvWidgetRef.current && chartReady && selectedMarketName && group) {
const market = group.getSerum3MarketByName(selectedMarketName)
tvWidgetRef.current.setSymbol(
market?.serumMarketExternal.toString(),
tvWidgetRef.current.activeChart().resolution(),
() => {
return
}
)
}
}, [selectedMarketName, chartReady])
useEffect(() => {

View File

@ -11,7 +11,6 @@ import mangoStore from '@store/mangoStore'
import { notify } from '../../utils/notifications'
import ProfileImage from '../profile/ProfileImage'
import { abbreviateAddress } from '../../utils/formatting'
import { PublicKey } from '@solana/web3.js'
import { useViewport } from 'hooks/useViewport'
import { breakpoints } from '../../utils/theme'
import EditProfileModal from '@components/modals/EditProfileModal'
@ -72,8 +71,6 @@ const ConnectedMenu = () => {
}
}, [publicKey, actions, wallet])
const { profile_name, wallet_pk } = profileDetails
return (
<>
<Menu>
@ -93,12 +90,12 @@ const ConnectedMenu = () => {
{!loadProfileDetails && !isMobile ? (
<div className="ml-2.5 overflow-hidden text-left">
<p className="font-mono text-xs text-th-fgd-3">
{wallet_pk
? abbreviateAddress(new PublicKey(wallet_pk))
: ''}
{publicKey ? abbreviateAddress(publicKey) : ''}
</p>
<p className="truncate pr-2 text-sm font-bold capitalize text-th-fgd-1">
{profile_name}
{profileDetails?.profile_name
? profileDetails.profile_name
: 'Profile Unavailabe'}
</p>
</div>
) : null}

View File

@ -19,6 +19,7 @@
"no-nfts": "😞 No NFTs found...",
"no-profile-exists": "This profile doesn't exist...",
"profile": "Profile",
"profile-api-error": "Profile update is unavailable. Please try again later",
"profile-fetch-fail": "Failed to fetch profile details",
"profile-name": "Profile Name",
"profile-pic-failure": "Failed to set profile pic",

View File

@ -17,8 +17,9 @@
"no-following": "No Accounts Followed",
"no-following-desc": "The lone sheep is in danger of the wolf",
"no-nfts": "😞 No NFTs found...",
"profile": "Profile",
"no-profile-exists": "This profile doesn't exist...",
"profile": "Profile",
"profile-api-error": "Profile update is unavailable. Please try again later",
"profile-fetch-fail": "Failed to fetch profile details",
"profile-name": "Profile Name",
"profile-pic-failure": "Failed to set profile pic",

View File

@ -1,43 +1,44 @@
{
"browse-profiles": "瀏覽",
"choose-profile": "選擇頭像",
"connect-view-profile": "連接錢包來查看帳戶",
"day-trader": "日內交易者",
"browse-profiles": "Browse",
"choose-profile": "Profile Image",
"connect-view-profile": "Connect your wallet to view your profile",
"day-trader": "Day Trader",
"degen": "Degen",
"discretionary": "零錢",
"edit-profile": "編輯帳戶",
"edit-profile-pic": "切換頭像",
"follow": "追蹤",
"following": "追蹤中",
"invalid-characters": "限制於字母、数字和空格",
"discretionary": "Discretionary",
"edit-profile": "Edit Profile",
"edit-profile-pic": "Edit Profile Pic",
"follow": "Follow",
"following": "Following",
"invalid-characters": "Only alphanumeric characters and single spaces allowed",
"length-error": "Names must be less than 20 characters",
"market-maker": "做市商",
"no-followers": "無追蹤者",
"no-followers-desc": "以隱身模式交易😎",
"no-following": "還沒追蹤別帳戶",
"no-following-desc": "跟朋友團結比較安全吧",
"no-nfts": "😞 未找到NFT...",
"no-profile-exists": "此帳戶不存在...",
"profile": "帳戶",
"profile-fetch-fail": "查帳戶細節出錯",
"profile-name": "帳戶標籤",
"profile-pic-failure": "設置頭像失敗",
"profile-pic-success": "設置頭像成功",
"profile-pic-remove-failure": "刪除頭像失敗",
"profile-pic-remove-success": "刪除頭像成功",
"profile-update-fail": "更新帳戶出錯",
"profile-update-success": "帳戶已更新",
"remove": "刪除",
"save-profile": "保存帳戶",
"set-profile-pic": "設置頭像",
"swing-trader": "擺動交易者",
"total-pnl": "組合總盈虧",
"total-value": "組合總價值",
"trader": "交易者",
"trader-category": "交易模式",
"unfollow": "取消追蹤",
"market-maker": "Market Maker",
"no-followers": "No Followers",
"no-followers-desc": "Trading in stealth mode 😎",
"no-following": "No Accounts Followed",
"no-following-desc": "The lone sheep is in danger of the wolf",
"no-nfts": "😞 No NFTs found...",
"no-profile-exists": "This profile doesn't exist...",
"profile": "Profile",
"profile-api-error": "Profile update is unavailable. Please try again later",
"profile-fetch-fail": "Failed to fetch profile details",
"profile-name": "Profile Name",
"profile-pic-failure": "Failed to set profile pic",
"profile-pic-success": "Successfully set profile pic",
"profile-pic-remove-failure": "Failed to remove profile pic",
"profile-pic-remove-success": "Successfully removed profile pic",
"profile-update-fail": "Failed to update profile",
"profile-update-success": "Profile updated",
"remove": "Remove",
"save-profile": "Save Profile",
"set-profile-pic": "Set Profile Pic",
"swing-trader": "Swing Trader",
"total-pnl": "Total Portfolio PnL",
"total-value": "Total Portfolio Value",
"trader": "Trader",
"trader-category": "Trader Category",
"unfollow": "Unfollow",
"uniqueness-api-fail": "Failed to check profile name uniqueness",
"uniqueness-fail": "Profile name is taken. Try another one",
"yolo": "YOLO",
"your-profile": "您的帳戶"
}
"your-profile": "Your Profile"
}

View File

@ -19,6 +19,7 @@
"no-nfts": "😞 未找到NFT...",
"no-profile-exists": "此帐户不存在...",
"profile": "帐户",
"profile-api-error": "Profile update is unavailable. Please try again later",
"profile-fetch-fail": "查帐户细节出错",
"profile-name": "帐户标签",
"profile-pic-failure": "设置头像失败",

View File

@ -19,6 +19,7 @@
"no-nfts": "😞 未找到NFT...",
"no-profile-exists": "此帳戶不存在...",
"profile": "帳戶",
"profile-api-error": "Profile update is unavailable. Please try again later",
"profile-fetch-fail": "查帳戶細節出錯",
"profile-name": "帳戶標籤",
"profile-pic-failure": "設置頭像失敗",

View File

@ -226,7 +226,7 @@ export type MangoStore = {
notifications: Array<Notification>
perpMarkets: PerpMarket[]
profile: {
details: ProfileDetails
details: ProfileDetails | null
loadDetails: boolean
}
selectedMarket: {
@ -261,7 +261,7 @@ export type MangoStore = {
tokenStats: {
initialLoad: boolean
loading: boolean
data: TokenStatsItem[]
data: TokenStatsItem[] | null
}
tradeForm: TradeForm
wallet: {
@ -416,7 +416,7 @@ const mangoStore = create<MangoStore>()(
set((state) => {
state.mangoAccount.stats.interestTotals.loading = false
})
notify({
console.error({
title: 'Failed to load account interest totals',
type: 'error',
})
@ -456,10 +456,10 @@ const mangoStore = create<MangoStore>()(
state.mangoAccount.stats.performance.loading = false
})
console.error('Failed to load account performance data', e)
notify({
title: 'Failed to load account performance data',
type: 'error',
})
// notify({
// title: 'Failed to load account performance data',
// type: 'error',
// })
}
},
fetchActivityFeed: async (

View File

@ -412,7 +412,6 @@ module.exports = {
'th-link-hover': 'var(--link-hover)',
'th-button': 'var(--button)',
'th-button-hover': 'var(--button-hover)',
'th-warning': 'var(--warning)',
'th-input-bkg': 'var(--input-bkg)',
'th-input-border': 'var(--input-border)',
'th-input-border-hover': 'var(--input-border-hover)',