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';
Expand All @@ -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({
Expand Down Expand Up @@ -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;
}
};

Expand Down
20 changes: 9 additions & 11 deletions src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} 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";
Expand All @@ -38,7 +37,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";
Expand Down Expand Up @@ -91,7 +89,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
Expand Down Expand Up @@ -380,7 +378,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
Expand Down Expand Up @@ -452,7 +450,7 @@ export const ProfileHeader = ({
lineHeight: "25px",
}}
>
{languages?.find((elem) => elem.lang == language).name ||
{languages?.find((elem) => elem.lang === language).name ||
`Select Language`}
</span>
</Box>
Expand All @@ -471,8 +469,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("");
Expand Down Expand Up @@ -513,7 +511,7 @@ const Assesment = ({ discoverStart }) => {

localStorage.setItem("lang", lang || "ta");
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_POINTER}/${usernameDetails?.data?.result?.virtualID}/${session_id}?language=${lang}`
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${usernameDetails?.data?.result?.virtualID}/${session_id}?language=${lang}`
);
setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);

Expand All @@ -538,7 +536,7 @@ const Assesment = ({ discoverStart }) => {
const sessionId = getLocalData("sessionId");
if (virtualId) {
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
}
Expand All @@ -551,15 +549,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");
Expand Down
25 changes: 10 additions & 15 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";
Expand Down Expand Up @@ -44,7 +40,7 @@ const AssesmentEnd = () => {
setLocalData("userLevel", data.data.milestone_level?.replace("m", ""));
const sessionId = getLocalData("sessionId");
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
})();
Expand All @@ -53,7 +49,6 @@ const AssesmentEnd = () => {
}, 4000);
}, []);

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

Expand Down Expand Up @@ -86,7 +81,7 @@ const AssesmentEnd = () => {
letterSpacing: "2%",
}}
>
{newLevel == previousLevel ? "Amost There.!" : `Hurray.!`}
{newLevel === previousLevel ? "Amost There.!" : `Hurray.!`}
</span>
</Box>
<Box
Expand All @@ -106,7 +101,7 @@ const AssesmentEnd = () => {
lineHeight: "30px",
}}
>
{newLevel == previousLevel
{newLevel === previousLevel
? "more"
: `Level ${previousLevel || ""}`}
</span>
Expand All @@ -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
Expand All @@ -149,7 +144,7 @@ const AssesmentEnd = () => {
lineHeight: "30px",
}}
>
{newLevel == previousLevel ? "required" : `successfully`}
{newLevel === previousLevel ? "required" : `successfully`}
</span>
</Box>
</Box>
Expand Down Expand Up @@ -308,7 +303,7 @@ const AssesmentEnd = () => {
textAlign: "center",
}}
>
{newLevel == previousLevel ? `Almost There!!!` : `Hurray!!!`}
{newLevel === previousLevel ? `Almost There!!!` : `Hurray!!!`}
</Typography>
<Box mt={1}>
<span
Expand All @@ -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>
Expand Down
42 changes: 18 additions & 24 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";
Expand All @@ -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);
Expand All @@ -50,7 +44,7 @@ const SpeakSentenceComponent = () => {
}, [questions]);

useEffect(() => {
if (questions?.length && !initialAssesment && currentQuestion == 0) {
if (questions?.length && !initialAssesment && currentQuestion === 0) {
deepali-chavhan marked this conversation as resolved.
Show resolved Hide resolved
setDisableScreen(true);
callConfettiAndPlay();
setTimeout(() => {
Expand All @@ -71,7 +65,7 @@ const SpeakSentenceComponent = () => {
const virtualId = getLocalData("virtualId");
const lang = getLocalData("lang");
const getPointersDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
);
setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
})();
Expand All @@ -94,7 +88,7 @@ const SpeakSentenceComponent = () => {
setVoiceText("");
setEnableNext(false);
}
if (voiceText == "success") {
if (voiceText === "success") {
deepali-chavhan marked this conversation as resolved.
Show resolved Hide resolved
setEnableNext(true);
// go_to_result(voiceText);
setVoiceText("");
Expand All @@ -119,13 +113,13 @@ const SpeakSentenceComponent = () => {

if (!(localStorage.getItem("contentSessionId") !== null)) {
const pointsRes = await axios.post(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.ADD_POINTER}/`,
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.ADD_POINTER}`,
{
userId: localStorage.getItem("virtualId"),
sessionId: localStorage.getItem("sessionId"),
points: 1,
language: lang,
milestoneLevel: "m0",
milestone: "m0",
}
);
setPoints(pointsRes?.data?.result?.totalLanguagePoints || 0);
Expand All @@ -149,7 +143,7 @@ const SpeakSentenceComponent = () => {

if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
} else if (currentQuestion == questions.length - 1) {
} else if (currentQuestion === questions.length - 1) {
deepali-chavhan marked this conversation as resolved.
Show resolved Hide resolved
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}`,
Expand All @@ -175,16 +169,16 @@ const SpeakSentenceComponent = () => {
}
);
if (
getSetData.data.sessionResult == "pass" &&
currentContentType == "Sentence" &&
getSetData.data.sessionResult === "pass" &&
deepali-chavhan marked this conversation as resolved.
Show resolved Hide resolved
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}`
Expand All @@ -197,17 +191,17 @@ const SpeakSentenceComponent = () => {
setCurrentQuestion(0);
setSentencePassedCounter(newSentencePassedCounter);
setQuestions(quesArr);
} else if (getSetData.data.sessionResult == "pass") {
} else if (getSetData.data.sessionResult === "pass") {
deepali-chavhan marked this conversation as resolved.
Show resolved Hide resolved
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}`
Expand All @@ -218,13 +212,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}`
Expand Down Expand Up @@ -262,7 +256,7 @@ const SpeakSentenceComponent = () => {
);

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

const resPagination = await axios.get(
Expand Down Expand Up @@ -302,7 +296,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,
Expand Down
Loading