Skip to content

Commit

Permalink
fix: added tutorial icon, change tutorial number
Browse files Browse the repository at this point in the history
  • Loading branch information
Aadit-Krishnaa-R committed Jan 28, 2024
1 parent 72294a7 commit e9643c2
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 31 deletions.
4 changes: 4 additions & 0 deletions src/assets/book (1).png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.flaticon.com/free-icon/book_13637888?term=code+tutorials&page=1&position=1&origin=search&related_id=13637888
HostUrl=https://www.flaticon.com/download/icon/edited
Binary file added src/assets/tutorial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/MapDesigner/MapDesigner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function MapDesigner(props: MapDesignerProps): JSX.Element {
tutorialAPI
.createCodeTutorialMatch({
value: JSON.stringify(stagedMap),
codeTutorialNumber: 6,
codeTutorialNumber: 4,
})
.then(() => {
Toast.success('Code Tutorial submitted succesfully');
Expand Down
13 changes: 13 additions & 0 deletions src/components/NavBar/NavBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@
opacity: 0.8;
}

.tutorialIcon {
height: 37px;
width: auto;
margin-top: 5px;
position: relative;
margin-right: 2rem;
}

.tutorialIcon:hover{
cursor: pointer;
opacity: 0.8;
}

.navbarTextButton {
background-color: #374043;
color: #fff;
Expand Down
18 changes: 6 additions & 12 deletions src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import signUpIcon from '../../assets/sign_up.svg';
import signInIcon from '../../assets/sign_in.svg';
import challengeDone from '../../assets/challenge_done.png';
import challengeAvailable from '../../assets/challenge_available.png';
import tutorialIcon from '../../assets/tutorial.png';
import DcCompleted from '../DcModals/DcCompleted';
import DcAvailable from '../DcModals/DcAvailable';
import {
Expand Down Expand Up @@ -188,21 +189,14 @@ const NavBar: React.FunctionComponent = () => {
<div className={styles.profileIcons}>
<div className={styles.notifIconContainer}>
{pageState == 'Dashboard' ? (
<button
className={styles.navbarTextButton}
<img
src={tutorialIcon}
className={styles.tutorialIcon}
title="Code Tutorials"
onClick={() => {
setShowTutorial(true);
}}
>
Launch Tutorial
</button>
) : pageState == 'Tutorials' ? (
<button
className={styles.navbarTextButton}
onClick={handleTutorialClose}
>
Close Tutorial
</button>
/>
) : (
<></>
)}
Expand Down
43 changes: 25 additions & 18 deletions src/pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default function Dashboard(): JSX.Element {
.getLatestCode()
.then(response => {
dispatch(initializeEditorStates(response));
console.log(response);
})
.catch(err => {
if (err instanceof ApiError) Toast.error(err.message);
Expand Down Expand Up @@ -289,7 +290,7 @@ export default function Dashboard(): JSX.Element {
if (isInfoOpen === true) dispatch(isInfoOpened(false));
else dispatch(isInfoOpened(true));
}

console.log(userCode);
const handleSubmit = () => {
let languageType: Language = Language.Cpp;
if (userLanguage === 'c_cpp') languageType = Language.Cpp;
Expand Down Expand Up @@ -357,8 +358,10 @@ export default function Dashboard(): JSX.Element {
const currentUserApi = new CurrentUserApi(apiConfig);

const User = useAppSelector(user);
const codeTutorialInitialLevel = User.codeTutorialNumber;
console.log(codeTutorialInitialLevel);
const navigate = useNavigate();

console.log(codeTutorialNumber);
const setOpened = (opened: boolean) => {
if (opened === false) {
currentUserApi
Expand Down Expand Up @@ -581,19 +584,23 @@ export default function Dashboard(): JSX.Element {
</Form.Select>
</Col>
<div className={styles.midDiv}>
<Col className={styles.toolbarColumn} sm="1">
<button
className={styles.toolbarButton}
onClick={handleSubmit}
ref={submitButtonRef}
id="SubmitButton"
>
<FontAwesomeIcon
title="Submit"
icon={faCloudUploadAlt as IconProp}
/>{' '}
</button>
</Col>
{codeTutorialNumber == 4 ? (
<></>
) : (
<Col className={styles.toolbarColumn} sm="1">
<button
className={styles.toolbarButton}
onClick={handleSubmit}
ref={submitButtonRef}
id="SubmitButton"
>
<FontAwesomeIcon
title="Submit"
icon={faCloudUploadAlt as IconProp}
/>{' '}
</button>
</Col>
)}
<>
{codeTutorialNumber == 1 ? (
<></>
Expand All @@ -605,7 +612,7 @@ export default function Dashboard(): JSX.Element {
Prev Tutorial
</button>
)}
{codeTutorialNumber == 6 ? (
{codeTutorialNumber == 4 ? (
<> </>
) : (
<button
Expand Down Expand Up @@ -768,7 +775,7 @@ export default function Dashboard(): JSX.Element {
>
<div className={styles.rightPane} id="MAP">
{pageState == 'Dashboard' ||
(pageState == 'Tutorials' && codeTutorialNumber != 6) ||
(pageState == 'Tutorials' && codeTutorialNumber != 4) ||
dailyChallengeSimulationState ? (
<RendererComponent />
) : dailyChallenge.challType == 'MAP' ? (
Expand All @@ -783,7 +790,7 @@ export default function Dashboard(): JSX.Element {
></img>
</div>
</>
) : pageState == 'Tutorials' && codeTutorialNumber == 6 ? (
) : pageState == 'Tutorials' && codeTutorialNumber == 4 ? (
<MapDesigner pageType={'Tutorials'} />
) : (
<MapDesigner pageType={'DailyChallenge'} />
Expand Down
5 changes: 5 additions & 0 deletions src/store/Tutorials/tutorials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { CodeAndLanguage, languagesAvailable } from '../editor/code';
import defaultCppCode from '../../assets/codes/cpp/run.cpp?raw';
import defaultPythonCode from '../../assets/codes/python/run.py?raw';
import defaultJavaCode from '../../assets/codes/java/Run.java?raw';
// import { user } from '../../store/User/UserSlice';
// import { useAppSelector } from '../hooks';

// const User = useAppSelector(user);
// const codeTutorialInitialLevel = User.codeTutorialNumber;
// console.log(codeTutorialInitialLevel);
export interface TutorialStateType {
tutorials: TutorialsGetRequest;
tutorialCode: string | undefined;
Expand Down
2 changes: 2 additions & 0 deletions src/store/User/UserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const getUserDetails = (): Promise<{
country: string;
avatarId: number;
isTutorialComplete: boolean;
codeTutorialNumber: number | undefined;
}> => {
return new Promise((resolve, reject) => {
const currentUserapi = new CurrentUserApi(apiConfig);
Expand All @@ -82,6 +83,7 @@ export const getUserDetails = (): Promise<{
country: res.country,
avatarId: res.avatarId,
isTutorialComplete: res.isTutorialComplete,
codeTutorialNumber: res.codeTutorialLevel,
});
})
.catch(error => {
Expand Down
2 changes: 2 additions & 0 deletions src/store/User/UserSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface User {
college: string;
avatarId: number;
recaptchaCode: string;
codeTutorialNumber: number;
}

interface register {
Expand Down Expand Up @@ -48,6 +49,7 @@ const initialState: register = {
college: '',
avatarId: 0,
recaptchaCode: '',
codeTutorialNumber: 1,
},
loading: false,
isRegistered: false,
Expand Down

0 comments on commit e9643c2

Please sign in to comment.