diff --git a/src/assets/icons/ableLeft.png b/src/assets/icons/ableLeft.png new file mode 100644 index 0000000..cc09323 Binary files /dev/null and b/src/assets/icons/ableLeft.png differ diff --git a/src/assets/icons/ableRight.png b/src/assets/icons/ableRight.png new file mode 100644 index 0000000..4e89493 Binary files /dev/null and b/src/assets/icons/ableRight.png differ diff --git a/src/assets/icons/disableLeft.png b/src/assets/icons/disableLeft.png new file mode 100644 index 0000000..b212506 Binary files /dev/null and b/src/assets/icons/disableLeft.png differ diff --git a/src/assets/icons/disableRight.png b/src/assets/icons/disableRight.png new file mode 100644 index 0000000..20cbc5b Binary files /dev/null and b/src/assets/icons/disableRight.png differ diff --git a/src/components/atoms/ArrowIcon.jsx b/src/components/atoms/ArrowIcon.jsx new file mode 100644 index 0000000..c1c132e --- /dev/null +++ b/src/components/atoms/ArrowIcon.jsx @@ -0,0 +1,24 @@ +import PropTypes from 'prop-types'; +import ableLeft from '../../assets/icons/ableLeft.png'; +import ableRight from '../../assets/icons/ableRight.png'; +import disableLeft from '../../assets/icons/disableLeft.png'; +import disableRight from '../../assets/icons/disableRight.png'; + +const ArrowIcon = ({ isActive, direction, style, onClick }) => { + if (isActive && direction === 'left') + return clickable next button; + if (isActive && direction === 'right') + return clickable next button; + if (!isActive && direction === 'left') + return clickable next button; + if (!isActive && direction === 'right') + return clickable next button; +}; + +ArrowIcon.propTypes = { + isActive: PropTypes.bool, + direction: PropTypes.string, + style: PropTypes.object, + onClick: PropTypes.func, +}; +export default ArrowIcon; diff --git a/src/pages/TeamMain/components/Banner2/index.jsx b/src/pages/TeamMain/components/Banner2/index.jsx index 464fede..6e3b276 100644 --- a/src/pages/TeamMain/components/Banner2/index.jsx +++ b/src/pages/TeamMain/components/Banner2/index.jsx @@ -1,9 +1,9 @@ import { Box, Flex, Image } from '@chakra-ui/react'; +import ArrowIcon from '../../../../components/atoms/ArrowIcon'; import Card from './Card'; import ContentCard from './ContentCard'; import PropTypes from 'prop-types'; -import arrowNext from '../../../../assets/next.png'; import getMemberRanking from '../../../../api/team/getTeamRanking'; import no_team_select from '../../../../assets/images/no_connected.png'; import { returnProfileImg } from '../../../../lips/returnProfile'; @@ -26,11 +26,6 @@ const Banner2 = ({ isTeamId = false }) => { const { id } = useParams(); const [rankingInfo, setRankingInfo] = useState(); - const [firstCardIndex, setFirstCardIndex] = useState(0); - - const handleNextCardIndex = () => { - setFirstCardIndex((prev) => prev + 1); - }; useEffect(() => { const fetchData = async () => { @@ -118,6 +113,7 @@ const Banner2 = ({ isTeamId = false }) => { const shuffledCards = useMemo(() => shuffleArray([...cardsData]), [cardsData]); + const [firstCardIndex, setFirstCardIndex] = useState(shuffledCards.length ?? 0); return ( @@ -141,20 +137,25 @@ const Banner2 = ({ isTeamId = false }) => { ) : ( - Next + {firstCardIndex === shuffleArray.length - 1 && ( + { + setFirstCardIndex(shuffleArray.length); + }} + alt='Next' + style={{ + position: 'absolute', + zIndex: '99', + top: '40%', + right: '-30px', + width: '68px', + height: '68px', + cursor: 'pointer', + }} + /> + )} {[ shuffledCards[firstCardIndex % 5], shuffledCards[(firstCardIndex + 1) % 5], @@ -174,6 +175,26 @@ const Banner2 = ({ isTeamId = false }) => { isAvg={card.isAvg} /> ))} + {firstCardIndex === shuffleArray.length && ( + { + setFirstCardIndex(shuffleArray.length - 1); + }} + className='swiper-button-next' + alt='Next' + style={{ + position: 'absolute', + top: '40%', + zIndex: '99', + left: '-35px', + width: '68px', + height: '68px', + cursor: 'pointer', + }} + /> + )} )}