Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved Lint Warnings #27

Merged
merged 11 commits into from
May 6, 2024
13 changes: 7 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { ThemeProvider } from '@mui/material';
import { BrowserRouter as Router } from 'react-router-dom';
import { StyledEngineProvider } from '@mui/material/styles';
@@ -11,14 +11,15 @@ import { startEvent } from './services/callTelemetryIntract';
import '@project-sunbird/telemetry-sdk/index.js';

const App = () => {
let ranonce = false;
const ranonce = useRef(false);
useEffect(() => {
const initService = async () => {
var did;
if (localStorage.getItem('fpDetails_v2') !== null) {
let fpDetails_v2 = localStorage.getItem('fpDetails_v2');
var did = fpDetails_v2.result;
did = fpDetails_v2.result;
} else {
var did = localStorage.getItem('did');
did = localStorage.getItem('did');
}

await initialize({
@@ -49,11 +50,11 @@ const App = () => {
// tslint:disable-next-line:max-line-length
metadata: {},
});
if (!ranonce) {
if (!ranonce.current) {
if (localStorage.getItem('contentSessionId') === null) {
startEvent();
}
ranonce = true;
ranonce.current = true;
}
};

17 changes: 7 additions & 10 deletions src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
@@ -18,11 +18,9 @@ import {
import practicebg from "../../assets/images/practice-bg.svg";
import {
useNavigate,
useSearchParams,
} from "../../../node_modules/react-router-dom/dist/index";
import { useEffect, useState } from "react";
import axios from "../../../node_modules/axios/index";
import { uniqueId } from "../../services/utilService";
// import { useDispatch } from 'react-redux';
import { setVirtualId } from "../../store/slices/user.slice";
import { useDispatch, useSelector } from "react-redux";
@@ -38,7 +36,6 @@ import desktopLevel8 from "../../assets/images/desktopLevel8.png";
import desktopLevel9 from "../../assets/images/desktopLevel9.png";
import profilePic from "../../assets/images/profile_url.png";
import textureImage from "../../assets/images/textureImage.png";
import scoreView from "../../assets/images/scoreView.png";
import back from "../../assets/images/back-arrow.png";
import { jwtDecode } from "jwt-decode";
import config from "../../utils/urlConstants.json";
@@ -91,7 +88,7 @@ export const LanguageModal = ({ lang, setLang, setOpenLangModal }) => {
<Box sx={{ width: "100%", display: "flex", justifyContent: "center" }}>
<Grid container justifyContent={"space-evenly"} sx={{ width: "80%" }}>
{languages.map((elem) => {
const isSelectedLang = elem.lang == selectedLang;
const isSelectedLang = elem.lang === selectedLang;
return (
<Grid xs={4} item>
<Box
@@ -380,7 +377,7 @@ export const ProfileHeader = ({
sx={{ cursor: "pointer" }}
onClick={() => navigate("/")}
>
<img src={profilePic}></img>
<img src={profilePic} alt="profile-pic"></img>
</Box>
<Box ml="12px">
<span
@@ -452,7 +449,7 @@ export const ProfileHeader = ({
lineHeight: "25px",
}}
>
{languages?.find((elem) => elem.lang == language).name ||
{languages?.find((elem) => elem.lang === language).name ||
`Select Language`}
</span>
</Box>
@@ -471,8 +468,8 @@ const Assesment = ({ discoverStart }) => {
var userDetails = jwtDecode(jwtToken);
username = userDetails.student_name;
}
const [searchParams, setSearchParams] = useSearchParams();
const [profileName, setProfileName] = useState(username);
// const [searchParams, setSearchParams] = useSearchParams();
// const [profileName, setProfileName] = useState(username);
const [openMessageDialog, setOpenMessageDialog] = useState("");
// let lang = searchParams.get("lang") || "ta";
const [level, setLevel] = useState("");
@@ -551,15 +548,15 @@ const Assesment = ({ discoverStart }) => {
const navigate = useNavigate();
const handleRedirect = () => {
const profileName = getLocalData("profileName");
if (!username && !profileName && !virtualId && level == 0) {
if (!username && !profileName && !virtualId && level === 0) {
// alert("please add username in query param");
setOpenMessageDialog({
message: "please add username in query param",
isError: true,
});
return;
}
if (level == 0) {
if (level === 0) {
navigate("/discover");
} else {
navigate("/practice");
23 changes: 9 additions & 14 deletions src/components/AssesmentEnd/AssesmentEnd.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import MainLayout from "../Layouts.jsx/MainLayout";
import assessmentBackground from "../../assets/images/assessmentBackground.png";
import { Box } from "@mui/material";
import {
AssesmentCompletePlane,
AverageMood,
BadMood,
GoodMood,
LevelRight,
StartAssessmentButton,
getLocalData,
setLocalData,
} from "../../utils/constants";
import homeBackground from "../../assets/images/homeBackground.png";
import { Typography } from "../../../node_modules/@mui/material/index";
import coinStar from "../../assets/images/coinStar.svg";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import { useEffect, useState } from "react";
@@ -53,7 +49,6 @@ const AssesmentEnd = () => {
}, 4000);
}, []);

let width = window.innerWidth * 0.85;
const navigate = useNavigate();
let newLevel = level.replace("m", "");

@@ -86,7 +81,7 @@ const AssesmentEnd = () => {
letterSpacing: "2%",
}}
>
{newLevel == previousLevel ? "Amost There.!" : `Hurray.!`}
{newLevel === previousLevel ? "Amost There.!" : `Hurray.!`}
</span>
</Box>
<Box
@@ -106,7 +101,7 @@ const AssesmentEnd = () => {
lineHeight: "30px",
}}
>
{newLevel == previousLevel
{newLevel === previousLevel
? "more"
: `Level ${previousLevel || ""}`}
</span>
@@ -128,16 +123,16 @@ const AssesmentEnd = () => {
lineHeight: "30px",
}}
>
{newLevel == previousLevel ? "practice" : `completed`}
{newLevel === previousLevel ? "practice" : `completed`}
</span>
</Box>
<Box
sx={{
position: "absolute",
bottom: newLevel == previousLevel ? 115 : 125,
left: newLevel == previousLevel ? 190 : 200,
bottom: newLevel === previousLevel ? 115 : 125,
left: newLevel === previousLevel ? 190 : 200,
transform:
newLevel == previousLevel ? "rotate(-5deg)" : "rotate(-18deg)",
newLevel === previousLevel ? "rotate(-5deg)" : "rotate(-18deg)",
}}
>
<span
@@ -149,7 +144,7 @@ const AssesmentEnd = () => {
lineHeight: "30px",
}}
>
{newLevel == previousLevel ? "required" : `successfully`}
{newLevel === previousLevel ? "required" : `successfully`}
</span>
</Box>
</Box>
@@ -308,7 +303,7 @@ const AssesmentEnd = () => {
textAlign: "center",
}}
>
{newLevel == previousLevel ? `Almost There!!!` : `Hurray!!!`}
{newLevel === previousLevel ? `Almost There!!!` : `Hurray!!!`}
</Typography>
<Box mt={1}>
<span
@@ -321,7 +316,7 @@ const AssesmentEnd = () => {
letterSpacing: "2%",
}}
>
{newLevel == previousLevel
{newLevel === previousLevel
? `Some more practice required to complete ${previousLevel}`
: `You completed Level ${previousLevel} successfully`}
</span>
36 changes: 15 additions & 21 deletions src/components/DiscoverSentance/DiscoverSentance.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import axios from "../../../node_modules/axios/index";
import coin from "../../assets/audio/coin.mp3";
import elephant from "../../assets/images/elephant.svg";
import {
UserID,
callConfetti,
getLocalData,
questionsList,
setLocalData,
} from "../../utils/constants";
import WordsOrImage from "../Mechanism/WordsOrImage";
import { useSearchParams } from "../../../node_modules/react-router-dom/dist/index";
import { uniqueId } from "../../services/utilService";
import useSound from "use-sound";
import confetti from "canvas-confetti";
import LevelCompleteAudio from "../../assets/audio/levelComplete.wav";
import config from "../../utils/urlConstants.json";
import { MessageDialog } from "../Assesment/Assesment";
@@ -23,7 +18,6 @@ const SpeakSentenceComponent = () => {
const [currentQuestion, setCurrentQuestion] = useState(0);
const navigate = useNavigate();
const [recordedAudio, setRecordedAudio] = useState("");
const [Story, setStory] = useState([]);
const [voiceText, setVoiceText] = useState("");
const [storyLine, setStoryLine] = useState(0);
const [assessmentResponse, setAssessmentResponse] = useState(undefined);
@@ -52,7 +46,7 @@ const SpeakSentenceComponent = () => {
}, [questions]);

useEffect(() => {
if (questions?.length && !initialAssesment && currentQuestion == 0) {
if (questions?.length && !initialAssesment && currentQuestion === 0) {
setDisableScreen(true);
callConfettiAndPlay();
setTimeout(() => {
@@ -96,7 +90,7 @@ const SpeakSentenceComponent = () => {
setVoiceText("");
setEnableNext(false);
}
if (voiceText == "success") {
if (voiceText === "success") {
setEnableNext(true);
// go_to_result(voiceText);
setVoiceText("");
@@ -151,7 +145,7 @@ const SpeakSentenceComponent = () => {

if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
} else if (currentQuestion == questions.length - 1) {
} else if (currentQuestion === questions.length - 1) {
const sub_session_id = getLocalData("sub_session_id");
const getSetResultRes = await axios.post(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_SET_RESULT}`,
@@ -178,16 +172,16 @@ const SpeakSentenceComponent = () => {
}
);
if (
getSetData.data.sessionResult == "pass" &&
currentContentType == "Sentence" &&
getSetData.data.sessionResult === "pass" &&
currentContentType === "Sentence" &&
sentencePassedCounter < 2
) {
if (getSetData.data.currentLevel !== "m0") {
navigate("/discover-end");
}
const newSentencePassedCounter = sentencePassedCounter + 1;
const sentences = assessmentResponse?.data?.data?.filter(
(elem) => elem.category == "Sentence"
(elem) => elem.category === "Sentence"
);
const resSentencesPagination = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_PAGINATION}?page=1&limit=5&collectionId=${sentences?.[newSentencePassedCounter]?.content?.[0]?.collectionId}`
@@ -200,17 +194,17 @@ const SpeakSentenceComponent = () => {
setCurrentQuestion(0);
setSentencePassedCounter(newSentencePassedCounter);
setQuestions(quesArr);
} else if (getSetData.data.sessionResult == "pass") {
} else if (getSetData.data.sessionResult === "pass") {
navigate("/discover-end");
} else if (
getSetData.data.sessionResult == "fail" &&
currentContentType == "Sentence"
getSetData.data.sessionResult === "fail" &&
currentContentType === "Sentence"
) {
if (getSetData.data.currentLevel !== "m0") {
navigate("/discover-end");
}
const words = assessmentResponse?.data?.data?.find(
(elem) => elem.category == "Word"
(elem) => elem.category === "Word"
);
const resWordsPagination = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_PAGINATION}?page=1&limit=5&collectionId=${words?.content?.[0]?.collectionId}`
@@ -221,13 +215,13 @@ const SpeakSentenceComponent = () => {
setCurrentQuestion(0);
setQuestions(quesArr);
} else if (
getSetData.data.sessionResult == "fail" &&
currentContentType == "Word"
getSetData.data.sessionResult === "fail" &&
currentContentType === "Word"
) {
navigate("/discover-end");

// const char = assessmentResponse?.data?.data?.find(
// (elem) => elem.category == "Char"
// (elem) => elem.category === "Char"
// );
// const resCharPagination = await axios.get(
// `${process.env.REACT_APP_LEARNER_AI_APP_HOST}/content-service/v1/content/pagination?page=1&limit=5&collectionId=${char?.content?.[0]?.collectionId}`
@@ -265,7 +259,7 @@ const SpeakSentenceComponent = () => {
);

const sentences = resAssessment?.data?.data?.find(
(elem) => elem.category == "Sentence"
(elem) => elem.category === "Sentence"
);

const resPagination = await axios.get(
@@ -306,7 +300,7 @@ const SpeakSentenceComponent = () => {
{...{
background: "linear-gradient(45deg, #FF730E 30%, #FFB951 90%)",
header:
questions[currentQuestion]?.contentType == "image"
questions[currentQuestion]?.contentType === "image"
? `Guess the below image`
: `Speak the below ${questions[currentQuestion]?.contentType}`,
words: questions[currentQuestion]?.contentSourceData?.[0]?.text,
Loading