From 903d98aeaba70278b2fc93ec4732df6877b47fcf Mon Sep 17 00:00:00 2001 From: sagar takle Date: Wed, 18 Dec 2024 14:23:04 +0530 Subject: [PATCH] Update username and school_udise in telemetry cdata and tags (#57) * fix:add username and school_udise * fix:build issue --------- Co-authored-by: sagar --- src/App.jsx | 6 ++++-- src/pages/videos/VideoReels.tsx | 29 ++++++++++++++++++++++++----- src/pages/videos/index.tsx | 4 ++-- src/services/auth/auth.ts | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index dae63b8..2634c0b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -19,6 +19,7 @@ const theme = extendTheme(customTheme); function AppRouter() { const [routes, setRoutes] = useState([]); const [token, setToken] = useState(); + const [authUser, setAuthUser] = useState(); const location = useLocation(); const navigate = useNavigate(); useEffect(() => { @@ -43,6 +44,7 @@ function AppRouter() { if (result?.success && result?.token) { setToken(result?.token); + setAuthUser(result?.data); } else { setToken(); } @@ -52,7 +54,7 @@ function AppRouter() { }; validateUser(); - }, [location.pathname]); // call on page change + }, [location?.pathname]); // call on page change return ( @@ -60,7 +62,7 @@ function AppRouter() { } + element={} /> ))} diff --git a/src/pages/videos/VideoReels.tsx b/src/pages/videos/VideoReels.tsx index 9bb0d83..0808e78 100644 --- a/src/pages/videos/VideoReels.tsx +++ b/src/pages/videos/VideoReels.tsx @@ -77,7 +77,8 @@ const VideoItem: React.FC<{ isVisible: boolean; style: React.CSSProperties; refQml?: any; -}> = memo(({ programID, id, qml_id, isVisible, refQml, style }) => { + authUser?: any; +}> = memo(({ programID, id, qml_id, isVisible, refQml, style, authUser }) => { const [isLoading, setIsLoading] = useState(true); const [playerContext, setPlayerContext] = useState(contextData); const { width, height } = useDeviceSize(); @@ -120,6 +121,14 @@ const VideoItem: React.FC<{ id: programID, type: "program", }, + { + id: authUser?.Student?.School?.udiseCode, + type: "school_udise", + }, + { + id: authUser?.username, + type: "username", + }, ], tags: [ ...contextData.tags, @@ -127,6 +136,14 @@ const VideoItem: React.FC<{ id: programID, type: "program", }, + { + id: authUser?.Student?.School?.udiseCode, + type: "school_udise", + }, + { + id: authUser?.username, + type: "username", + }, ], }); setLesson(resultData); @@ -258,10 +275,11 @@ const VideoItem: React.FC<{ ); }); -const VideoReel: React.FC<{ videos: any[]; programID?: string }> = ({ - videos, - programID, -}) => { +const VideoReel: React.FC<{ + videos: any[]; + programID?: string; + authUser: any; +}> = ({ videos, programID, authUser }) => { const listRef = useRef(null); const qmlRef = useRef(null); const [visibleIndex, setVisibleIndex] = useState(0); @@ -379,6 +397,7 @@ const VideoReel: React.FC<{ videos: any[]; programID?: string }> = ({ refQml={qmlRef} style={style} key={"VideoItem" + index} + authUser={authUser} /> )} diff --git a/src/pages/videos/index.tsx b/src/pages/videos/index.tsx index 46f3411..b10c268 100644 --- a/src/pages/videos/index.tsx +++ b/src/pages/videos/index.tsx @@ -23,7 +23,7 @@ const getSubject = async () => { return localStorage.getItem("subject") || null; }; -const App = () => { +const App = (props: any) => { const navigate = useNavigate(); const [videos, setVideos] = useState>([]); const [error, setError] = useState(null); @@ -69,7 +69,7 @@ const App = () => { return error ? ( ) : ( - + ); }; diff --git a/src/services/auth/auth.ts b/src/services/auth/auth.ts index d8a95ea..75f1136 100644 --- a/src/services/auth/auth.ts +++ b/src/services/auth/auth.ts @@ -286,7 +286,7 @@ export const checkUserDetails = async () => { } const data = await response.json(); - return { success: true, token }; + return { success: true, token, data: data?.data?.[0] || {} }; } catch (error: unknown) { return { success: false,