Skip to content

Commit 49e768a

Browse files
committed
Merge branch 'all-1.2' of github.com:Sunbird-ALL/storylingo-v2 into all-1.2
2 parents 04c9989 + 6e3bdda commit 49e768a

File tree

2 files changed

+137
-70
lines changed

2 files changed

+137
-70
lines changed

src/assets/images/logout.svg

Lines changed: 4 additions & 0 deletions
Loading

src/components/Assesment/Assesment.jsx

Lines changed: 133 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import {
44
Box,
55
Grid,
66
IconButton,
7+
Tooltip,
78
Typography,
89
} from "../../../node_modules/@mui/material/index";
10+
import LogoutImg from "../../assets/images/logout.svg";
11+
import { styled } from "@mui/material/styles";
912
import {
1013
RoundTick,
1114
SelectLanguageButton,
@@ -16,9 +19,7 @@ import {
1619
setLocalData,
1720
} from "../../utils/constants";
1821
import practicebg from "../../assets/images/practice-bg.svg";
19-
import {
20-
useNavigate,
21-
} from "../../../node_modules/react-router-dom/dist/index";
22+
import { useNavigate } from "../../../node_modules/react-router-dom/dist/index";
2223
import { useEffect, useState } from "react";
2324
import axios from "../../../node_modules/axios/index";
2425
// import { useDispatch } from 'react-redux';
@@ -42,6 +43,7 @@ import config from "../../utils/urlConstants.json";
4243
import panda from "../../assets/images/panda.svg";
4344
import cryPanda from "../../assets/images/cryPanda.svg";
4445
import { uniqueId } from "../../services/utilService";
46+
import { end } from "../../services/telementryService";
4547

4648
export const LanguageModal = ({ lang, setLang, setOpenLangModal }) => {
4749
const [selectedLang, setSelectedLang] = useState(lang);
@@ -169,7 +171,8 @@ export const LanguageModal = ({ lang, setLang, setOpenLangModal }) => {
169171
</Box>
170172
<Box
171173
sx={{ width: "100%", display: "flex", justifyContent: "center" }}
172-
mt={5} mb={1}
174+
mt={5}
175+
mb={1}
173176
// mr="110px"
174177
>
175178
<Box
@@ -340,17 +343,49 @@ export const ProfileHeader = ({
340343

341344
const handleProfileBack = () => {
342345
try {
343-
if (process.env.REACT_APP_IS_APP_IFRAME === 'true') {
344-
window.parent.postMessage({ type: 'restore-iframe-content' }, '*');
345-
navigate("/")
346+
if (process.env.REACT_APP_IS_APP_IFRAME === "true") {
347+
window.parent.postMessage({ type: "restore-iframe-content" }, "*");
348+
navigate("/");
346349
} else {
347-
navigate("/discover-start")
350+
navigate("/discover-start");
348351
}
349352
} catch (error) {
350353
console.error("Error posting message:", error);
351354
}
352355
};
353356

357+
const handleLogout = () => {
358+
localStorage.clear();
359+
end({});
360+
navigate("/Login");
361+
};
362+
363+
const CustomIconButton = styled(IconButton)({
364+
padding: "6px 20px",
365+
color: "white",
366+
fontSize: "20px",
367+
fontWeight: 500,
368+
borderRadius: "8px",
369+
marginRight: "10px",
370+
fontFamily: '"Lato", "sans-serif"',
371+
position: "relative",
372+
display: "flex",
373+
alignItems: "center",
374+
justifyContent: "center",
375+
"& .logout-img": {
376+
display: "block",
377+
filter: "invert(1)",
378+
},
379+
});
380+
381+
const CustomTooltip = styled(({ className, ...props }) => (
382+
<Tooltip {...props} classes={{ popper: className }} />
383+
))({
384+
[`& .MuiTooltip-tooltip`]: {
385+
fontSize: "1.2rem", // Adjust the font size as needed
386+
},
387+
});
388+
354389
return (
355390
<>
356391
{!!openMessageDialog && (
@@ -377,7 +412,13 @@ export const ProfileHeader = ({
377412
zIndex: 5555,
378413
}}
379414
>
380-
<Box sx={{ display: "flex", alignItems: "center", width: { xs: "100%", sm: "50%" } }}>
415+
<Box
416+
sx={{
417+
display: "flex",
418+
alignItems: "center",
419+
width: { xs: "100%", sm: "50%" },
420+
}}
421+
>
381422
{handleBack && (
382423
<Box ml={{ xs: "10px", sm: "94px" }}>
383424
<IconButton onClick={handleBack}>
@@ -388,11 +429,19 @@ export const ProfileHeader = ({
388429
{username && (
389430
<>
390431
<Box
391-
ml={handleBack ? { xs: "10px", sm: "12px" } : { xs: "10px", sm: "94px" }}
432+
ml={
433+
handleBack
434+
? { xs: "10px", sm: "12px" }
435+
: { xs: "10px", sm: "94px" }
436+
}
392437
sx={{ cursor: "pointer" }}
393438
onClick={handleProfileBack}
394439
>
395-
<img src={profilePic} alt="profile-pic" style={{ height: "30px" }} />
440+
<img
441+
src={profilePic}
442+
alt="profile-pic"
443+
style={{ height: "30px" }}
444+
/>
396445
</Box>
397446
<Box ml="12px">
398447
<span
@@ -404,13 +453,13 @@ export const ProfileHeader = ({
404453
lineHeight: "25px",
405454
}}
406455
>
407-
{username || ""}
456+
{username || ""}
408457
</span>
409458
</Box>
410459
</>
411460
)}
412461
</Box>
413-
462+
414463
<Box
415464
sx={{
416465
justifySelf: "flex-end",
@@ -440,7 +489,7 @@ export const ProfileHeader = ({
440489
</span>
441490
</Box>
442491
</Box> */}
443-
492+
444493
<Box
445494
mr={{ xs: "10px", sm: "90px" }}
446495
onClick={() =>
@@ -470,6 +519,20 @@ export const ProfileHeader = ({
470519
</Box>
471520
</Box>
472521
</Box>
522+
{process.env.REACT_APP_IS_IN_APP_AUTHORISATION === "true" && (
523+
<CustomTooltip title="Logout">
524+
<Box>
525+
<CustomIconButton onClick={handleLogout}>
526+
<img
527+
className="logout-img"
528+
style={{ height: 30, width: 35 }}
529+
src={LogoutImg}
530+
alt="Logout"
531+
/>
532+
</CustomIconButton>
533+
</Box>
534+
</CustomTooltip>
535+
)}
473536
</Box>
474537
</Box>
475538
</>
@@ -491,7 +554,7 @@ const Assesment = ({ discoverStart }) => {
491554
const [level, setLevel] = useState("");
492555
const dispatch = useDispatch();
493556
const [openLangModal, setOpenLangModal] = useState(false);
494-
const [lang, setLang] = useState(getLocalData("lang") || "en");
557+
const [lang, setLang] = useState(getLocalData("lang") || "en");
495558
const [points, setPoints] = useState(0);
496559

497560
useEffect(() => {
@@ -524,11 +587,11 @@ const Assesment = ({ discoverStart }) => {
524587
);
525588
let session_id = localStorage.getItem("sessionId");
526589

527-
if (!session_id){
590+
if (!session_id) {
528591
session_id = uniqueId();
529-
localStorage.setItem("sessionId", session_id)
592+
localStorage.setItem("sessionId", session_id);
530593
}
531-
594+
532595
localStorage.setItem("lang", lang || "ta");
533596
const getPointersDetails = await axios.get(
534597
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${usernameDetails?.data?.result?.virtualID}/${session_id}?language=${lang}`
@@ -555,9 +618,9 @@ const Assesment = ({ discoverStart }) => {
555618
);
556619
let sessionId = getLocalData("sessionId");
557620

558-
if (!sessionId || sessionId === 'null'){
621+
if (!sessionId || sessionId === "null") {
559622
sessionId = uniqueId();
560-
localStorage.setItem("sessionId", sessionId)
623+
localStorage.setItem("sessionId", sessionId);
561624
}
562625

563626
if (virtualId) {
@@ -607,7 +670,7 @@ const Assesment = ({ discoverStart }) => {
607670
height: "100vh",
608671
backgroundImage: `url(${images?.[`desktopLevel${level || 1}`]})`,
609672
backgroundRepeat: "round",
610-
backgroundSize: 'auto',
673+
backgroundSize: "auto",
611674
position: "relative",
612675
};
613676

@@ -675,68 +738,68 @@ const Assesment = ({ discoverStart }) => {
675738
</Box>
676739
) : (
677740
<MainLayout
678-
showNext={false}
679-
showTimer={false}
680-
cardBackground={assessmentBackground}
681-
backgroundImage={practicebg}
682-
{...{
683-
setOpenLangModal,
684-
lang,
685-
points,
686-
}}
687-
>
688-
<Box
689-
sx={{
690-
position: "absolute",
691-
right: { xs: 20, md: 200 },
692-
display: "flex",
693-
flexDirection: "column",
694-
justifyContent: "center",
695-
alignItems: "center",
696-
mt: { xs: 2, md: 5 },
741+
showNext={false}
742+
showTimer={false}
743+
cardBackground={assessmentBackground}
744+
backgroundImage={practicebg}
745+
{...{
746+
setOpenLangModal,
747+
lang,
748+
points,
697749
}}
698750
>
699-
<Typography
751+
<Box
700752
sx={{
701-
color: "#322020",
702-
fontWeight: 700,
703-
fontSize: { xs: "24px", md: "40px" },
704-
fontFamily: "Quicksand",
705-
lineHeight: { xs: "36px", md: "62px" },
706-
textAlign: "center",
753+
position: "absolute",
754+
right: { xs: 20, md: 200 },
755+
display: "flex",
756+
flexDirection: "column",
757+
justifyContent: "center",
758+
alignItems: "center",
759+
mt: { xs: 2, md: 5 },
707760
}}
708761
>
709-
{discoverStart
710-
? "Let's test your language skills"
711-
: "You have good language skills"}
712-
</Typography>
713-
<Box>
714762
<Typography
715763
sx={{
716-
color: "#1CB0F6",
717-
fontWeight: 600,
718-
fontSize: { xs: "20px", md: "30px" },
764+
color: "#322020",
765+
fontWeight: 700,
766+
fontSize: { xs: "24px", md: "40px" },
719767
fontFamily: "Quicksand",
720-
lineHeight: { xs: "30px", md: "50px" },
768+
lineHeight: { xs: "36px", md: "62px" },
721769
textAlign: "center",
722770
}}
723771
>
724-
{level > 0
725-
? `Take the assessment to complete Level ${level}.`
726-
: "Take the assessment to discover your level"}
772+
{discoverStart
773+
? "Let's test your language skills"
774+
: "You have good language skills"}
727775
</Typography>
776+
<Box>
777+
<Typography
778+
sx={{
779+
color: "#1CB0F6",
780+
fontWeight: 600,
781+
fontSize: { xs: "20px", md: "30px" },
782+
fontFamily: "Quicksand",
783+
lineHeight: { xs: "30px", md: "50px" },
784+
textAlign: "center",
785+
}}
786+
>
787+
{level > 0
788+
? `Take the assessment to complete Level ${level}.`
789+
: "Take the assessment to discover your level"}
790+
</Typography>
791+
</Box>
792+
<Box
793+
sx={{
794+
cursor: "pointer",
795+
mt: { xs: 1, md: 2 },
796+
}}
797+
onClick={handleRedirect}
798+
>
799+
<StartAssessmentButton />
800+
</Box>
728801
</Box>
729-
<Box
730-
sx={{
731-
cursor: "pointer",
732-
mt: { xs: 1, md: 2 },
733-
}}
734-
onClick={handleRedirect}
735-
>
736-
<StartAssessmentButton />
737-
</Box>
738-
</Box>
739-
</MainLayout>
802+
</MainLayout>
740803
)}
741804
</>
742805
);

0 commit comments

Comments
 (0)