Skip to content

Commit

Permalink
fix: avatar state
Browse files Browse the repository at this point in the history
  • Loading branch information
Barresi committed Apr 16, 2024
1 parent 5ea8588 commit 55a8129
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/widgets/edit-account/ui/avatar-change/avatar-change.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ const AvatarChange: FC = () => {

const [avatarImg, setAvatarImg] = useState<string | null>(null)
useEffect(() => {
const urlOnBackend =
import.meta.env.VITE_BACKEND_DOMEN + '/ftp/avatars/' + user?.avatar
setAvatarImg(previewUrl || urlOnBackend || null)
if (previewUrl) {
setAvatarImg(previewUrl)
} else if (user?.avatar) {
const urlOnBackend =
import.meta.env.VITE_BACKEND_DOMEN + '/ftp/avatars/' + user?.avatar
setAvatarImg(urlOnBackend)
} else {
setAvatarImg(null)
}
}, [previewUrl, user?.avatar])
return (
<div
Expand Down

0 comments on commit 55a8129

Please sign in to comment.