Skip to content

Commit 83d46f6

Browse files
authored
Merge pull request #71 from Stack-Knowledge/hotfix/scoring
[hotfix] scoring
2 parents 290b8d8 + b9c805e commit 83d46f6

File tree

10 files changed

+53
-36
lines changed

10 files changed

+53
-36
lines changed

packages/api/admin/src/hooks/user/useGetScoringList.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import type { ScoringListType } from 'types';
77
import type { UseQueryOptions } from '@tanstack/react-query';
88

99
export const useGetScoringList = (
10-
pageNumber: number,
1110
options?: UseQueryOptions<ScoringListType[]>
1211
) =>
1312
useQuery<ScoringListType[]>(
1413
userQueryKeys.getScoringList(),
15-
() => get(userUrl.scoring(pageNumber)),
14+
() => get(userUrl.scoring()),
1615
options
1716
);

packages/api/common/src/libs/urlController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const solveUrl = {
1818
} as const;
1919

2020
export const userUrl = {
21-
scoring: (pageNumber: number) => `/user/scoring/list/${pageNumber}`,
21+
scoring: () => `/user/scoring`,
2222
scoringResult: (solveId: string) => `/user/scoring/${solveId}`,
2323
solveDetail: (solveId: string) => `/user/scoring/${solveId}`,
2424
};

packages/common/src/PageContainer/MainPage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const MainPage: React.FC<MainPageProps> = ({ isClient }) => {
1212
<S.MainWrapper>
1313
<Banner />
1414
<S.MissionAlertText>
15-
* 문제는 12:30 ~ 19:30분까지 풀수 있습니다.
15+
* 문제는 12:30 ~ 19:30분까지 풀 수 있습니다.
1616
</S.MissionAlertText>
1717
<MainContents isClient={isClient} />
1818
</S.MainWrapper>

packages/common/src/components/Banner/Banner2/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import DocumentIcon from 'common/assets/Banner/DocumentIcon.png';
77
const Banner2 = () => (
88
<S.BannerWrapper>
99
<S.BannerTitleContainer>
10-
<S.BannerTitle>상품받고</S.BannerTitle>
10+
<S.BannerTitle>상품 받고</S.BannerTitle>
1111
<S.BannerTitle>시험 점수도 챙기자!!</S.BannerTitle>
1212
</S.BannerTitleContainer>
1313
<S.DocumentContainer>

packages/common/src/components/MissionDetailInput /index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const MissionDetailInput: React.FC<MissionDetailInputProps> = ({
3232
<S.MissionDetailInput
3333
placeholder={
3434
role === 'admin'
35-
? '문제를 작성해주시기 바랍니다.'
36-
: '답변을 작성해주시기 바랍니다.'
35+
? '문제를 작성해 주시기 바랍니다.'
36+
: '답변을 작성해 주시기 바랍니다.'
3737
}
3838
maxLength={MAXLENGTH}
3939
value={inputValue}

packages/common/src/components/RankingCard/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { RankingPropsType } from 'types';
66

77
import DefaultProfile from 'common/assets/svg/DefaultProfile.svg';
88

9-
import Image from 'next/image';
10-
119
interface RankingCardType extends RankingPropsType {
1210
rank: number;
1311
}
@@ -19,13 +17,12 @@ const RankingCard: React.FC<RankingCardType> = ({
1917
}) => (
2018
<S.CardWrapper href={'/ranking'} className='medalWrapper'>
2119
{rank <= 3 && <S.Medal className='medal'>{rank}</S.Medal>}
22-
<S.ProfileWrapper>
23-
<Image
24-
fill
25-
alt='profile'
26-
src={profileImage ? profileImage : DefaultProfile}
27-
/>
28-
</S.ProfileWrapper>
20+
<S.ProfileImage
21+
width={90}
22+
height={90}
23+
alt='profile'
24+
src={profileImage ? profileImage : DefaultProfile}
25+
/>
2926
<S.UserName>{name}</S.UserName>
3027
<S.FlexWrapper>
3128
<S.Point>{cumulatePoint}</S.Point>

packages/common/src/components/RankingCard/style.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled';
22

33
import Link from 'next/link';
4+
import Image from 'next/image';
45

56
export const CardWrapper = styled(Link)`
67
width: 14rem;
@@ -15,16 +16,8 @@ export const CardWrapper = styled(Link)`
1516
cursor: pointer;
1617
`;
1718

18-
export const ProfileWrapper = styled.div`
19-
width: 5.625rem;
20-
height: 5.625rem;
19+
export const ProfileImage = styled(Image)`
2120
border-radius: 50%;
22-
23-
overflow: hidden;
24-
position: relative;
25-
img {
26-
object-fit: cover;
27-
}
2821
`;
2922

3023
export const UserName = styled.span`

projects/admin/src/components/MissionCarousel/index.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,60 @@ import { useGetScoringList } from 'api/admin';
1111

1212
import { useRouter } from 'next/navigation';
1313
import { useEffect, useState } from 'react';
14+
import { toast } from 'react-toastify';
1415

1516
const MissionCarousel = () => {
1617
const [pageIndex, setPageIndex] = useState(0);
17-
const [data, setData] = useState<ScoringListType[] | undefined>([]);
18-
19-
const { data: newData } = useGetScoringList(pageIndex);
18+
const [missionList, setMissionList] = useState<ScoringListType[][]>();
2019

20+
const { data, isError } = useGetScoringList();
2121
const { push } = useRouter();
2222

2323
const onCardClick = (solveId: string) => {
2424
push(`/mission/scoring/${solveId}`);
2525
};
2626

2727
const moveRight = () => {
28-
if (data?.length === 10) setPageIndex((cur) => cur + 1);
28+
if (missionList && pageIndex < missionList.length - 1)
29+
if (
30+
pageIndex !== missionList.length - 2 ||
31+
missionList[missionList.length - 1][0]
32+
)
33+
setPageIndex((prev) => prev + 1);
2934
};
3035

3136
const moveLeft = () => {
32-
if (pageIndex > 0) setPageIndex((cur) => cur - 1);
37+
if (pageIndex > 0) setPageIndex((prev) => prev - 1);
3338
};
3439

3540
useEffect(() => {
36-
setData(newData);
37-
}, [newData]);
41+
const newMissionList: ScoringListType[][] = [];
42+
let temp: ScoringListType[] = [];
43+
data?.forEach((item, index) => {
44+
temp.push(item);
45+
if ((index + 1) % 10 === 0) {
46+
newMissionList.push(temp);
47+
temp = [];
48+
}
49+
});
50+
if (data)
51+
newMissionList.push(data.slice(newMissionList.length * 10, data.length));
52+
setMissionList(newMissionList);
53+
}, [data]);
54+
55+
if (isError) {
56+
toast.error('권한이 없는 사용자입니다.');
57+
}
3858

3959
return (
4060
<>
41-
{data?.length != 0 && (
61+
{missionList?.length != 0 && missionList && (
4262
<S.CarouselWrapper>
4363
<S.PointerWrapper onClick={moveLeft}>
4464
<VectorIcon direction='left' />
4565
</S.PointerWrapper>
4666
<S.ContentWrapper>
47-
{data?.map((item, index) => (
67+
{missionList[pageIndex]?.map((item, index) => (
4868
<TaskCard
4969
onClick={() => onCardClick(item.solveId)}
5070
key={item.solveId + index}

projects/admin/src/components/ShopCarousel/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ const ShopCarousel = () => {
4141

4242
const moveRight = () => {
4343
if (orderedItemList && pageIndex < orderedItemList.length - 1)
44-
setPageIndex((prev) => prev + 1);
44+
if (
45+
pageIndex !== orderedItemList.length - 2 ||
46+
orderedItemList[orderedItemList.length - 1][0]
47+
)
48+
setPageIndex((prev) => prev + 1);
4549
};
4650

4751
return (

projects/client/src/components/MissionCarousel/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ const MissionCarousel = () => {
4545

4646
const moveRight = () => {
4747
if (missionList && pageIndex < missionList.length - 1)
48-
setPageIndex((prev) => prev + 1);
48+
if (
49+
pageIndex !== missionList.length - 2 ||
50+
missionList[missionList.length - 1][0]
51+
)
52+
setPageIndex((prev) => prev + 1);
4953
};
5054

5155
return (

0 commit comments

Comments
 (0)