Skip to content

Commit 8c44824

Browse files
bhoopesh369shubham-1806Ram-20062003
authored
Feat: Reset tutorials (#37)
* feat: reset tutorials ,refresh battletv * Fix: Reset tutorials * fix: small fixes * fix : stats * fix: minor changes --------- Co-authored-by: shubham-1806 <[email protected]> Co-authored-by: Ram-20062003 <[email protected]> Co-authored-by: Ram Ganesh K. R <[email protected]>
1 parent 76ae353 commit 8c44824

File tree

9 files changed

+84
-11
lines changed

9 files changed

+84
-11
lines changed

packages/map-designer/src/Parameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Parameters {
1919

2020
static mapTileOffsetY = 256;
2121

22-
static totalCoins = 10000;
22+
static totalCoins = 6000;
2323

2424
static mapLocalStorageKey = 'cc-map-designer-map';
2525
}

packages/renderer/src/config/TowerConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class TowerConfig {
1010
'tower1_thumbnail.png',
1111
400,
1212
4,
13-
100,
13+
25,
1414
),
1515
new TowerType(
1616
1,
@@ -19,7 +19,7 @@ export default class TowerConfig {
1919
'tower2_thumbnail.png',
2020
600,
2121
6,
22-
200,
22+
50,
2323
),
2424
new TowerType(
2525
2,
@@ -28,7 +28,7 @@ export default class TowerConfig {
2828
'tower3_thumbnail.png',
2929
400,
3030
6,
31-
200,
31+
100,
3232
),
3333
];
3434
}

src/components/BattleTV/BattleTV.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,21 @@
261261
height: 0;
262262
width: 0;
263263
}
264+
.button {
265+
background-color: transparent;
266+
color: #eaeaea;
267+
margin: 0px 8px;
268+
border: 1px solid #eaeaea;
269+
padding: 8px;
270+
text-transform: uppercase;
271+
border-radius: 8px;
272+
font-family: monospace, sans-serif;
273+
display: inline-block;
274+
white-space: nowrap;
275+
transition: 0.3s;
276+
}
277+
278+
.button:hover {
279+
color: #0a1c2a;
280+
background-color: #aaaaaa;
281+
}

src/components/BattleTV/BattleTV.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function PaginatedItems() {
125125
></img>
126126
</div>
127127
<span className={[styles.name].join(' ')}>
128-
{match.user1.username}
128+
{match.user1.username.substring(0, 10)}
129129
</span>
130130
</span>
131131
<span className={styles.coinsusedleft}>
@@ -206,6 +206,16 @@ function PaginatedItems() {
206206
containerClassName={styles.pagination}
207207
activeClassName="active"
208208
/>
209+
<button
210+
type="button"
211+
className={styles.button}
212+
onClick={() => {
213+
dispatch(fetchBattleTv());
214+
}}
215+
id="refresh"
216+
>
217+
Refresh
218+
</button>
209219
</nav>
210220
</>
211221
);

src/components/DashboardOptions/DashboardOptions.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11
import Dropdown from 'react-bootstrap/Dropdown';
2-
import { Link } from 'react-router-dom';
2+
import { Link, useNavigate } from 'react-router-dom';
33
import styles from './DashboardOptions.module.css';
44
import DropdownToggle from 'react-bootstrap/esm/DropdownToggle';
55
import { ButtonGroup } from 'react-bootstrap';
6+
import { apiConfig, ApiError } from '../../api/ApiConfig';
7+
import { CurrentUserApi } from '@codecharacter-2023/client';
8+
import Toast from 'react-hot-toast';
9+
import { useAppDispatch } from '../../store/hooks';
10+
import {
11+
isTourOverChanged,
12+
isTourResetChanged,
13+
} from '../../store/DailyChallenge/dailyChallenge';
614

715
interface dashboardoptions {
816
image?: JSX.Element;
917
onLogout?: React.MouseEventHandler<HTMLElement>;
1018
}
1119

1220
const DashboardOptions = (props: dashboardoptions): JSX.Element => {
21+
const currentUserApi = new CurrentUserApi(apiConfig);
22+
const navigate = useNavigate();
23+
const dispatch = useAppDispatch();
24+
25+
const resetTutorials = () => {
26+
currentUserApi
27+
.updateCurrentUser({
28+
updateTutorialLevel: 'RESET',
29+
})
30+
.then(() => {
31+
navigate('/dashboard', { replace: true });
32+
dispatch(isTourResetChanged(true));
33+
dispatch(isTourOverChanged(false));
34+
})
35+
.catch(err => {
36+
if (err instanceof ApiError) Toast.error(err.message);
37+
});
38+
};
39+
1340
return (
1441
<div className={styles.dropdown}>
1542
<Dropdown as={ButtonGroup}>
@@ -20,6 +47,9 @@ const DashboardOptions = (props: dashboardoptions): JSX.Element => {
2047
<Dropdown.Item as={Link} to="/profile" className={styles.menuText}>
2148
View Profile
2249
</Dropdown.Item>
50+
<Dropdown.Item onClick={resetTutorials} className={styles.menuText}>
51+
Revisit Tutorial
52+
</Dropdown.Item>
2353
<Dropdown.Item onClick={props.onLogout} className={styles.menuText}>
2454
Logout
2555
</Dropdown.Item>

src/components/Leaderboard/DailyLeaderboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function PaginatedItems() {
9999
className={styles.pic}
100100
src={getAvatarByID(row.avatarId).url}
101101
></img>
102-
{' ' + row.userName}
102+
{' ' + row.userName.substring(0, 10)}
103103
</div>
104104
</td>
105105
<td className={styles.score}>{row.score}</td>

src/components/Leaderboard/Leaderboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function PaginatedItems() {
160160
className={styles.pic}
161161
src={getAvatarByID(row.user.avatarId).url}
162162
></img>
163-
{' ' + row.user.username}
163+
{' ' + row.user.username.substring(0, 10)}
164164
</div>
165165
</td>
166166
<td className={styles.score}>

src/components/TourIntroModal/TourIntroModal.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@ import { apiConfig, ApiError } from '../../api/ApiConfig';
33
import { CurrentUserApi } from '@codecharacter-2023/client';
44
import Toast from 'react-hot-toast';
55
import styles from './TourIntroModal.module.css';
6-
import { useAppSelector } from '../../store/hooks';
6+
import { useAppDispatch, useAppSelector } from '../../store/hooks';
77
import { user } from '../../store/User/UserSlice';
88
import { useEffect, useState } from 'react';
99
import { useNavigate } from 'react-router-dom';
1010
import { useTour } from '@reactour/tour';
11-
import { IsTourOver } from '../../store/DailyChallenge/dailyChallenge';
11+
import {
12+
IsTourOver,
13+
IsTourReset,
14+
isTourResetChanged,
15+
} from '../../store/DailyChallenge/dailyChallenge';
1216

1317
const TourIntroModal = (): JSX.Element => {
1418
const [isTourOpen, setIsTourOpen] = useState(false);
1519
const currentUserApi = new CurrentUserApi(apiConfig);
1620

1721
const User = useAppSelector(user);
1822
const navigate = useNavigate();
23+
const dispatch = useAppDispatch();
1924
const { setIsOpen } = useTour();
2025

2126
const isTourOver = useAppSelector(IsTourOver);
27+
const isTourReset = useAppSelector(IsTourReset);
2228

2329
const handleShowClick = () => {
2430
setIsTourOpen(false);
@@ -70,10 +76,11 @@ const TourIntroModal = (): JSX.Element => {
7076
currentUserApi.getCurrentUser().then(res => {
7177
if (res.isTutorialComplete === false && res.tutorialLevel < 6) {
7278
setIsTourOpen(true);
79+
dispatch(isTourResetChanged(false));
7380
}
7481
});
7582
}
76-
}, [isTourOver]);
83+
}, [isTourOver, isTourReset]);
7784

7885
return (
7986
<Modal show={isTourOpen} centered onHide={onHide}>

src/store/DailyChallenge/dailyChallenge.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface DailyChallengeStateType {
1818
dcMap: Array<Array<number>>;
1919
isSimulating: boolean;
2020
isTourOver: boolean;
21+
isTourReset: boolean;
2122
}
2223

2324
const initialState: DailyChallengeStateType = {
@@ -40,6 +41,7 @@ const initialState: DailyChallengeStateType = {
4041
dcMap: [],
4142
isSimulating: false,
4243
isTourOver: false,
44+
isTourReset: false,
4345
};
4446

4547
export const dailyChallengeSlice = createSlice({
@@ -87,6 +89,9 @@ export const dailyChallengeSlice = createSlice({
8789
isTourOverChanged: (state, action: PayloadAction<boolean>) => {
8890
state.isTourOver = action.payload;
8991
},
92+
isTourResetChanged: (state, action: PayloadAction<boolean>) => {
93+
state.isTourReset = action.payload;
94+
},
9095
},
9196
});
9297

@@ -98,6 +103,7 @@ export const {
98103
changeDcMap,
99104
changeSimulationState,
100105
isTourOverChanged,
106+
isTourResetChanged,
101107
} = dailyChallengeSlice.actions;
102108
export const dailyChallengeState = (
103109
state: RootState,
@@ -119,4 +125,6 @@ export const dcSimulation = (state: RootState): boolean =>
119125
state.dailyChallenge.isSimulating;
120126
export const IsTourOver = (state: RootState): boolean =>
121127
state.dailyChallenge.isTourOver;
128+
export const IsTourReset = (state: RootState): boolean =>
129+
state.dailyChallenge.isTourReset;
122130
export default dailyChallengeSlice.reducer;

0 commit comments

Comments
 (0)