Skip to content

Commit 3482832

Browse files
committed
Feat: 매칭 요청이 없을 때 매칭 탭 비활성화
1 parent 0bed2f2 commit 3482832

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/pages/Home/HomeTabBar.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ const HomeTabBar: React.FC<HomeTabBarProps> = ({ onOpenBottomSheet }) => {
4545
};
4646

4747
const handleSwiperChange = (swiper: SwiperCore) => {
48-
setActiveIndex(swiper.activeIndex);
48+
// 매칭 요청이 없고 1번 index에 있을 때 0번 탭 비활성화
49+
if (!hasMatchingRequests && swiper.activeIndex === 1) {
50+
swiper.allowSlidePrev = false;
51+
setActiveIndex(swiper.activeIndex);
52+
}
53+
// 매칭 요청이 없고 0번 index에 있을 때 1번 탭으로 이동
54+
else if (!hasMatchingRequests && swiper.activeIndex === 0) {
55+
swiper.slideNext();
56+
}
57+
// 매칭 요청이 있을 때 양쪽 스와이퍼 가능
58+
else {
59+
swiper.allowSlidePrev = true;
60+
setActiveIndex(swiper.activeIndex);
61+
}
4962
};
5063

5164
const fetchMatchingRequests = async () => {
@@ -100,6 +113,7 @@ const HomeTabBar: React.FC<HomeTabBarProps> = ({ onOpenBottomSheet }) => {
100113
swiperRef.current = swiper;
101114
}}
102115
onSlideChange={handleSwiperChange}
116+
allowSlidePrev={hasMatchingRequests}
103117
spaceBetween={0}
104118
slidesPerView={1}
105119
autoHeight={true}

0 commit comments

Comments
 (0)