forgeplus-react/src/forge/Information/Component/partner.jsx

66 lines
1.7 KiB
JavaScript

import React , { useEffect } from 'react';
// import Slider from 'react-slick';
import { httpUrl } from '../fetch';
import axios from 'axios';
import { useState } from 'react';
const settings = {
dots: false,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
vertical: true,
verticalSwiping: true,
autoplay:true,
arrows:false
};
function Partner(props) {
const [ topics ,setTopics ] = useState(undefined);
const [ moreTypes ,setMoreTypes ] = useState(false);
const { id, partnerList } = props;
useEffect(()=>{
getUnit(partnerList);
},[id])
function getUnit(array){
const newArray = array
setMoreTypes(array.length > 1)
while(newArray[1] && newArray[1].length + newArray[0].length <= 5) {
newArray[0] = [...newArray[0], ...newArray.splice(1, 1)[0]]
}
setTopics(newArray)
}
return(
<ul className="boxmain zone_part_lists">
{
topics && topics.length>0 ?
topics.map((i, k)=>{
return(
<li key={ k }>
{
i.map((j,k1)=>{
return(
<div className="zone_part_item" key={ k1 }>
{ j.typeName && moreTypes && <span className="task-hide">{j.typeName}</span>}
{
j.link ? <a key={ k1 } href={ j.link } target="_blank" ><img src={j.logo} alt=""/></a>
:
<div><img src={j.logo} alt=""/></div>
}
</div>
)
})
}
</li>
)
})
:
""
}
</ul>
)
}
export default Partner;