Skip to content

Commit

Permalink
IssueId #219606 feat: on submit should call the learnerai API call in…
Browse files Browse the repository at this point in the history
… Storylingo [React]
  • Loading branch information
ajinkyapandetekdi committed May 23, 2024
2 parents 68421e0 + aab9014 commit 57c83aa
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ const Practice = () => {
setGameOverData({ gameOver: true, userWon, ...data, meetsFluencyCriteria});
};

const isFirefox = () => {
return typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().includes('firefox');
};

useEffect(() => {
if (startShowCase) {
setLivesData({ ...livesData, lives: LIVES });
Expand Down Expand Up @@ -317,6 +321,15 @@ const Practice = () => {
let showcaseLevel =
currentPracticeStep == 3 || currentPracticeStep == 8;
setIsShowCase(showcaseLevel);
if (showcaseLevel && localStorage.getItem('isShowcaseReload') === null && isFirefox()) {
localStorage.setItem('isShowcaseReload', true)
const iframe = window.parent.document.getElementById("myLearningJourneyIframe");
const baseUrl = iframe.src.split('#')[0].split('?')[0];
iframe.src = `${baseUrl}#/practice`;
}
else if (!showcaseLevel && localStorage.getItem('isShowcaseReload') && isFirefox()) {
localStorage.removeItem('isShowcaseReload')
}

quesArr = [...quesArr, ...(resGetContent?.data?.content || [])];
setCurrentContentType(resGetContent?.data?.content?.[0]?.contentType);
Expand Down Expand Up @@ -463,7 +476,15 @@ const Practice = () => {

let showcaseLevel = userState == 4 || userState == 9;
setIsShowCase(showcaseLevel);

if (showcaseLevel && localStorage.getItem('isShowcaseReload') === null && isFirefox()) {
localStorage.setItem('isShowcaseReload', true)
const iframe = window.parent.document.getElementById("myLearningJourneyIframe");
const baseUrl = iframe.src.split('#')[0].split('?')[0];
iframe.src = `${baseUrl}#/practice`;
}
else if (!showcaseLevel && localStorage.getItem('isShowcaseReload') && isFirefox()) {
localStorage.removeItem('isShowcaseReload')
}
if (showcaseLevel) {
await axios.post(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.ADD_LESSON}`,
Expand Down

0 comments on commit 57c83aa

Please sign in to comment.