From 5ea858812d4c4731973268859c1cbe429a1fce3c Mon Sep 17 00:00:00 2001 From: Barresi Date: Wed, 17 Apr 2024 00:34:39 +0700 Subject: [PATCH] fix: banner state --- .../edit-account/ui/banner-change/banner-change.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/widgets/edit-account/ui/banner-change/banner-change.tsx b/src/widgets/edit-account/ui/banner-change/banner-change.tsx index f2c351e4..481ee186 100644 --- a/src/widgets/edit-account/ui/banner-change/banner-change.tsx +++ b/src/widgets/edit-account/ui/banner-change/banner-change.tsx @@ -27,9 +27,15 @@ const BannerChange: FC = () => { const [bannerImg, setBannerImg] = useState(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 (