Skip to content

Commit

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

const [bannerImg, setBannerImg] = useState<string | null>(null)
useEffect(() => {
const urlOnBackend =
import.meta.env.VITE_BACKEND_DOMEN + '/ftp/banners/' + user?.banner
setBannerImg(previewUrl || urlOnBackend || null)
if (previewUrl) {
setBannerImg(previewUrl)
} else if (user?.banner) {
const urlOnBackend =
import.meta.env.VITE_BACKEND_DOMEN + '/ftp/banners/' + user?.banner
setBannerImg(urlOnBackend)
} else {
setBannerImg(null)
}
}, [previewUrl, user?.banner])
return (
<div className='relative flex-grow h-[120px] usm:h-full w-full'>
Expand Down

0 comments on commit 5ea8588

Please sign in to comment.