Skip to content

Commit 50a7cbb

Browse files
Merge pull request #5 from darshilbabel/release-1.0.0
QA drop 6
2 parents 9b52a98 + 3796429 commit 50a7cbb

9 files changed

Lines changed: 200 additions & 118 deletions

File tree

public/locales/en/translation.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"confirmChanges": "Yes",
33
"popUpChanges": "<div class='text-class'>\n You've been inactive for a while.\n Do you want to continue?\n</div>",
4-
"guestPopUpChanges": "<div class='text-class'>\n Are you sure you want to leave this conversation?\n All your progress will be lost\n</div>",
4+
"guestPopUpChanges": "<div class='text-class'>\n Are you sure you want to leave this conversation?\n</div>",
55
"comfirmButton": "Yes",
66
"denyButton": "No",
77
"doLater": "I will do it later",
@@ -149,5 +149,7 @@
149149
"landing_tagline": "Micro Improvement Mega Impact",
150150
"landing_login_btn": "Login",
151151
"sidebarTitle": "SAATHI",
152-
"sidebarEmptyText": "Your past conversations will appear here"
152+
"sidebarEmptyText": "Your past conversations will appear here",
153+
"sessionExpiredMessage": "Session expired. Please log in again to continue.",
154+
"profileOnboardingCompleteMessage": "Thank you. I have all the information I need. Redirecting you to Saathi"
153155
}

public/locales/hi/translation.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"confirmChanges": "हाँ",
33
"popUpChanges": "<div class='text-class'>\n आप कुछ समय से निष्क्रिय हैं। \n क्या आप जारी रखना चाहते हैं?\n</div>",
4-
"guestPopUpChanges": "<div class='text-class'>\n क्या आप वाकई इस बातचीत को छोड़ना चाहते हैं?\n आपकी सारी प्रगति खो जाएगी\n</div>",
4+
"guestPopUpChanges": "<div class='text-class'>\n क्या आप वाकई इस बातचीत को छोड़ना चाहते हैं?\n</div>",
55
"comfirmButton": "हाँ",
66
"denyButton": "नहीं",
77
"doLater": "मैं इसे बाद में करूंगा",
@@ -26,11 +26,11 @@
2626
"reportLoader": "आपकी रिपोर्ट बनाने में कुछ समय लग सकता है। कृपया प्रतीक्षा करें...",
2727
"downloadLoader": "डाउनलोड हो रहा है कृपया प्रतीक्षा करें...",
2828
"downloadFileError": "आपकी फ़ाइल डाउनलोड नहीं हो सकी। कृपया पुनः प्रयास करें।",
29-
"homepageHeading": "स्वागत!",
30-
"homepageList": "मैं साथी हूं, आपका विद्यालय सुधार सहयोगी।",
29+
"homepageHeading": "स्वागत है!",
30+
"homepageList": "मैं साथी हूँ, आपका विद्यालय सुधार सहयोगी।",
3131
"homepageList1": "आप जिन चुनौतियों का सामना कर रहे हैं, उनके बारे में बताएं या शिक्षा के बारे में मुझसे कुछ भी पूछें —",
3232
"homepageList2": "मैं इसमें आपकी मदद करूंगा।",
33-
"profileHomepageList1": "शुरू करने से पहले, मुझे आपके अनुभव को व्यक्तिगत बनाने में मदद करने के लिए आपसे कुछ जानकारी एकत्र करने की आवश्यकता होगी",
33+
"profileHomepageList1": "शुरू करने से पहले, मुझे आपसे कुछ जानकारी चाहिए ताकि मैं आपके अनुभव को व्यक्तिगत बना सकूँ",
3434
"profileHomepageList2": "क्या हम शुरू कर सकते हैं?",
3535
"la_homepageHeading": "हम आपकी बात सुनने के लिए यहाँ हैं",
3636
"la_homepageHeading1": "साथी के साथ!",
@@ -137,5 +137,7 @@
137137
"landing_tagline": "सूक्ष्म सुधार, बड़ा प्रभाव",
138138
"landing_login_btn": "लॉगिन",
139139
"sidebarTitle": "साथी",
140-
"sidebarEmptyText": "आपकी पिछली बातचीत यहाँ दिखाई देंगी"
140+
"sidebarEmptyText": "आपकी पिछली बातचीत यहाँ दिखाई देंगी",
141+
"sessionExpiredMessage": "सत्र समाप्त हो गया। कृपया जारी रखने के लिए फिर से लॉग इन करें।",
142+
"profileOnboardingCompleteMessage": "धन्यवाद। मुझे ज़रूरी सारी जानकारी मिल गई है। आपको साथी पर रीडायरेक्ट किया जा रहा है।"
141143
}

public/locales/kn/translation.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"confirmChanges": "ಹೌದು",
33
"popUpChanges": "<div class='text-class'>\n ನೀವು ಸ್ವಲ್ಪ ಸಮಯದಿಂದ ನಿಷ್ಕ್ರಿಯರಾಗಿದ್ದೀರಿ.\n ನೀವು ಮುಂದುವರಿಸಲು ಬಯಸುತ್ತೀರಾ?\n</div>",
4-
"guestPopUpChanges": "<div class='text-class'>\n ನೀವು ಈ ಸಂಭಾಷಣೆಯನ್ನು ತ್ಯಜಿಸಲು ಖಚಿತವಾಗಿ ಬಯಸುತ್ತೀರಾ?\n ನಿಮ್ಮ ಎಲ್ಲಾ ಪ್ರಗತಿ ಕಳೆದುಹೋಗುತ್ತದೆ\n</div>",
4+
"guestPopUpChanges": "<div class='text-class'>\n ನೀವು ಈ ಸಂಭಾಷಣೆಯನ್ನು ತ್ಯಜಿಸಲು ಖಚಿತವಾಗಿ ಬಯಸುತ್ತೀರಾ?\n</div>",
55
"comfirmButton": "ಹೌದು",
66
"denyButton": "ಇಲ್ಲ",
77
"doLater": "ನಾನು ಅದನ್ನು ನಂತರ ಮಾಡುತ್ತೇನೆ.",
@@ -118,5 +118,7 @@
118118
"landing_tagline": "ಮೈಕ್ರೋ ಇಂಪ್ರೂವ್ಮೆಂಟ್ ಮೆಗಾ ಇಂಪ್ಯಾಕ್ಟ್",
119119
"landing_login_btn": "ಲಾಗಿನ್",
120120
"sidebarTitle": "ಸಾಥಿ",
121-
"sidebarEmptyText": "ನಿಮ್ಮ ಹಿಂದಿನ ಸಂಭಾಷಣೆಗಳು ಇಲ್ಲಿ ಕಾಣಿಸಿಕೊಳ್ಳುತ್ತವೆ"
121+
"sidebarEmptyText": "ನಿಮ್ಮ ಹಿಂದಿನ ಸಂಭಾಷಣೆಗಳು ಇಲ್ಲಿ ಕಾಣಿಸಿಕೊಳ್ಳುತ್ತವೆ",
122+
"sessionExpiredMessage": "ಅವಧಿ ಮುಗಿದಿದೆ. ಮುಂದುವರಿಯಲು ದಯವಿಟ್ಟು ಮತ್ತೆ ಲಾಗಿನ್ ಮಾಡಿ.",
123+
"profileOnboardingCompleteMessage": "ಧನ್ಯವಾದಗಳು. ನನಗೆ ಬೇಕಾದ ಎಲ್ಲಾ ಮಾಹಿತಿ ನನ್ನಲ್ಲಿದೆ. ನಿಮ್ಮನ್ನು ಸಾಥಿಗೆ ಮರುನಿರ್ದೇಶಿಸುತ್ತಿದ್ದೇನೆ."
122124
}

src/api/endpoints/user.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { API_ENDPOINTS } from "constants/urls"
22
import { apiClient } from "../client"
33
import env from "utils/env"
4+
import Swal from "sweetalert2"
5+
import i18n from "i18next"
6+
import ROUTES from "../../url"
47

58
/**
69
* Creates a new user profile
@@ -94,16 +97,31 @@ export const acceptTncApi = async profileId => {
9497
*/
9598
export const readElevateProfileApi = async accessToken => {
9699
try {
97-
const authUrl = env.AUTH_ROUTE();
100+
const authUrl = env.AUTH_ROUTE()
98101
const response = await apiClient.get(authUrl, {
99102
headers: {
100103
"Content-Type": "application/json",
101-
"x-auth-token": accessToken
104+
"x-auth-token": accessToken,
102105
},
103106
withCredentials: true,
104-
});
105-
return response?.data;
107+
})
108+
return response?.data
106109
} catch (error) {
107-
return error?.response?.data
110+
console.log("[readElevateProfileApi] error status:", error?.response?.status)
111+
if (error?.response?.status === 401) {
112+
const result = await Swal.fire({
113+
text: i18n.t("sessionExpiredMessage"),
114+
confirmButtonText: i18n.t("confirmChanges"),
115+
allowOutsideClick: false,
116+
})
117+
if (result.isConfirmed) {
118+
const flowName = env.FLOW_NAME()
119+
const search = flowName ? `?${new URLSearchParams({ flow: flowName }).toString()}` : ""
120+
window.location.href = ROUTES.SHIKSHALOKAM_HOME_PAGE + search
121+
}
122+
}
123+
else {
124+
throw error
125+
}
108126
}
109127
}

src/components/Header.jsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ const Header = ({
1717
return (
1818
<>
1919
{/* Desktop Language Selector */}
20-
<LanguageSelector
21-
// userLanguage={userLanguage}
22-
// onLanguageChange={onLanguageChange}
20+
{/* <LanguageSelector
2321
className="absolute top-6 right-6 hidden sm:block"
2422
isVisible={!!languageButtonSelect}
25-
/>
23+
/> */}
2624

2725
{/* Desktop Header */}
2826
<div className="px-5 hidden sm:block">
@@ -45,14 +43,12 @@ const Header = ({
4543
<>
4644
<div className="justify-center w-full flex sm:hidden">
4745
<div className="w-full">
48-
<div className={`${languageButtonSelect && ![null, ""].includes(languageButtonSelect) ? "justify-between" : "justify-center"} w-full flex sm:hidden items-center p-2`}>
46+
<div className="justify-center w-full flex sm:hidden items-center p-2">
4947
<img src={t("pageLogo")} className={`h-[50px] object-contain ${chatLanguage === "en" ? "w-[140px]" : "w-[100px]"}`} alt="shikshalokam_logo" />
50-
<LanguageSelector
51-
// userLanguage={userLanguage}
52-
// onLanguageChange={onLanguageChange}
48+
{/* <LanguageSelector
5349
className="w-[140px] flex justify-end p-2"
5450
isVisible={languageButtonSelect && ![null, ""].includes(languageButtonSelect)}
55-
/>
51+
/> */}
5652
</div>
5753
</div>
5854
</div>

src/pages/Login/commonPage.jsx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { useUserDataLocalStore, useChatDataLocalStore } from "store"
2222
import { useTranslation } from "react-i18next"
2323
import PrivacyPolicyPopup from "../../components/TnC/privacyPolicyPopup"
2424
import ProfileChatPopup from "../../components/ProfileChatPopup/ProfileChatPopup"
25-
import { getProfileApi, acceptTncApi } from "api/endpoints/user"
25+
import { getProfileApi, acceptTncApi, readElevateProfileApi } from "api/endpoints/user"
26+
import { clearFromStorage } from "../../services/storage_service"
2627
import { getSessionDetails } from "../../services/api.service"
2728

2829
function CommonHomePage({ usecaseType }) {
@@ -48,9 +49,12 @@ function CommonHomePage({ usecaseType }) {
4849

4950
const isSaathiHome = !usecaseType
5051

52+
const [isTokenValidating, setIsTokenValidating] = useState(() => isSaathiHome && !!accessToken)
53+
5154
const showLanding =
5255
isSaathiHome &&
53-
!Boolean(accessToken)
56+
!Boolean(accessToken) &&
57+
!isTokenValidating
5458

5559
const ptm_case = sessionFlowName.megaPTM === usecaseType
5660
const ylc_case = sessionFlowName.YLC === usecaseType
@@ -85,6 +89,31 @@ function CommonHomePage({ usecaseType }) {
8589
isTncAccepted === false &&
8690
!isProfileLoading
8791

92+
useEffect(() => {
93+
if (!isSaathiHome || !accessToken) return
94+
95+
const storedToken = accessToken
96+
;(async () => {
97+
try {
98+
const data = await readElevateProfileApi(storedToken)
99+
if (data) {
100+
clearFromStorage()
101+
const profile = data.profile_details
102+
const store = useUserDataLocalStore.getState()
103+
store.setAccessToken(env.AUTH_METHOD() === "url" ? storedToken : true)
104+
store.setProfileId(profile?.profileid)
105+
store.setFirstName(profile?.first_name)
106+
store.setCompanyName(profile?.company)
107+
store.setState(profile?.state)
108+
}
109+
} catch (error) {
110+
console.error("[CommonHomePage] Token validation failed:", error)
111+
} finally {
112+
setIsTokenValidating(false)
113+
}
114+
})()
115+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
116+
88117
useEffect(() => {
89118
if (zustandProfileId || !profileId) return
90119
useUserDataLocalStore.getState().setProfileId(profileId)
@@ -125,6 +154,7 @@ function CommonHomePage({ usecaseType }) {
125154
}, [urlFlow])
126155

127156
useEffect(() => {
157+
if (isTokenValidating) return
128158
if (showLanding) return
129159
if (isSaathiOnboarding && !saathiOnboardingDone) return
130160

@@ -134,10 +164,11 @@ function CommonHomePage({ usecaseType }) {
134164
pathname: ROUTES.COMMON_CHAT,
135165
search: new URLSearchParams({ [URL_PARAMS.FLOW]: urlFlow }).toString(),
136166
})
137-
}, [urlFlow, hasSelectedLanguage, showLanding, isSaathiOnboarding, saathiOnboardingDone])
167+
}, [isTokenValidating, urlFlow, hasSelectedLanguage, showLanding, isSaathiOnboarding, saathiOnboardingDone])
138168

139169
// Process language selection
140170
useEffect(() => {
171+
if (isTokenValidating) return
141172
if (showLanding) return
142173
if (!urlLanguage && !hasSelectedLanguage) {
143174
setIsLoading(false)
@@ -176,7 +207,7 @@ function CommonHomePage({ usecaseType }) {
176207
pathname: ROUTES.COMMON_CHAT,
177208
search: new URLSearchParams({ [URL_PARAMS.FLOW]: urlFlow }).toString(),
178209
})
179-
}, [chatLanguage, urlLanguage, urlFlow, hasSelectedLanguage, showLanding, isSaathiOnboarding, saathiOnboardingDone])
210+
}, [isTokenValidating, chatLanguage, urlLanguage, urlFlow, hasSelectedLanguage, showLanding, isSaathiOnboarding, saathiOnboardingDone])
180211

181212
useEffect(() => {
182213
handleLanguageChange(chatLanguage, audioRef, stopAllAudio, setStopAudioTriggered)

src/pages/ShikshalokamVoiceChat/chat-container.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,15 @@ function ChatContainer() {
130130
}
131131

132132
const setFinalLanguage = async () => {
133-
if (accessToken) return
133+
if (accessToken) {
134+
try {const session = await getSessionDetails()
135+
setSessionId(session.sessionid)}
136+
catch (error) {
137+
console.log("[ChatContainer] authenticated session bootstrap failed:", error)
138+
navigate(ROUTES.SHIKSHALOKAM_HOME_PAGE)
139+
}
140+
return
141+
}
134142

135143
await initialSetup()
136144
const storedLanguage = chatLanguage || languageList[0].value
@@ -169,7 +177,7 @@ function ChatContainer() {
169177

170178
return (
171179
<>
172-
{companyName && !isLoading && <DynamicVoiceChat />}
180+
{(companyName || accessToken) && !isLoading && <DynamicVoiceChat />}
173181
{(isLoading || !ipFetched) && (
174182
<div className="loader-load-spinner">
175183
<div className="div67">

src/pages/ShikshalokamVoiceChat/dynamic-voice-chat.js

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { AiOutlineEye } from "react-icons/ai"
44
import { API_ENDPOINTS } from "../../constants/urls"
55
import { BiLoader } from "react-icons/bi"
66
import { clearFromStorage, handleS3Upload } from "../../services/storage_service"
7-
import { createMessage } from "../interview-voice"
87
import { createUserProfileApi } from "api/endpoints/user"
8+
import { createMessage } from "../interview-voice"
99
import { getChatsFromDB, endStoryV2Api, getStoryBySessionAPI, updateStoryMediaApi, updateReflectionStatusApi, getAI4BharatAudioApi, ai4BharatASRApi, getFlowInfoApi } from "../../api/endpoints"
1010
import { extractStoryData, extractTextBlocks, getEditorContentBlocks, handleMultipleUploads } from "../../utils/story"
1111
import { FaCircle } from "react-icons/fa6"
@@ -335,14 +335,14 @@ const DynamicVoiceChat = ({
335335
setChatHistory([
336336
...currentHistory,
337337
{
338-
msg: "Thank you. I have all the information I need. Redirecting you to Saathi",
338+
msg: t("profileOnboardingCompleteMessage"),
339339
source: "bot",
340340
updated_at: Date.now(),
341341
received: true,
342342
},
343343
])
344344
onProfileExtractedRef.current?.()
345-
}, [])
345+
}, [t])
346346

347347
const onWebSocketMessage = useCallback(
348348
event => {
@@ -1123,16 +1123,18 @@ const DynamicVoiceChat = ({
11231123
setChatLanguage(languageList[0].value)
11241124
stopAllAudio()
11251125
if (accessToken) {
1126-
clearFromStorage()
1127-
navigateSsoFlow(ssoRerouteURL)
1126+
navigate({
1127+
pathname: ROUTES.SHIKSHALOKAM_HOME_PAGE,
1128+
search: new URLSearchParams({ flow: env.FLOW_NAME() }).toString(),
1129+
}, { replace: true })
11281130
} else {
11291131
navigate(ROUTES.SHIKSHALOKAM_VOICE_CHAT_LOGIN)
11301132
}
11311133
}
11321134
}
1133-
// Check if we already pushed a custom state
1135+
11341136
if (!window.history.state?.isCustom) {
1135-
window.history.pushState({ isCustom: true }, "", window.location.href)
1137+
window.history.replaceState({ isCustom: true }, "", window.location.href)
11361138
}
11371139

11381140
window.addEventListener("popstate", handleBack)
@@ -1249,12 +1251,38 @@ const DynamicVoiceChat = ({
12491251
}
12501252

12511253
if (!profileToUse && accessToken) {
1252-
createUserProfile()
1254+
// createUserProfile()
12531255
setShouldFetchIntro(true)
12541256
setIsStreamingComplete(true)
12551257
}
12561258
}, [accessToken, profileToUse])
12571259

1260+
/**
1261+
* Initialize popup mode: generate session and open new chat
1262+
* Runs when popup renders with an already-known profile (chat-container bypassed)
1263+
*/
1264+
useEffect(() => {
1265+
if (!isPopupMode) return
1266+
if (!accessToken || !profileToUse) return
1267+
1268+
;(async () => {
1269+
try {
1270+
setIsLoading(true)
1271+
if (!sessionId) {
1272+
const session = await getSessionDetails()
1273+
setSessionId(session.sessionid)
1274+
}
1275+
setIsNewChatOpen(true)
1276+
setShouldFetchIntro(true)
1277+
setIsStreamingComplete(true)
1278+
} catch (error) {
1279+
console.error("[DynamicVoiceChat popup] session init failed:", error)
1280+
} finally {
1281+
setIsLoading(false)
1282+
}
1283+
})()
1284+
}, [isPopupMode, accessToken, profileToUse])
1285+
12581286
/**
12591287
* Fetch chat session for Reflection flow based on projectId
12601288
* Retrieves existing session for project-based reflections
@@ -2004,29 +2032,14 @@ const DynamicVoiceChat = ({
20042032
}
20052033

20062034
const navigateBack = () => {
2007-
let rerouteUrl = previousUrl
2008-
const currentFlow = storageFlow
20092035
stopAllAudio()
2010-
if (accessToken) {
2011-
console.log("clearing storage")
2012-
clearFromStorage()
2013-
navigateSsoFlow(ssoRerouteURL)
2014-
return
2015-
}
2016-
console.log("clearing storage")
2017-
clearFromStorage()
2018-
setLanguage(LANGUAGE_ENUMS.ENGLISH)
2019-
setChatLanguage(LANGUAGE_ENUMS.ENGLISH)
2020-
setHasSelectedLanguage(false)
2021-
if (rerouteUrl && rerouteUrl !== null && rerouteUrl !== undefined && rerouteUrl !== "") {
2022-
window.location.href = rerouteUrl
2023-
} else {
2024-
navigate({
2036+
navigate(
2037+
{
20252038
pathname: ROUTES.SHIKSHALOKAM_HOME_PAGE,
2026-
search: currentFlow ? new URLSearchParams({ flow: currentFlow }).toString() : ''
2027-
})
2028-
window.location.reload()
2029-
}
2039+
search: new URLSearchParams({ flow: env.FLOW_NAME() }).toString(),
2040+
},
2041+
{ replace: true }
2042+
)
20302043
}
20312044

20322045
function navigateSsoFlow() {

0 commit comments

Comments
 (0)