Skip to content

Commit

Permalink
fix: overwatch memberinfo update (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
PMtHk authored Aug 21, 2023
2 parents 3d5c6e7 + 32783bb commit fb560b4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 50 deletions.
6 changes: 1 addition & 5 deletions src/apis/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ export const signup = async (
lol: games.lol,
pubg: games.pubg,
overwatch: games.overwatch,
// valorant: games.valorant,
lostark: '',
maplestory: '',
// rsoAccessToken: '',
// rsoRefreshToken: '',
valorant: games.valorant,
});

return null;
Expand Down
48 changes: 30 additions & 18 deletions src/pages/overwatch/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ interface CardProps {
name: string;
battletag: number;
type: string;
tank_tier: string;
tank_rank: string;
damage_tier: string;
damage_rank: string;
support_tier: string;
support_rank: string;
tank_tier: string | 'none';
tank_rank: string | 'none';
damage_tier: string | 'none';
damage_rank: string | 'none';
support_tier: string | 'none';
support_rank: string | 'none';
wins: number;
losses: number;
kills: number;
Expand Down Expand Up @@ -204,23 +204,35 @@ const Card = ({ item, expired }: CardProps) => {
<AuthorSection>
<WinRateSectionName>승률</WinRateSectionName>
<ChildSectionContent>
<MatchPlayed>
<WinRate
component="span"
sx={{
color: winRate >= 50 ? '#d31f45' : '#5383e8',
}}
>
{winRate}%
</WinRate>
({item.author?.wins}{item.author?.losses}패)
</MatchPlayed>
{item.author.wins + item.author.losses === 0 ? (
<MatchPlayed>
<WinRate component="span">정보없음</WinRate>
</MatchPlayed>
) : (
<MatchPlayed>
<WinRate
component="span"
sx={{
color: winRate >= 50 ? '#d31f45' : '#5383e8',
}}
>
{winRate}%
</WinRate>
({item.author?.wins}{item.author?.losses}패)
</MatchPlayed>
)}
</ChildSectionContent>
</AuthorSection>
<AuthorSection>
<KDSectionName>K/D</KDSectionName>
<ChildSectionContent>
<KDTypo sx={{ color: calcKDInfo().color }}>{authorKDTypo}</KDTypo>
{item.author.kills + item.author.deaths === 0 ? (
<KDTypo>정보없음</KDTypo>
) : (
<KDTypo sx={{ color: calcKDInfo().color }}>
{authorKDTypo}
</KDTypo>
)}
</ChildSectionContent>
</AuthorSection>
<AuthorSection>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/overwatch/CreateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const CreateCard = () => {
setIsNewNicknameCertified(false);
dispatch(
snackbarActions.OPEN_SNACKBAR({
message: '입력하신 정보와 일치하는 소환사를 찾을 수 없습니다.',
message: '입력하신 정보와 일치하는 플레이어를 찾을 수 없습니다.',
severity: 'error',
}),
);
Expand Down
38 changes: 26 additions & 12 deletions src/pages/overwatch/MemberSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,36 @@ const MemberSlot = ({ name }: MemberSlotProps) => {
</SectionInMember>
<SectionInMember>
<SectionTitleInMember>승률</SectionTitleInMember>
<WinRateSection>
<WinRate
component="span"
sx={{ color: winRate >= 50 ? '#d31f45' : '#5383e8' }}
>
{winRate}%
</WinRate>
<MatchPlayed>
{memberInfo.wins}{memberInfo.losses}
</MatchPlayed>
</WinRateSection>
{memberInfo.wins + memberInfo.losses === 0 ? (
<WinRateSection>
<WinRate component="span" sx={{ fontSize: '14px' }}>
정보없음
</WinRate>
</WinRateSection>
) : (
<WinRateSection>
<WinRate
component="span"
sx={{ color: winRate >= 50 ? '#d31f45' : '#5383e8' }}
>
{winRate}%
</WinRate>
<MatchPlayed>
{memberInfo.wins}{memberInfo.losses}
</MatchPlayed>
</WinRateSection>
)}
</SectionInMember>
<SectionInMember>
<SectionTitleInMember>K/D</SectionTitleInMember>
<KDSection>
<KDTypo sx={{ color: calcKDInfo().color }}>{authorKDTypo}</KDTypo>
{memberInfo.kills + memberInfo.deaths === 0 ? (
<KDTypo sx={{ fontSize: '14px' }}>정보없음</KDTypo>
) : (
<KDTypo sx={{ color: calcKDInfo().color }}>
{authorKDTypo}
</KDTypo>
)}
</KDSection>
</SectionInMember>
<SectionInMember>
Expand Down
5 changes: 1 addition & 4 deletions src/pages/register/InputLol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const InputLol = () => {
);

const exactNickname = await verifyNickname(nickname.trim());
await loadHistory(nickname);

dispatch(
registerActions.SET_GAMES_WITH_ID({
Expand All @@ -70,10 +71,6 @@ const InputLol = () => {
setNickname('');
setWarning(true);
setIsPending(false);
} finally {
if (nickname !== '') {
await loadHistory(nickname);
}
}
};

Expand Down
8 changes: 3 additions & 5 deletions src/pages/register/InputOverwatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const InputOverwatch = () => {
}),
);

const isExist = await verifyNickname(nickname.trim());
await verifyNickname(nickname.trim());

await loadHistory(nickname.trim());

dispatch(
registerActions.SET_GAMES_WITH_ID({
Expand All @@ -72,10 +74,6 @@ const InputOverwatch = () => {
setNickname('');
setWarning(true);
setIsPending(false);
} finally {
if (nickname !== '') {
await loadHistory(nickname);
}
}
};

Expand Down
8 changes: 3 additions & 5 deletions src/pages/register/InputPubg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';

import { RootState } from 'store';
import { getPlatform, loadHistory } from 'apis/api/pubg';
import { getPlatform, fetchMemberHistory, loadHistory } from 'apis/api/pubg';
import { registerActions } from 'store/register-slice';
import { snackbarActions } from 'store/snackbar-slice';
import { gameList } from 'assets/Games.data';
Expand Down Expand Up @@ -59,6 +59,8 @@ const InputPubg = () => {

const fetchedPlatform = await getPlatform(nickname.trim());

await loadHistory(nickname.trim(), fetchedPlatform);

dispatch(snackbarActions.CLOSE_SNACKBAR());

dispatch(
Expand All @@ -84,10 +86,6 @@ const InputPubg = () => {
setPlatform('STEAM');
setWarning(true);
setIsPending(false);
} finally {
if (nickname !== '') {
await loadHistory(nickname, platform);
}
}
};

Expand Down

0 comments on commit fb560b4

Please sign in to comment.