@@ -10,29 +10,6 @@ const OfferContents = (props) => {
1010 const { listOffers } = props ;
1111 const [ index , setIndex ] = useState ( 0 ) ;
1212
13- let offersContentRender = < Spinner /> ;
14- if ( listOffers ) {
15- offersContentRender = (
16- < React . Fragment >
17- { listOffers . offers . map ( ( offer ) => {
18- return (
19- < OfferContent
20- key = { offer . _id }
21- hotelName = { offer . name }
22- hotelRating = { offer . rating }
23- description = { offer . description }
24- discount = { offer . discount }
25- imgSource = { offer . imgSource }
26- dots = { listOffers . offers . length }
27- index = { index }
28- onChangeIndex = { setIndex }
29- />
30- ) ;
31- } ) }
32- </ React . Fragment >
33- ) ;
34- }
35-
3613 // const changeBackgroundImage = (index) => {
3714 // let str = `url(${listOffers.offers[index].imgSource})`;
3815 // return str;
@@ -48,16 +25,39 @@ const OfferContents = (props) => {
4825 pauseOnHover : true ,
4926 } ;
5027
28+ let offersContentRender = < Spinner /> ;
29+ if ( listOffers ) {
30+ offersContentRender = (
31+ < React . Fragment >
32+ < Slider { ...settings } >
33+ { listOffers . offers . map ( ( offer ) => {
34+ return (
35+ < OfferContent
36+ key = { offer . _id }
37+ hotelName = { offer . name }
38+ hotelRating = { offer . rating }
39+ description = { offer . description }
40+ discount = { offer . discount }
41+ imgSource = { offer . imgSource }
42+ dots = { listOffers . offers . length }
43+ index = { index }
44+ onChangeIndex = { setIndex }
45+ />
46+ ) ;
47+ } ) }
48+ </ Slider >
49+ </ React . Fragment >
50+ ) ;
51+ }
52+
5153 return (
5254 < section
5355 className = "offer"
5456 // style={{
5557 // backgroundImage: changeBackgroundImage(index),
5658 // }}
5759 >
58- < div className = "container" >
59- < Slider { ...settings } > { offersContentRender } </ Slider >
60- </ div >
60+ < div className = "container" > { offersContentRender } </ div >
6161 </ section >
6262 ) ;
6363} ;
0 commit comments