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

[GGFE-217] Ranklist-api #969

Merged
merged 6 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export default function AppLayout({ children }: AppLayoutProps) {
) : (
<div className={styles.appContainer}>
<div
className={`${styles.background} ${styles[colorMode.toLowerCase()]}`}
className={`${styles.background} ${
colorMode !== undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ๋„ !== undefined ๋ง๊ณ  ๊ทธ๋ƒฅ colorMode ๋งŒ ์“ฐ๋Š”๊ฒŒ ๋” ๊น”๋”ํ•  ๊ฒƒ ๊ฐ™์•„์š”

? styles[colorMode.toLowerCase()]
: styles.basic
} `}
>
<div>
{presentPath === '/statistics' && user.isAdmin ? (
Expand Down
5 changes: 3 additions & 2 deletions components/Layout/MainPageProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import styles from 'styles/Layout/MainPageProfile.module.scss';

const MainPageProfile = () => {
const user = useRecoilValue(userState);

return (
<div className={styles.mainPageProfile}>
<div className={styles.gridContainer}>
Expand All @@ -16,7 +15,9 @@ const MainPageProfile = () => {
>
<PlayerImage
src={user.userImageUri}
styleName={`mainPageProfile ${user.edge.toLowerCase()}`}
styleName={`mainPageProfile ${
user.edge ? user.edge.toLowerCase() : 'basic'
}`}
size={18}
/>
</Link>
Expand Down
5 changes: 3 additions & 2 deletions components/Layout/MenuBar/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const MenuProfile = () => {
๊ฒ€: 'black',
๋ฌด: 'rainbow',
};

return (
<div className={styles.menuProfileWrapper}>
<Link
Expand All @@ -44,7 +43,9 @@ const MenuProfile = () => {
>
<PlayerImage
src={user.userImageUri}
styleName={`menuProfile ${user.edge.toLowerCase()}`}
styleName={`menuProfile ${
user.edge ? user.edge.toLowerCase() : 'basic'
}`}
size={18}
/>
</Link>
Expand Down
43 changes: 5 additions & 38 deletions components/modal/event/WelcomeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useState, useEffect } from 'react';
import { useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { CoinResult } from 'types/coinTypes';
import { Modal } from 'types/modalTypes';
import { instance } from 'utils/axios';
import { mockInstance } from 'utils/mockAxios';
import { errorState } from 'utils/recoil/error';
import { modalState } from 'utils/recoil/modal';
import CoinPopcon from 'components/modal/CoinPopcon';
import useAxiosGet from 'hooks/useAxiosGet';
import styles from 'styles/modal/event/WelcomeModal.module.scss';

export default function WelcomeModal() {
Expand All @@ -22,35 +20,16 @@ export default function WelcomeModal() {
'42GG์— ์˜ค์‹ ๊ฑธ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.\n๋‹น์‹ ์˜ ํ–‰๋ณตํ•œ ํƒ๊ตฌ ์ƒํ™œ์„\n์‘์›ํ•ฉ๋‹ˆ๋‹ค! ์ด์ด์ด...',
};

/* const postCoinHandler = async() => {
const postCoinHandler = async () => {
try {
const res = await instance.post(
`/pingpong/users/attendance`
);
const res = await instance.post(`/pingpong/users/attendance`);
setCoin(res.data);
return res.data;
} catch (error) {
setError('SM01');
}
};

useEffect(() => {
postCoinHandler();
}, []); */

const getCoinHandler = async () => {
try {
const res = await mockInstance.get(`/users/attendance`);
if (res && res.data) {
setCoin(res.data);
return res.data;
}
} catch (error) {
setError('SM01');
return null;
}
};

const openPageManual = () => {
window.open(
'https://github.com/42organization/42arcade.gg.client/wiki/42gg.kr--%ED%8E%98%EC%9D%B4%EC%A7%80-%EA%B0%80%EC%9D%B4%EB%93%9C'
Expand All @@ -60,8 +39,7 @@ export default function WelcomeModal() {
const openAttendanceCoin = async () => {
try {
setButtonState(true);
const updatedCoin = await getCoinHandler();
//const updatedCoin = await postCoinHandler();
const updatedCoin = await postCoinHandler();

if (!updatedCoin) return null;

Expand All @@ -79,16 +57,6 @@ export default function WelcomeModal() {
}
};

const openStatChangeModal = () => {
setModal({
modalName: 'FIXED-STAT',
exp: {
gameId: 0,
mode: 'RANK',
},
});
};

return (
<div>
<div className={styles.container}>
Expand All @@ -108,11 +76,10 @@ export default function WelcomeModal() {
<div className={styles.positive}>
<input
onClick={openAttendanceCoin}
// onClick={openStatChangeModal}
type='button'
value='์ถœ์„ํ•˜๊ธฐ'
/>
{buttonState && <CoinPopcon amount={10} coin={1} />}
{buttonState && <CoinPopcon amount={8} coin={1} />}
Comment on lines -115 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๊ฑฐ ์ฝ”์ธ ์ •์ฑ… ๋ฐ”๋€Œ์—ˆ์„ ๋•Œ ๋“ค์–ด๊ฐ€๋Š” ๊ฐ’๋„ ๊ฐ™์ด ๋ฐ”๋€Œ์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค ๐Ÿฅธ

</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/modal/statChange/CoinStatChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function CoinStatChange({ after, before }: CoinChangeProps) {

const CoinChangeAnimation = () => {
const toAdd = 1;
for (let i = before; i < after; i++) {
for (let i = 0; i < after - before; i++) {
sleep(i * 500).then(() => setCoin((thisCoin) => thisCoin + toAdd));
}
};
Expand Down
8 changes: 1 addition & 7 deletions components/modal/statChange/StatChangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ export default function StatChangeModal({ gameId, mode }: Exp) {
const setError = useSetRecoilState(errorState);
const [stat, setStat] = useState<GameResult | undefined>();

/* const getExpHandler = useAxiosGet({
const getExpHandler = useAxiosGet({
url: `/pingpong/games/${gameId}/result/${mode?.toLowerCase()}`,
setState: setStat,
err: 'KP03',
type: 'setError',
}); */
const getExpHandler = useMockAxiosGet({
url: `/games/normal`,
setState: setStat,
err: 'KP03',
type: 'setError',
});

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion components/rank/RankList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function RankList({ season }: RankListProps) {
const makePath = (): string => {
const modeQuery = Mode === 'RANK' ? 'ranks/single' : 'exp';
const seasonQuery = Mode === 'RANK' ? `&season=${season}` : '';
return `/${modeQuery}?page=${page}&size=20${seasonQuery}`;
return `pingpong/${modeQuery}?page=${page}&size=20${seasonQuery}`;
};

useRankList({
Expand Down
4 changes: 2 additions & 2 deletions components/rank/topRank/RankListItemMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default function RankListItemMain({
src={userImageUri}
styleName={
rank === 1
? `ranktropybig ${edge.toLowerCase()}`
: `ranktropy ${edge.toLowerCase()}`
? `ranktropybig ${edge ? edge.toLowerCase() : 'basic'}`
: `ranktropy ${edge ? edge.toLowerCase() : 'basic'}`
}
size={50}
/>
Expand Down
4 changes: 3 additions & 1 deletion components/rank/topRank/RankListMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default function RankListMain({ isMain, season }: RankListMainProps) {
const [page] = useState<number>(1);

const makePathRanker = useMemo(() => {
return `rank/${Mode}`;
if (isMain === true)
return `/pingpong/users/images?seasonId=${season}&mode=${'RANK'}`;
return `/pingpong/users/images?seasonId=${season}&mode=${Mode}`;
}, [season, Mode, isMain]);

useRankListMain({
Expand Down
4 changes: 2 additions & 2 deletions components/user/BasicProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export default function BasicProfile({ profileId }: ProfileProps) {
{intraId && (
<PlayerImage
src={userImageUri}
styleName={`mainProfile ${edge.toLowerCase()}`}
styleName={`mainProfile ${edge ? edge.toLowerCase() : 'basic'}`}
size={30}
/>
)}
<div className={styles.idContainer}>
<div className={styles.ranktier}>
<PlayerImage src={tierImageUri} styleName={'ranktier'} size={50} />
<PlayerImage src={tierImageUri} styleName={'profiletier'} size={50} />
</div>
<div className={styles.intraId}>{intraId}</div>
<div className={styles.buttons}>
Expand Down
11 changes: 2 additions & 9 deletions hooks/Layout/useGetUserSeason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@ import { SeasonList } from 'types/seasonTypes';
import { userState } from 'utils/recoil/layout';
import { loginState } from 'utils/recoil/login';
import { seasonListState } from 'utils/recoil/seasons';
import useAxiosGet, { useMockAxiosGet } from 'hooks/useAxiosGet';
import useAxiosGet from 'hooks/useAxiosGet';

const useGetUserSeason = (presentPath: string) => {
const [user, setUser] = useRecoilState<User>(userState);
const setSeasonList = useSetRecoilState<SeasonList>(seasonListState);
const isLogIn = useRecoilValue(loginState);

/* const getUserHandler = useAxiosGet({
const getUserHandler = useAxiosGet({
url: '/pingpong/users',
setState: setUser,
err: 'JB02',
type: 'setError',
}); */

const getUserHandler = useMockAxiosGet({
url: '/users/user',
setState: setUser,
err: 'JB02',
type: 'setError',
});

const getSeasonListHandler = useAxiosGet<any>({
Expand Down
11 changes: 1 addition & 10 deletions hooks/rank/useRankList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ const useRankList = ({
const [myRank, setMyRank] = useRecoilState<MyRank>(myRankState);
const [isScroll, setIsScroll] = useRecoilState<boolean>(scrollState);

/* const getRankDataHandler = useAxiosGet<any>({
url: makePath,
setState: (data) => {
setRank(data);
setMyRank((prev) => ({ ...prev, [toggleMode]: data.myRank }));
},
err: 'DK01',
type: 'setError',
}); */
const getRankDataHandler = useMockAxiosGet<any>({
const getRankDataHandler = useAxiosGet<any>({
url: makePath,
setState: (data) => {
setRank(data);
Expand Down
16 changes: 2 additions & 14 deletions hooks/rank/useRankListMain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, Dispatch, SetStateAction } from 'react';
import { userImages, ToggleMode } from 'types/rankTypes';
import useAxiosGet, { useMockAxiosGet } from 'hooks/useAxiosGet';
import useAxiosGet from 'hooks/useAxiosGet';

interface useRankListProps {
makePathRanker: string;
Expand All @@ -19,7 +19,7 @@ const useRankListMain = ({
page,
isMain,
}: useRankListProps): void => {
/* const getRankerDataHandler = useAxiosGet<any>({
const getRankerDataHandler = useAxiosGet<any>({
url: makePathRanker,
setState: (data) => {
[data.userImages[0], data.userImages[1]] = [
Expand All @@ -30,18 +30,6 @@ const useRankListMain = ({
},
err: 'DK01',
type: 'setError',
}); */
const getRankerDataHandler = useMockAxiosGet<any>({
url: makePathRanker,
setState: (data) => {
[data.rankList[0], data.rankList[1]] = [
data.rankList[1],
data.rankList[0],
];
setRanker(data.rankList);
},
err: 'DK01',
type: 'setError',
});

useEffect(() => {
Expand Down
14 changes: 2 additions & 12 deletions hooks/users/useBasicProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useSetRecoilState, useRecoilState } from 'recoil';
import { instance } from 'utils/axios';
import { errorState } from 'utils/recoil/error';
import { profileState } from 'utils/recoil/user';
import { useMockAxiosGet } from 'hooks/useAxiosGet';

interface UseBasicProfileProps {
profileId: string;
Expand Down Expand Up @@ -34,23 +33,14 @@ const useBasicProfile = ({ profileId }: UseBasicProfileProps) => {
getBasicProfileHandler();
}, []);

/* const getBasicProfileHandler = async () => {
const getBasicProfileHandler = async () => {
try {
const res = await instance.get(`/pingpong/users/${profileId}`);
setProfile(res?.data);
} catch (e) {
setError('SJ03');
}
}; */

const getBasicProfileHandler = useMockAxiosGet<any>({
url: '/users/intraId',
setState: (data) => {
setProfile(data);
},
err: 'DK01',
type: 'setError',
});
};

return {
intraId,
Expand Down
13 changes: 12 additions & 1 deletion styles/PlayerImage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,18 @@
.ranktier {
@include imageWrap;
div {
@include userRankImage(1.5rem);
position: relative;
width: 1.4rem;
height: 1.5rem;
}
}

.profiletier {
@include imageWrap;
div {
position: relative;
width: 1.7rem;
height: 2rem;
}
}

Expand Down
Loading