Skip to content

Commit

Permalink
Merge pull request #130 from karrotmvp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jongwooha98 authored Nov 29, 2021
2 parents a3830f7 + 3707b3a commit e78a54b
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 25 deletions.
7 changes: 6 additions & 1 deletion src/pages/Game2048/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import {
} from './Score';
import refreshGameUrl from 'assets/svg/game2048/refresh_game.svg';
import { useAnalytics } from 'services/analytics';
import { useUserData } from 'hooks';
import { useMini, useUserData } from 'hooks';

export const Game: React.FC = () => {
const analytics = useAnalytics();
const { isTop } = useCurrentScreen();
const minigameApi = useMinigameApi();
const { isInWebEnvironment } = useMini();
const { userId, setUserInfo } = useUserData();
const { score: myBestScore, highestScore, gameType } = useMyGame2048Data();
const {
Expand Down Expand Up @@ -49,6 +50,10 @@ export const Game: React.FC = () => {
resetGame();
};
const handleGameEnd = async () => {
if (isInWebEnvironment) {
setIsGameOver(true);
return;
}
analytics.logEvent('click_game_end_button', {
game_type: '2048_puzzle',
button_type: 'game_end',
Expand Down
21 changes: 16 additions & 5 deletions src/pages/Game2048/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export const Home = () => {
});
if (response !== undefined) {
setLastWeekTopDistrict({
townName1: response[0].name1,
townName1: response[0].name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
townName2: response[0].name2,
score: response[0].score,
});
Expand Down Expand Up @@ -253,11 +256,18 @@ export const Home = () => {
1000
);
if (data) {
const indexedDistrictRankData = data.map((item: any, index: number) => ({
rank: index + 1,
const indexedUserRankData = data.map((item: any, index: number) => ({
...item,
rank: index + 1,
town: {
...item.town,
name1: item.town.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
},
}));
setUserLeaderboardData(indexedDistrictRankData);
setUserLeaderboardData(indexedUserRankData);
}
}, [gameType, minigameApi]);
const getDistrictLeaderboardData = useCallback(async () => {
Expand All @@ -266,8 +276,9 @@ export const Home = () => {
} = await minigameApi.gameTownApi.getLeaderBoardByTownUsingGET(gameType);
if (data) {
const indexedDistrictRankData = data.map((item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
name1: item.name1.replace(/(특별시|광역시|특별자치시|특별자치도)$/, ''),
}));
setDistrictLeaderboardData(indexedDistrictRankData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Game2048/Home/LastWeekWinner/LastWeekWinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const LastWeekTopDistrict: React.FC<DistrictProps> = (props) => {
지난 주 <span>1등 동네</span>
</Title>
<Name>
{props.townName1.slice(0, 2)} {props.townName2}
{props.townName1} {props.townName2}
</Name>
<Score>{commafy(props.score)}</Score>
</Container>
Expand Down
12 changes: 10 additions & 2 deletions src/pages/Game2048/Leaderboard/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ export const Leaderboard = () => {
);
if (data) {
const indexedUserRankData = data.map((item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
town: {
...item.town,
name1: item.town.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
},
}));
setUserLeaderboardData(() => indexedUserRankData);
}
Expand All @@ -107,8 +114,9 @@ export const Leaderboard = () => {
} = await minigameApi.gameTownApi.getLeaderBoardByTownUsingGET(gameType);
if (data) {
const indexedDistrictRankData = data.map((item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
name1: item.name1.replace(/(특별시|광역시|특별자치시|특별자치도)$/, ''),
}));

setDistrictLeaderboardData(() => indexedDistrictRankData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Props = {
isRanked: boolean;
};
const LeaderboardTabs: React.FC<Props> = (props) => {
console.log(props.userLeaderboardData);
const { isTop } = useCurrentScreen();
const [activeTabKey, setActiveTabKey] = useState<string>('district');
const handleTabChange = (key: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const DefaultUserRow: React.FC<DefaultUserRowProps> = (props) => {
<Name>
{props.nickname}
<DistrictName color={`#7c7c7c`}>
{props.cityName.slice(0, 2)} {props.districtName}
{props.cityName} {props.districtName}
</DistrictName>
</Name>
<Score>{commafy(props.score)}</Score>
Expand All @@ -49,7 +49,7 @@ export const DefaultDistrictRow: React.FC<DefaultDistrictRowProps> = (
<ContentsWrapper>
<Info>
<Name>
{props.cityName.slice(0, 2)} {props.districtName}
{props.cityName} {props.districtName}
</Name>
<Score>{commafy(props.score)}</Score>
</Info>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Game2048/Leaderboard/LeaderboardTabs/Row/TopRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const TopUserRow: React.FC<TopUserRowProps> = (props) => {
<Name rank={props.rank}>
{props.nickname}
<DistrictName color={`#7c7c7c`}>
{props.cityName.slice(0, 2)} {props.districtName}
{props.cityName} {props.districtName}
</DistrictName>
</Name>
<Score>{commafy(props.score)}</Score>
Expand All @@ -56,7 +56,7 @@ export const TopDistrictRow: React.FC<TopDistrictTowProps> = (props) => {
<ContentsWrapper>
<Info>
<Name rank={props.rank}>
{props.cityName.slice(0, 2)} {props.districtName}
{props.cityName} {props.districtName}
</Name>
<Score>{commafy(props.score)}</Score>
</Info>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Game2048/Leaderboard/MyInfo/MyInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const MyInfo: React.FC = () => {
<Name>
{nickname}
<District>
{cityName.slice(0, 2)} {districtName}
{cityName.replace(/(특별시|광역시|특별자치시|특별자치도)$/, '')}
&nbsp;{districtName}
</District>
</Name>
</Info>
Expand Down
23 changes: 18 additions & 5 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,15 @@ export const Home: React.FC = () => {
});
const indexedResponse2048Puzzle = response?.map(
(item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
town: {
...item.town,
name1: item.town.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
},
})
);
setTop2048PuzzleUsers(indexedResponse2048Puzzle);
Expand All @@ -359,8 +366,15 @@ export const Home: React.FC = () => {
});
const indexedResponseKarrotClicker = response?.map(
(item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
town: {
...item.town,
name1: item.town.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
},
})
);
setTopKarrotClickerUsers(indexedResponseKarrotClicker);
Expand Down Expand Up @@ -497,7 +511,6 @@ export const Home: React.FC = () => {
className="mySwiper"
>
{top2048PuzzleUsers?.map((user, i) => {
console.log(top2048PuzzleUsers, i);
if (user.comment === '' || user.comment === null) {
user.comment = `${user.town.name2} 파이팅!`;
}
Expand All @@ -513,7 +526,7 @@ export const Home: React.FC = () => {
{user.rank}{user.nickname}
</p>
<DistrictName color={`#0E74FF`}>
{user.town.name1.slice(0, 2)} {user.town.name2}
{user.town.name1}&nbsp;{user.town.name2}
</DistrictName>
</div>
<p className="comment">{user.comment}</p>
Expand Down Expand Up @@ -555,7 +568,7 @@ export const Home: React.FC = () => {
{user.rank}{user.nickname}
</p>
<DistrictName color={`#EB5D0E`}>
{user.town.name1.slice(0, 2)} {user.town.name2}
{user.town.name1}&nbsp;{user.town.name2}
</DistrictName>
</div>
<p className="comment">{user.comment}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ export const DistrictLeaderboard: React.FC = () => {
if (data) {
const indexedDistrictRankData = data.map(
(item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
name1: item.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
})
);
setDistrictRankData(indexedDistrictRankData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ export const IndividualLeaderboard: React.FC = () => {
if (data) {
const indexedindividualRankData = data.map(
(item: any, index: number) => ({
rank: index + 1,
...item,
rank: index + 1,
town: {
...item.town,
name1: item.town.name1.replace(
/(특별시|광역시|특별자치시|특별자치도)$/,
''
),
},
})
);
setIndividualRankData(() => indexedindividualRankData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DefaultUserRow: React.FC<DefaultUserRowProps> = (props) => {
<Info>
<Name>
<DistrictName districtName={props.districtName}>
{props.districtName.slice(0, -1)}
{props.districtName}
</DistrictName>
{props.nickname}
</Name>
Expand All @@ -45,7 +45,7 @@ export const DefaultDistrictRow: React.FC<DefaultDistrictRowProps> = (
<ContentsWrapper>
<Info>
<Name>
{props.cityName.slice(0, -3)} {props.districtName}
{props.cityName} {props.districtName}
</Name>
<Score>{commafy(props.score)}</Score>
</Info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TopUserRow: React.FC<TopUserRowProps> = (props) => {
<Info>
<Name rank={props.rank}>
<DistrictName districtName={props.districtName}>
{props.districtName.slice(0, -1)}
{props.districtName}
</DistrictName>
{props.nickname}
</Name>
Expand All @@ -55,7 +55,7 @@ export const TopDistrictRow: React.FC<TopDistrictTowProps> = (props) => {
<ContentsWrapper>
<Info>
<Name rank={props.rank}>
{props.cityName.slice(0, 2)} {props.districtName}
{props.cityName} {props.districtName}
</Name>
<Score>{commafy(props.score)}</Score>
</Info>
Expand Down

0 comments on commit e78a54b

Please sign in to comment.