Skip to content

Commit 76ae353

Browse files
authored
fix: updated profile page, added dcEnable env (#39)
* fix: updated profile page, added dcEnable env * fix: hid dc leaderboard * fix: fixed dc Enable and Name
1 parent 1c019eb commit 76ae353

File tree

6 files changed

+104
-66
lines changed

6 files changed

+104
-66
lines changed

src/components/Leaderboard/MainLeaderboard.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import styles from './Leaderboard.module.css';
55
import { CurrentUserApi } from '@codecharacter-2023/client';
66
import { useTour } from '@reactour/tour';
77
import { apiConfig } from '../../api/ApiConfig';
8+
import { dcEnable } from '../../config/config';
89

910
export default function BattleTV(): JSX.Element {
1011
const [isDailyChallengeLeaderboard, setIsDailyChallengeLeaderboard] =
@@ -36,21 +37,25 @@ export default function BattleTV(): JSX.Element {
3637
) : (
3738
<Leaderboard />
3839
)}
39-
<button
40-
type="button"
41-
className={styles.button}
42-
onClick={() => {
43-
if (!isDailyChallengeLeaderboard) {
44-
setIsDailyChallengeLeaderboard(true);
45-
setLeaderboardType('Match Leaderboard');
46-
} else {
47-
setIsDailyChallengeLeaderboard(false);
48-
setLeaderboardType('Daily Challenge Leaderboard');
49-
}
50-
}}
51-
>
52-
{leaderboardType}
53-
</button>
40+
{dcEnable ? (
41+
<button
42+
type="button"
43+
className={styles.button}
44+
onClick={() => {
45+
if (!isDailyChallengeLeaderboard) {
46+
setIsDailyChallengeLeaderboard(true);
47+
setLeaderboardType('Match Leaderboard');
48+
} else {
49+
setIsDailyChallengeLeaderboard(false);
50+
setLeaderboardType('Daily Challenge Leaderboard');
51+
}
52+
}}
53+
>
54+
{leaderboardType}
55+
</button>
56+
) : (
57+
<></>
58+
)}
5459
</div>
5560
);
5661
}

src/components/NavBar/NavBar.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ import { AuthApi } from '@codecharacter-2023/client';
1616
import { apiConfig, ApiError } from '../../api/ApiConfig';
1717
import Toast from 'react-hot-toast';
1818
import DashboardOptions from '../DashboardOptions/DashboardOptions';
19-
import { cookieDomain } from '../../config/config';
19+
import { cookieDomain, dcEnable } from '../../config/config';
2020

2121
import signUpIcon from '../../assets/sign_up.svg';
2222
import signInIcon from '../../assets/sign_in.svg';
23-
// import challengeDone from '../../assets/challenge_done.png';
24-
// import challengeAvailable from '../../assets/challenge_available.png';
23+
import challengeDone from '../../assets/challenge_done.png';
24+
import challengeAvailable from '../../assets/challenge_available.png';
2525
import DcCompleted from '../DcModals/DcCompleted';
2626
import DcAvailable from '../DcModals/DcAvailable';
2727
import {
2828
changePageState,
2929
changeSimulationState,
30-
// dailyChallengeCompletionState,
30+
dailyChallengeCompletionState,
3131
} from '../../store/DailyChallenge/dailyChallenge';
3232

3333
const NavBar: React.FunctionComponent = () => {
@@ -37,7 +37,7 @@ const NavBar: React.FunctionComponent = () => {
3737
const loggedInUser = useAppSelector(user);
3838
const isLogged = useAppSelector(isloggedIn);
3939
const loadingAuth = useAppSelector(loading);
40-
// const dcCompletionstatus = useAppSelector(dailyChallengeCompletionState);
40+
const dcCompletionstatus = useAppSelector(dailyChallengeCompletionState);
4141
useEffect(() => {
4242
const cookieValue = document.cookie;
4343
const bearerToken = cookieValue.split(';');
@@ -157,16 +157,20 @@ const NavBar: React.FunctionComponent = () => {
157157
location.pathname != '/' ? (
158158
<div className={styles.profileIcons}>
159159
<div className={styles.notifIconContainer}>
160-
{/* <img
161-
src={dcCompletionstatus ? challengeDone : challengeAvailable}
162-
className={styles.dcIcon}
163-
title="Daily Challenge"
164-
onClick={() => {
165-
dcCompletionstatus
166-
? setShowCompleted(true)
167-
: setShowAvailable(true);
168-
}}
169-
/> */}
160+
{dcEnable ? (
161+
<img
162+
src={dcCompletionstatus ? challengeDone : challengeAvailable}
163+
className={styles.dcIcon}
164+
title="Daily Challenge"
165+
onClick={() => {
166+
dcCompletionstatus
167+
? setShowCompleted(true)
168+
: setShowAvailable(true);
169+
}}
170+
/>
171+
) : (
172+
<></>
173+
)}
170174
</div>
171175
<div className={styles.notifIcon}>
172176
<Notifs />

src/components/Profile/Profile.tsx

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const Profile = (): JSX.Element => {
4545
confirmPassword: 'password',
4646
});
4747
const err = useAppSelector(isCreditionalError);
48-
const profileScrollRef = useRef<HTMLDivElement>(null);
4948
const oldpasswordTypeAction = () => {
5049
if (passwordType.oldpassword === 'password') {
5150
setPasswordType({
@@ -197,6 +196,8 @@ const Profile = (): JSX.Element => {
197196
setSelectedAvatar(id);
198197
};
199198

199+
const profileScrollRef = useRef<HTMLDivElement>(null);
200+
200201
const handleGoToCreds = () => {
201202
if (profileScrollRef.current) {
202203
profileScrollRef.current.scrollTo({
@@ -215,6 +216,15 @@ const Profile = (): JSX.Element => {
215216
}
216217
};
217218

219+
const handleGoToRatingChart = () => {
220+
if (profileScrollRef.current) {
221+
profileScrollRef.current.scrollTo({
222+
top: 1900,
223+
behavior: 'smooth',
224+
});
225+
}
226+
};
227+
218228
return (
219229
<div
220230
className={styles.profileScrollBody}
@@ -241,7 +251,7 @@ const Profile = (): JSX.Element => {
241251
className={classnames('mb-4', styles.formField)}
242252
controlId="formBasicUserName"
243253
>
244-
<Form.Label className={styles.label}>USERNAME</Form.Label>
254+
<Form.Label className={styles.label}>NAME</Form.Label>
245255
<Form.Control
246256
type="text"
247257
placeholder={loggedInUser.name || 'Full Name'}
@@ -331,20 +341,16 @@ const Profile = (): JSX.Element => {
331341
</Button>
332342
</div>
333343
<div className={styles.footer}>
334-
{
335-
<>
336-
<Button
337-
variant="link"
338-
onClick={() => {
339-
handleGoToCreds();
340-
dispatch(creditionals());
341-
}}
342-
className={styles.linkButton}
343-
>
344-
{'CHANGE CREDENTIALS '}
345-
</Button>
346-
</>
347-
}
344+
<Button
345+
variant="link"
346+
onClick={() => {
347+
handleGoToCreds();
348+
dispatch(creditionals());
349+
}}
350+
className={styles.linkButton}
351+
>
352+
{'CHANGE CREDENTIALS '}
353+
</Button>
348354
</div>
349355
</div>
350356
<div>
@@ -459,23 +465,39 @@ const Profile = (): JSX.Element => {
459465
SUBMIT{' '}
460466
</Button>
461467
</div>
468+
<div className={styles.footer}>
469+
<Button
470+
variant="link"
471+
onClick={handleGoBacktoProfile}
472+
className={styles.linkButton}
473+
>
474+
{' EDIT PROFILE'}
475+
</Button>
476+
<Button
477+
variant="link"
478+
onClick={handleGoToRatingChart}
479+
className={styles.linkButton}
480+
>
481+
{' RATING CHART'}
482+
</Button>
483+
</div>
462484
</div>
463485
</Form>
486+
<RatingChart />
464487
<div className={styles.footer}>
465488
<Button
466489
variant="link"
467-
onClick={handleGoBacktoProfile}
490+
onClick={() => {
491+
handleGoToCreds();
492+
dispatch(creditionals());
493+
}}
468494
className={styles.linkButton}
469495
>
470-
{' EDIT PROFILE'}
496+
{'CHANGE CREDENTIALS '}
471497
</Button>
472498
</div>
473499
</div>
474500
</div>
475-
<div>
476-
<RatingChart />
477-
<div className={styles.emptyspace}></div>
478-
</div>
479501
</div>
480502
);
481503
};

src/components/Profile/profile.module.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: flex;
33
margin-top: 2rem;
44
flex-direction: column;
5-
height: 1900px;
5+
height: 2700px;
66
}
77

88
.Container {
@@ -13,7 +13,9 @@
1313
flex-direction: column;
1414
overflow: hidden;
1515
}
16-
16+
.Container > .footer {
17+
height: 10rem;
18+
}
1719
.header {
1820
color: white;
1921
padding: 1rem;
@@ -102,8 +104,9 @@
102104
.footer {
103105
text-align: center;
104106
display: flex;
105-
flex-direction: column-reverse;
106107
align-items: center;
108+
justify-content: space-evenly;
109+
107110
}
108111

109112

@@ -253,6 +256,9 @@
253256
.formContainer > div:nth-child(1) {
254257
height: 55rem;
255258
}
259+
.formContainer > div:nth-child(2) {
260+
height: 50rem;
261+
}
256262

257263
.profileScrollBody {
258264
height: 100%;
@@ -265,6 +271,3 @@
265271
top: 10px;
266272
}
267273

268-
.emptyspace {
269-
height: 13vw;
270-
}

src/config/config.example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export const SECRET_KEY = 'YOUR SECRET KEY';
55
export const accessUrl = 'ACCESS URL FOR CORS';
66
export const homeUrl = 'http://localhost:3000';
77
export const lspUrl = 'ws://localhost:8000/ws';
8+
export const dcEnable = false;
89

910
export const cookieDomain = 'localhost';

src/pages/Dashboard/Dashboard.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import Tour from '../../components/TourProvider/TourProvider';
6767
import { EditorSteps } from '../../components/TourProvider/EditorSteps';
6868
import { useNavigate } from 'react-router-dom';
6969
import TourIntroModal from '../../components/TourIntroModal/TourIntroModal';
70+
import { dcEnable } from '../../config/config';
7071

7172
type SplitPaneState = {
7273
horizontalPercent: string;
@@ -140,14 +141,16 @@ export default function Dashboard(): JSX.Element {
140141
dispatch(loggedIn());
141142
}
142143
});
143-
dailyChallengeAPI
144-
.getDailyChallenge()
145-
.then(response => {
146-
dispatch(initializeDailyChallengeState(response));
147-
})
148-
.catch(err => {
149-
if (err instanceof ApiError) Toast.error(err.message);
150-
});
144+
if (dcEnable) {
145+
dailyChallengeAPI
146+
.getDailyChallenge()
147+
.then(response => {
148+
dispatch(initializeDailyChallengeState(response));
149+
})
150+
.catch(err => {
151+
if (err instanceof ApiError) Toast.error(err.message);
152+
});
153+
}
151154
}, []);
152155

153156
useEffect(() => {

0 commit comments

Comments
 (0)