Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#282 팀 랭킹 api 에러 처리 #283

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/containers/main/TeamRankSlider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* eslint-disable react/jsx-props-no-spreading */

'use client';

import { Box, Flex } from '@chakra-ui/react';
import { Box, Flex, Text } from '@chakra-ui/react';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import { Swiper, SwiperSlide, SwiperClass } from 'swiper/react';

import 'swiper/css';

import { getTeams } from '@/app/api/team';
import textStyles from '@/theme/foundations/textStyles';
import { TeamRank } from '@/types';

import TeamCard from '../TeamCard';
Expand All @@ -28,6 +31,7 @@ const TeamRankSlider = () => {

useEffect(() => {
getTeams().then((res) => {
if (!res.ok) return;
const teams = res.body.slice(0, 10).map((team: TeamRank, idx: number) => {
return { ...team, rank: idx + 1 };
});
Expand All @@ -37,6 +41,22 @@ const TeamRankSlider = () => {

return (
<Flex align="center" direction="column" w="100%">
{teamRank.length === 0 && (
<Flex
align="center"
justify="center"
w={{ base: '450px', lg: '600px', '2xl': '720px' }}
h={{ base: '300px', lg: '360px', '2xl': '430px' }}
mt="20"
bg="rgba(255,255,255,0.1)"
border="1px solid white"
borderRadius="30"
>
<Text {...textStyles.bold_4xl} textColor="white">
아직 생성된 팀이 없습니다.
</Text>
</Flex>
)}
<Box w="100%">
<Swiper
centeredSlides
Expand Down Expand Up @@ -65,7 +85,6 @@ const TeamRankSlider = () => {
))}
</Swiper>
</Box>

<Flex justify="center" w="100%" h="10" mt="8">
{teamRank.map((team, idx) => (
<Box
Expand Down