fix edit profile pic

This commit is contained in:
saml33 2022-12-24 11:12:32 +11:00
parent 5c8c8d64fd
commit f49d4dd56a
3 changed files with 8 additions and 8 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

@ -17,7 +17,7 @@ const ProfileImage = ({
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

@ -226,7 +226,7 @@ export type MangoStore = {
notifications: Array<Notification>
perpMarkets: PerpMarket[]
profile: {
details: ProfileDetails
details: ProfileDetails | null
loadDetails: boolean
}
selectedMarket: {