@@ -18,76 +18,84 @@ const GameDevs = ({id}) => {
1818
1919 useEffect ( ( ) => {
2020 getDevs ( ) ;
21- } , [ ] ) ;
21+ } , [ id ] ) ;
2222
2323 const getDevs = async ( ) => {
2424 const response = await GamesAPI . getDevelopersGameById ( id ) ;
2525 setDevs ( response . data . results ) ;
2626 setIsLoading ( false ) ;
2727 }
2828
29+ const swiperParams = {
30+ modules : [ Navigation , Pagination ] ,
31+ spaceBetween : 12 ,
32+ slidesPerView : 3 ,
33+ navigation : true ,
34+ wrapperClass : 'devs-slider' ,
35+ } ;
36+ 37+ const swiperContent = devs . length !== 0
38+ ? < Swiper
39+ { ...swiperParams }
40+ >
41+ {
42+ devs . slice ( 0 , 5 ) . map ( dev => {
43+ return < SwiperSlide key = { dev . id } >
44+ < div className = "game-developer" style = { { backgroundImage : `linear-gradient(rgba(32, 32, 32, 0.5), rgb(32, 32, 32) 70%), url(${ dev . image_background } )` } } >
45+ < div className = "game-developer__head" >
46+ < div className = "game-developer__head-photo" >
47+ < img src = {
48+ dev . image === null ? 'https://w7.pngwing.com/pngs/336/946/png-transparent-avatar-user-medicine-surgery-patient-avatar-face-heroes-head.png' : dev . image
49+ } alt = "developer" />
50+ </ div >
51+ < div className = "game-developer__head-name" >
52+ < a href = "#" > { dev . name } </ a > </ div >
53+ < div className = "game-developer__head-positions" >
54+ { dev . positions . map ( ( position , index , array ) => {
55+ if ( ( index + 1 ) !== array . length ) {
56+ return < div key = { position . id }
57+ className = "game-developer__head-position" >
58+ { position . name . charAt ( 0 ) . toUpperCase ( ) + position . name . slice ( 1 ) } ,
59+ </ div >
60+ } else {
61+ return < div key = { position . id }
62+ className = "game-developer__head-position" >
63+ { position . name . charAt ( 0 ) . toUpperCase ( ) + position . name . slice ( 1 ) }
64+ </ div >
65+ }
66+ } ) }
67+ </ div >
68+ </ div >
69+ < div className = "game-developer__content" >
70+ < div className = "game-developer__content-title" > Known for { dev . games_count } games</ div >
71+ < ul className = "game-developer__content-items" >
72+ { dev . games . map ( game => {
73+ return < li key = { game . id } className = "game-developer__content-game" >
74+ < a href = "#" className = "game-developer__content-name" > { game . name } </ a >
75+ < span className = "game-developer__content-added" > { game . added } </ span >
76+ </ li >
77+ } ) }
78+ </ ul >
79+ </ div >
80+ </ div >
81+ </ SwiperSlide >
82+ } )
83+ }
84+ < SwiperSlide >
85+ < div className = "game-developer" >
86+ < a href = "#" className = "game-developer__button-more" >
87+ < button > More</ button >
88+ </ a >
89+ </ div >
90+ </ SwiperSlide >
91+ </ Swiper >
92+ : < div > There is no creators for this game</ div >
93+ 2994 return (
3095 < div className = "game-devs__inner" >
3196 { isLoading
3297 ? < Loader />
33- : < Swiper
34- modules = { [ Navigation , Pagination ] }
35- spaceBetween = { 12 }
36- slidesPerView = { 3 }
37- navigation
38- wrapperClass = { 'devs-slider' }
39- >
40- {
41- devs . slice ( 0 , 5 ) . map ( dev => {
42- return < SwiperSlide key = { dev . id } >
43- < div className = "game-developer" style = { { backgroundImage : `linear-gradient(rgba(32, 32, 32, 0.5), rgb(32, 32, 32) 70%), url(${ dev . image_background } )` } } >
44- < div className = "game-developer__head" >
45- < div className = "game-developer__head-photo" >
46- < img src = {
47- dev . image === null ? 'https://w7.pngwing.com/pngs/336/946/png-transparent-avatar-user-medicine-surgery-patient-avatar-face-heroes-head.png' : dev . image
48- } alt = "developer" />
49- </ div >
50- < div className = "game-developer__head-name" >
51- < a href = "#" > { dev . name } </ a > </ div >
52- < div className = "game-developer__head-positions" >
53- { dev . positions . map ( ( position , index , array ) => {
54- if ( ( index + 1 ) !== array . length ) {
55- return < div key = { position . id }
56- className = "game-developer__head-position" >
57- { position . name . charAt ( 0 ) . toUpperCase ( ) + position . name . slice ( 1 ) } ,
58- </ div >
59- } else {
60- return < div key = { position . id }
61- className = "game-developer__head-position" >
62- { position . name . charAt ( 0 ) . toUpperCase ( ) + position . name . slice ( 1 ) }
63- </ div >
64- }
65- } ) }
66- </ div >
67- </ div >
68- < div className = "game-developer__content" >
69- < div className = "game-developer__content-title" > Known for { dev . games_count } games</ div >
70- < ul className = "game-developer__content-items" >
71- { dev . games . map ( game => {
72- return < li key = { game . id } className = "game-developer__content-game" >
73- < a href = "#" className = "game-developer__content-name" > { game . name } </ a >
74- < span className = "game-developer__content-added" > { game . added } </ span >
75- </ li >
76- } ) }
77- </ ul >
78- </ div >
79- </ div >
80- </ SwiperSlide >
81- } )
82- }
83- < SwiperSlide >
84- < div className = "game-developer" >
85- < a href = "#" className = "game-developer__button-more" >
86- < button > More</ button >
87- </ a >
88- </ div >
89- </ SwiperSlide >
90- </ Swiper >
98+ : swiperContent
9199 }
92100 </ div >
93101 ) ;
0 commit comments