|
1 | | -import { Box } from '@mui/material' |
2 | | -import EventImage from 'components/generic/EventImage' |
3 | 1 | import React, { useState, useEffect } from 'react' |
4 | | -import { SwipeableViews } from 'components/animated/SwipeableViews' |
| 2 | + |
| 3 | +import { Box } from '@mui/material' |
| 4 | +import { styled } from '@mui/material/styles' |
| 5 | + |
| 6 | +import Image from 'components/generic/Image' |
5 | 7 | import BannerService from 'services/banner' |
6 | 8 |
|
7 | | -const BannerCarousel = (event = null) => { |
| 9 | +const Banner = styled(Box)({ |
| 10 | + maxHeight: '465px', |
| 11 | + display: 'flex', |
| 12 | + alignItems: 'center', |
| 13 | + overflow: 'hidden', |
| 14 | +}) |
| 15 | + |
| 16 | +// This used to have SwipeableViews, that's why it's called a carousel |
| 17 | +const BannerCarousel = () => { |
8 | 18 | const [pictures, setPictures] = useState([]) |
9 | | - const [index, setIndex] = useState(0) |
10 | 19 |
|
11 | 20 | useEffect(() => { |
12 | 21 | BannerService.getAllBanners().then(banners => { |
13 | 22 | if (banners) setPictures(banners) |
14 | 23 | }) |
15 | 24 | }, []) |
16 | 25 | return ( |
17 | | - <> |
18 | | - <Box className="relative mt-0"> |
19 | | - <SwipeableViews |
20 | | - enableMouseEvents |
21 | | - index={index} |
22 | | - onChangeIndex={setIndex} |
23 | | - interval={5000} |
24 | | - disabled |
25 | | - > |
26 | | - {pictures?.map(picture => ( |
27 | | - <Box |
28 | | - key={picture._id} |
29 | | - className="bg-black flex flex-col items-center justify-center h-full max-h-[465px]" |
30 | | - > |
31 | | - <EventImage |
32 | | - className="w-full h-full max-h-[465px] object-contain max-w-[1440px]" |
33 | | - publicId={picture.icon} |
34 | | - defaultImage={require('assets/images/default_cover_image.png')} |
35 | | - transformation={{ |
36 | | - width: 1440, |
37 | | - height: 465, |
38 | | - }} |
39 | | - buttons={picture.buttons} |
40 | | - /> |
41 | | - </Box> |
42 | | - ))} |
43 | | - </SwipeableViews> |
44 | | - </Box> |
45 | | - </> |
| 26 | + <Banner> |
| 27 | + {pictures?.map(picture => ( |
| 28 | + <Image |
| 29 | + publicId={picture.icon} |
| 30 | + defaultImage={require('assets/images/default_cover_image.png')} |
| 31 | + key={picture._id} |
| 32 | + /> |
| 33 | + ))} |
| 34 | + </Banner> |
46 | 35 | ) |
47 | 36 | } |
48 | 37 |
|
|
0 commit comments