Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -43,6 +44,7 @@ function AppRouter() {

if (result?.success && result?.token) {
setToken(result?.token);
setAuthUser(result?.data);
} else {
setToken();
}
Expand All @@ -52,15 +54,15 @@ function AppRouter() {
};

validateUser();
}, [location.pathname]); // call on page change
}, [location?.pathname]); // call on page change

return (
<Routes>
{routes?.map((item, index) => (
<Route
key={item?.path + index}
path={item?.path}
element={<item.component />}
element={<item.component {...{ authUser }} />}
/>
))}
</Routes>
Expand Down
29 changes: 24 additions & 5 deletions src/pages/videos/VideoReels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(true);
const [playerContext, setPlayerContext] = useState<any>(contextData);
const { width, height } = useDeviceSize();
Expand Down Expand Up @@ -120,13 +121,29 @@ const VideoItem: React.FC<{
id: programID,
type: "program",
},
{
id: authUser?.Student?.School?.udiseCode,
type: "school_udise",
},
{
id: authUser?.username,
type: "username",
},
],
tags: [
...contextData.tags,
{
id: programID,
type: "program",
},
{
id: authUser?.Student?.School?.udiseCode,
type: "school_udise",
},
{
id: authUser?.username,
type: "username",
},
],
});
setLesson(resultData);
Expand Down Expand Up @@ -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<HTMLDivElement>(null);
const qmlRef = useRef<HTMLDivElement>(null);
const [visibleIndex, setVisibleIndex] = useState(0);
Expand Down Expand Up @@ -379,6 +397,7 @@ const VideoReel: React.FC<{ videos: any[]; programID?: string }> = ({
refQml={qmlRef}
style={style}
key={"VideoItem" + index}
authUser={authUser}
/>
)}
</List>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/videos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Array<any>>([]);
const [error, setError] = useState<string | null>(null);
Expand Down Expand Up @@ -69,7 +69,7 @@ const App = () => {
return error ? (
<Loading showSpinner={false} message={error} onBackClick={onBackClick} />
) : (
<VideoReel videos={videos} programID={programID} />
<VideoReel {...{ programID, videos, ...props }} />
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading