Skip to content

Commit

Permalink
fix: banner url
Browse files Browse the repository at this point in the history
  • Loading branch information
Barresi committed Apr 16, 2024
1 parent f9badb8 commit dd987e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/shared/ui/banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import banner from '@assets/banner/default user banner.jpg'
interface IBannerProps {
className?: string
src: string | null
isImgNotOnBackend?: boolean
}

const Banner: FC<IBannerProps> = ({ className, src }) => {
const img = import.meta.env.VITE_BACKEND_DOMEN + '/ftp/banners/' + src || banner
const Banner: FC<IBannerProps> = ({ className, src, isImgNotOnBackend }) => {
const urlBackend = import.meta.env.VITE_BACKEND_DOMEN + '/ftp/banners/'
const img = (isImgNotOnBackend ? src : urlBackend + src) || banner
return (
<img /* Todo убрать иконку файла при отсутствии урл */
src={img}
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/edit-account/ui/banner-change/banner-change.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const BannerChange: FC = () => {

const [bannerImg, setBannerImg] = useState<string | null>(null)
useEffect(() => {
setBannerImg(previewUrl || user?.banner || null)
const urlOnBackend =
import.meta.env.VITE_BACKEND_DOMEN + '/ftp/banners/' + user?.banner
setBannerImg(previewUrl || urlOnBackend || null)
}, [previewUrl, user])
return (
<div className='relative flex-grow h-[120px] usm:h-full w-full'>
<Banner src={bannerImg || null} />
<Banner src={bannerImg || null} isImgNotOnBackend />
<Button
variant='secondary'
className='absolute bottom-[40px] right-[50%] translate-x-[50%] usm:translate-x-0 usm:right-[20px] usm:bottom-[20px] w-[190px] h-[40px] lg:right-[30px] lg:bottom-[30px] xxl:right-[20px]'
Expand Down

0 comments on commit dd987e3

Please sign in to comment.