@@ -4,69 +4,77 @@ import "./Rooms.css";
44import Slider from "react-slick" ;
55import "slick-carousel/slick/slick.css" ;
66import "slick-carousel/slick/slick-theme.css" ;
7+ import Spinner from "../../UI/Spinner/Spinner" ;
78
89const Rooms = ( props ) => {
9- const { listRooms } = props ;
10- let settings = {
11- dots : true ,
12- infinite : false ,
13- speed : 500 ,
14- slidesToShow : 4 ,
15- slidesToScroll : 4 ,
16- initialSlide : 0 ,
17- responsive : [
18- {
19- breakpoint : 1024 ,
20- settings : {
21- slidesToShow : 3 ,
22- slidesToScroll : 3 ,
23- infinite : true ,
24- dots : true ,
25- } ,
26- } ,
27- {
28- breakpoint : 600 ,
29- settings : {
30- slidesToShow : 2 ,
31- slidesToScroll : 2 ,
32- initialSlide : 2 ,
33- } ,
34- } ,
35- {
36- breakpoint : 480 ,
37- settings : {
38- slidesToShow : 1 ,
39- slidesToScroll : 1 ,
40- } ,
41- } ,
42- ] ,
43- } ;
10+ const { listRooms } = props ;
11+ let settings = {
12+ dots : true ,
13+ infinite : false ,
14+ speed : 500 ,
15+ slidesToShow : 4 ,
16+ slidesToScroll : 4 ,
17+ initialSlide : 0 ,
18+ responsive : [
19+ {
20+ breakpoint : 1024 ,
21+ settings : {
22+ slidesToShow : 3 ,
23+ slidesToScroll : 3 ,
24+ infinite : true ,
25+ dots : true ,
26+ } ,
27+ } ,
28+ {
29+ breakpoint : 600 ,
30+ settings : {
31+ slidesToShow : 2 ,
32+ slidesToScroll : 2 ,
33+ initialSlide : 2 ,
34+ } ,
35+ } ,
36+ {
37+ breakpoint : 480 ,
38+ settings : {
39+ slidesToShow : 1 ,
40+ slidesToScroll : 1 ,
41+ } ,
42+ } ,
43+ ] ,
44+ } ;
4445
45- return (
46- < section className = "rooms" >
47- < div className = "container" >
48- < h5 className = "section-head" >
49- < span className = "heading" > the best offers with rooms</ span >
50- </ h5 >
51- < div className = "rooms-grid" >
52- < Slider { ...settings } >
53- { listRooms . rooms . map ( ( room ) => {
54- return (
55- < Room
56- key = { room . id }
57- roomName = { room . name }
58- roomPrice = { room . price }
59- roomDescription = { room . description }
60- imgSource = { room . imgSource }
61- imgAlt = { room . imgAlt }
62- />
63- ) ;
64- } ) }
65- </ Slider >
66- </ div >
67- </ div >
68- </ section >
69- ) ;
46+ let roomsRender = < Spinner /> ;
47+ if ( listRooms ) {
48+ roomsRender = (
49+ < React . Fragment >
50+ { listRooms . rooms . map ( ( room ) => {
51+ return (
52+ < Room
53+ key = { room . _id }
54+ roomName = { room . name }
55+ roomPrice = { room . price }
56+ roomDescription = { room . description }
57+ imgSource = { room . imgSource }
58+ imgAlt = { room . imgAlt }
59+ />
60+ ) ;
61+ } ) }
62+ </ React . Fragment >
63+ ) ;
64+ }
65+
66+ return (
67+ < section className = "rooms" >
68+ < div className = "container" >
69+ < h5 className = "section-head" >
70+ < span className = "heading" > the best offers with rooms</ span >
71+ </ h5 >
72+ < div className = "rooms-grid" >
73+ < Slider { ...settings } > { roomsRender } </ Slider >
74+ </ div >
75+ </ div >
76+ </ section >
77+ ) ;
7078} ;
7179
7280export default Rooms ;
0 commit comments