Skip to content

Commit

Permalink
Refactor(rank): 코드 리팩토링 및 css 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobbymin committed Oct 9, 2024
1 parent 8862848 commit 6f5278c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
1 change: 0 additions & 1 deletion src/pages/rank/components/all/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const AllRank = () => {
}));
setUserRanks(allUserData);
setLoading(false);
// console.log('rank data: ', allUserData);
};

fetchUserRanking();
Expand Down
79 changes: 47 additions & 32 deletions src/pages/rank/components/my/index.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
import { TextContainer } from '../../styles';
import * as S from './styles';
import { useGetMyRank } from '@/apis/my-rank/my-rank.api';
import Profile from '@/assets/main/ZZAN-Profile.png';
import { getTierDetails } from '@/constants/data/tierSchema';
import { useInfoStore } from '@/store/useInfoStore';
import * as Base from '@/styles/baseStyles';
import { Box, Image, Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

const MyRank = () => {
const { userInfo } = useInfoStore();
const { data } = useGetMyRank();

const tierDetails = userInfo?.tierInfo
? getTierDetails(userInfo?.tierInfo.tier)
const tierDetails = data?.data.tierInfo
? getTierDetails(data?.data.tierInfo.tier)
: { color: 'var(--color-class-02)' };
return (
<>
<S.MyRankLayout>
<Base.Text
fontSize='var(--font-size-xl)'
fontWeight='700'
color='#457A82'
>
<MyRankLayout>
<Text fontSize='var(--font-size-xl)' fontWeight='700' color='#457A82'>
내 순위
</Base.Text>
<S.RankInfoContainer>
<S.RankPosition>
<Base.Text fontWeight='700'>1위</Base.Text>
</S.RankPosition>
<S.RankProfile>
<S.RankProfileImg width='4.5rem' src={Profile} />
</S.RankProfile>
</Text>
<RankInfoContainer>
<RankPosition>
<Text fontWeight='700'>{data?.data.rank}</Text>
</RankPosition>
<Box display='flex'>
<Image width='4.5rem' src={Profile} />
</Box>
<TextContainer>
<Base.Text fontSize='var(--font-size-xl)' fontWeight='650'>
{userInfo?.nickname}
</Base.Text>
<Base.Text
color={tierDetails?.color}
fontWeight='700'
fontSize='1.2rem'
>
{userInfo?.tierInfo.tier}
</Base.Text>
<Text fontSize='var(--font-size-xl)' fontWeight='650'>
{data?.data.nickname}
</Text>
<Text color={tierDetails?.color} fontWeight='700' fontSize='1.2rem'>
{data?.data.tierInfo.tier}
</Text>
</TextContainer>
</S.RankInfoContainer>
</S.MyRankLayout>
</RankInfoContainer>
</MyRankLayout>
</>
);
};

export default MyRank;

export const MyRankLayout = styled.div`
display: flex;
flex-direction: column;
background-color: var(--color-green-06);
border-bottom: 1px solid #bdc5cd;
`;

export const RankInfoContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 0.6rem;
padding: 1rem 0.5rem;
`;

export const RankPosition = styled.div`
width: 3rem;
text-align: center;
white-space: nowrap;
`;
5 changes: 2 additions & 3 deletions src/pages/rank/components/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const UserRank: React.FC<UserRankProps> = ({ user, index }) => {
<S.UserRankContainer>
<Box
display='flex'
// justifyContent='space-between'
alignItems='center'
textAlign='center'
bgColor='#fff'
Expand Down Expand Up @@ -52,14 +51,14 @@ const UserRank: React.FC<UserRankProps> = ({ user, index }) => {
gap='1rem'
>
<Text
maxWidth='150px'
maxWidth='170px'
fontWeight='700'
fontSize='0.8rem'
color={tierColor}
>
{tierInfo}
</Text>
<Text maxWidth='150px' fontSize='0.8rem' color={tierColor}>
<Text maxWidth='200px' fontSize='0.7rem' color={tierColor}>
{currentExp}
</Text>
</Box>
Expand Down

0 comments on commit 6f5278c

Please sign in to comment.